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
This commit is contained in:
Jesse Hall
2012-02-21 09:47:06 -08:00
parent 91d4e8e195
commit ac018fe3f6
7 changed files with 74 additions and 21 deletions

View File

@@ -76,13 +76,19 @@ uint32_t rcCreateColorBuffer(uint32_t width, uint32_t height, GLenum internalFor
be specified as a render target for a window surface through
rcSetWindowColorBuffer or to be displayed on the framebuffer window
through rcFBPost.
The function returns a handle to the colorBuffer object.
The function returns a handle to the colorBuffer object, with an initial
reference count of 1.
void rcDestroyColorBuffer(uint32_t colorbuffer);
destroyes a colorBuffer object.
void rcOpenColorBuffer(uint32_t colorbuffer);
Adds an additional reference to the colorbuffer, typically from a
different Android process than the one which created it.
void rcCloseColorBuffer(uint32_t colorbuffer);
Removes a reference to the colorbuffer. When the reference count drops
to zero the colorbuffer is automatically destroyed.
void rcFlushWindowColorBuffer(uint32_t windowSurface, uint32_t colorBuffer);
This flushes the current window color buffer
This flushes the current window color buffer
void rcSetWindowColorBuffer(uint32_t windowSurface, uint32_t colorBuffer);
This set the target color buffer for a windowSurface, when set the

View File

@@ -11,7 +11,8 @@ GL_ENTRY(void, rcDestroyContext, uint32_t context)
GL_ENTRY(uint32_t, rcCreateWindowSurface, uint32_t config, uint32_t width, uint32_t height)
GL_ENTRY(void, rcDestroyWindowSurface, uint32_t windowSurface)
GL_ENTRY(uint32_t, rcCreateColorBuffer, uint32_t width, uint32_t height, GLenum internalFormat)
GL_ENTRY(void, rcDestroyColorBuffer, uint32_t colorbuffer)
GL_ENTRY(void, rcOpenColorBuffer, uint32_t colorbuffer)
GL_ENTRY(void, rcCloseColorBuffer, uint32_t colorbuffer)
GL_ENTRY(void, rcSetWindowColorBuffer, uint32_t windowSurface, uint32_t colorBuffer)
GL_ENTRY(int, rcFlushWindowColorBuffer, uint32_t windowSurface)
GL_ENTRY(EGLint, rcMakeCurrent, uint32_t context, uint32_t drawSurf, uint32_t readSurf)