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:
@@ -215,13 +215,22 @@ static uint32_t rcCreateColorBuffer(uint32_t width,
|
||||
return fb->createColorBuffer(width, height, internalFormat);
|
||||
}
|
||||
|
||||
static void rcDestroyColorBuffer(uint32_t colorbuffer)
|
||||
static void rcOpenColorBuffer(uint32_t colorbuffer)
|
||||
{
|
||||
FrameBuffer *fb = FrameBuffer::getFB();
|
||||
if (!fb) {
|
||||
return;
|
||||
}
|
||||
fb->DestroyColorBuffer( colorbuffer );
|
||||
fb->openColorBuffer( colorbuffer );
|
||||
}
|
||||
|
||||
static void rcCloseColorBuffer(uint32_t colorbuffer)
|
||||
{
|
||||
FrameBuffer *fb = FrameBuffer::getFB();
|
||||
if (!fb) {
|
||||
return;
|
||||
}
|
||||
fb->closeColorBuffer( colorbuffer );
|
||||
}
|
||||
|
||||
static int rcFlushWindowColorBuffer(uint32_t windowSurface)
|
||||
@@ -336,7 +345,8 @@ void initRenderControlContext(renderControl_decoder_context_t *dec)
|
||||
dec->set_rcCreateWindowSurface(rcCreateWindowSurface);
|
||||
dec->set_rcDestroyWindowSurface(rcDestroyWindowSurface);
|
||||
dec->set_rcCreateColorBuffer(rcCreateColorBuffer);
|
||||
dec->set_rcDestroyColorBuffer(rcDestroyColorBuffer);
|
||||
dec->set_rcOpenColorBuffer(rcOpenColorBuffer);
|
||||
dec->set_rcCloseColorBuffer(rcCloseColorBuffer);
|
||||
dec->set_rcSetWindowColorBuffer(rcSetWindowColorBuffer);
|
||||
dec->set_rcFlushWindowColorBuffer(rcFlushWindowColorBuffer);
|
||||
dec->set_rcMakeCurrent(rcMakeCurrent);
|
||||
|
||||
Reference in New Issue
Block a user