Commit Graph

15 Commits

Author SHA1 Message Date
Jesse Hall
ac018fe3f6 EmuGL: refcount ColorBuffers on the host
The gralloc API assumes system-wide reference counting of gralloc
buffers. The host-GL accelerated gralloc maps buffers to host-side
ColorBuffer objects, but was destroying them unconditionally in
gralloc_free(), ignoring any additional references from
gralloc_register_buffer().

This affected the SurfaceTexture gralloc buffers used by the
Browser/WebView. For some reason these buffers are actually allocated
by SurfaceFlinger and passed back to the WebView through Binder. But
since SurfaceFlinger doesn't actually need the buffer for anything,
sometime after the WebView has called gralloc_register_buffer()
SurfaceFlinger calls gralloc_free() on it. This caused the host
ColorBuffer to be destroyed long before the WebView is done using it.

Change-Id: I33dbee887a48a6907041cf19e9f38a1f6c983eff
2012-02-21 11:13:20 -08:00
David 'Digit' Turner
5d1e8b2f28 emulator: opengl: add initLibrary function to render library
This adds an initLibrary() function to libOpenglRender.

It will be used by the emulator to fallback on software rendering
if the library cannot be initialized properly, e.g. if it is not
possible to load the host EGL/GLES libraries.

Change-Id: I41e8ad73a315166e4a15cbee1db72c2552370f46
2011-08-29 16:57:38 +02:00
Guy Zadickario
4629d2412b opengles emulator: fixes flashing effect on Mac
There is a flashing effect we see on Mac when switching between
drawables (pbuffer and a window) on the same context.
This change make the FrameBuffer object in the renderer to use
two different OpenGL contexts, one which is used while the pbuffer
drawable is bound and another which is used when the subwindow is
bounded during swap. The two contexts share textures so both contexts
have access to all allocated color buffers.

While this fixes the flashing effect on Mac, it should be more effective on
other platforms as well.

Change-Id: I63b49f0cdae8e2785765503750bbf5fbd4d963a1
2011-08-18 13:36:38 +03:00
Guy Zadickario
b9a5baf42b opengles emulator: code cleanup removing dead code
This change removes the 'blitFromPbuffer' path in the renderer
which uses binding pbuffer to texture. This path does not work
on all platforms and is not relavent any more. It simplifies
a lot the FBConfig filtering code.

Also, added a check to fail the renderer initialization if
the translator plugin does not support EGL_KHR_gl_texture_2d_image
and GL_OES_EGL_IMAGE (by both GLES implementations [1 and 2])
since our implementation requires it.

Change-Id: Ifd4c66943a8da56308cfb7e38914c962b4f5befe
2011-08-16 12:14:02 +03:00
Guy Zadickario
617416e693 opengles emulator: support display rotation and resize
Changes the render_api to support re-creating the display
sub-window and the ability to rotate the displayed framebuffer
image.
That currently works only when the renderer runs as a thread
and not as seperate process. Therefore we setup the library
to run the renderer as thread(s) inside the calling process
on *all* platforms for now.

Change-Id: Ifd009db903759042a7edcf89866d3c3fe076cae9
2011-08-11 17:36:20 +03:00
Guy Zadickario
13b3da879b opengles emulator: added FPS statistics printout
Make the renderer print FPS statistics every 1 second.
Need to set SHOW_FPS_STATS=1

Change-Id: I69e8c43a779e685ae0b34974d1ef33ad75e7a7e4
2011-08-11 17:36:13 +03:00
Guy Zadickario
f6b9241094 opengles emulator: support glEGLImageTargetRenderbufferStorageOES
needed changes to support glEGLImageTargetRenderbufferStorageOES,
added implementation in egl and added tokens to renderControl.

Also fixed function pointers returned by eglGetProcAddress to
return functions that works independant of the current context,
see system/egl/ClientAPIExts.cpp

That makes the egl_image conformance test to pass on the guest.

Change-Id: I580cda82ba0fb44f12b75aa0bbacf5cd9f15f744
2011-08-10 10:53:06 +02:00
Guy Zadickario
ded8587d2d opengles emulator: Fixed Windows renderer termination
Make the event pump loop in the renderer process we do on Windows
exit when the Framebuffer's subwindow is destroyed.
Fixed TcpStream to close the socket using 'closesocket' on windows,
otherwise the other end of the socket does not sense that the socket
is closed.

+ Use WS_DISABLED to ensure that our GL subwindow doesn't receive
  any input events.

Change-Id: Icb477b3e1d7993a8880acb5e01bc5da29309ae50
2011-08-10 10:11:13 +02:00
Guy Zadickario
467e5fb162 opengles emulator: fixed renderer termination flow
Handling clean exit of the renderer when stopOpenGLRenderer
is called. This is done by openning a connection to the renderer
and flag that it should exit. Added 'clientFlags' field which must
be send after every connection is made to the renderer for this purpose.
The server will wait for running rendering threads to exit and then will
close all EGL/GL resources and will exit. The stopOpenGLRenderer will
return only when the renderer has exited.

Change-Id: I8272b8ea59d5fc78453bb7bd2d25908068869fa7
2011-08-10 10:03:07 +02:00
Guy Zadickario
b68a421908 opengl renderer: Enable and fix renderer Mac support
The following enables the renderer build on darwin.
Moved platform specific type declarations from render_api.h
to render_api_platform_types.h so it can be included from the
objective c code.
Fixed subwindow to use EmuGLView which overrides NSView to prevent
background drawing of the view.
2011-07-03 15:40:52 +03:00
Amit Feller
1d3f5f58ce opengl renderer: create rendering subwindow
The application provides the window handle to which the
OpenglRenderer should render to however only a sub-region of
this window needs to be rendered. This change adds this functionality
by creating a native child subwindow into which rendering will happen.
2011-07-03 15:14:59 +03:00
Stas Gurtovoy
62d074d9f8 emulator opengl: add GLESv2 support to driver + renderer
Added GLESv2 library to system.
Made fixes to the host libOpenGLRender to
compile and support GLESv2 (defined WITH_GLES2).
Other fixes required to make GLESv2 to work.

Change-Id: I9eb198e6092e7fa3550342c50929dd1714282cb3
2011-06-30 09:14:12 +03:00
Stas Gurtovoy
613025efb3 emulator opengl: pool of fixups to the host side.
Those are the host side fixups required for the system to load
without failure to the point of bootanimation is run.

Change-Id: I42eebb123b05aaf6a0671e91e77a4ba6b330b852
2011-06-21 14:48:44 +03:00
Stas Gurtovoy
2220d27302 emulator opengl: added Bind texture to EGLImage/surface
added functionality to bind an EGLImage to a texture both
in the system and host sides.

Change-Id: I2dc26090b45da080ac4d0e8f5799c95f7cc54634
2011-06-21 01:41:50 +03:00
Guy Zadikario
1f0d3939ed emulatgor opengl: First commit of the host renderer library.
This is a library which includes all the OpenGL renderer functionality,
it is packaged in a library so that both the renderer process and the emulator
program will be able to use that functionality.

NOTES:
   1) gl_proc.h and GLDispatch.{h,cpp} in this commit will be replaced
      with the decoder auto-generated dispatch in a later commit, the
      auto-generated dispatch is currently missing some extension functions
      required for the renderer.
   2) look at host/include/libOpenglRender/render_api.h for the external
      interface defined for this library (to be used by the emulator).

The following is a description of each component:

FrameBuffer - The main object which manages the framebuffer and color buffers.
              This is a singleton which get initialized through its initialize
              static function. It initializes the OpenGL renderer and must be
              called first. This initialization function is not thread safe so
              it must be called before any thread that is calling to this
              library is created.

FBConfig - Includes a static set of configs supported by the renderer which get
           initialized during FrameBuffer initialization phase. Also,
           an instance of this class includes the a description of one frame
           buffer configuration supported by the renderer.

RenderContext - encapsulate a rendering context state.

ColorBuffer - implements a color buffer object as a texture which can be bind
              as render target or source.

WindowSurface - implements the functionality of a native window which can be
                bound to a rendering context and its target ColorBuffer can
                be specified and replaced.

ThreadInfo - holds per-thread information.

EGLDispatch - loads the EGL plugin library, all egl calls are made through
              this dispatch table which get initialized during initialization
              phase.

GLDispatch - loads the GLES plugin library, all GLES calls are made through
             this dispatch table which get initialized during initialization
             phase - This will be replaced by the auto-generated code of the
             decoder ...

RenderThread - implements a thread that reads command tokens from an IOStream
               and decode it.

RenderControl - implements the host side implementation of the renderControl
                API, when a renderControl token is decoded from the stream
                it is dispatched to this implementation.

RenderServer - implements a TCP server which listens to port number and
               launcges a RenderThread for each new connection.

Change-Id: I9f34d17bdfcb715893a13cd30086c767f499df87
2011-04-16 10:45:39 +03:00