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:
@@ -26,9 +26,13 @@
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint32_t HandleType;
|
||||
struct ColorBufferRef {
|
||||
ColorBufferPtr cb;
|
||||
uint32_t refcount; // number of client-side references
|
||||
};
|
||||
typedef std::map<HandleType, RenderContextPtr> RenderContextMap;
|
||||
typedef std::map<HandleType, WindowSurfacePtr> WindowSurfaceMap;
|
||||
typedef std::map<HandleType, ColorBufferPtr> ColorBufferMap;
|
||||
typedef std::map<HandleType, ColorBufferRef> ColorBufferMap;
|
||||
|
||||
struct FrameBufferCaps
|
||||
{
|
||||
@@ -60,7 +64,8 @@ public:
|
||||
HandleType createColorBuffer(int p_width, int p_height, GLenum p_internalFormat);
|
||||
void DestroyRenderContext(HandleType p_context);
|
||||
void DestroyWindowSurface(HandleType p_surface);
|
||||
void DestroyColorBuffer(HandleType p_colorbuffer);
|
||||
void openColorBuffer(HandleType p_colorbuffer);
|
||||
void closeColorBuffer(HandleType p_colorbuffer);
|
||||
|
||||
bool bindContext(HandleType p_context, HandleType p_drawSurface, HandleType p_readSurface);
|
||||
bool setWindowSurfaceColorBuffer(HandleType p_surface, HandleType p_colorbuffer);
|
||||
|
||||
Reference in New Issue
Block a user