From 40e0b05e6dbceced8b666108d100e5a28e81b7dd Mon Sep 17 00:00:00 2001 From: Jesse Hall Date: Fri, 23 May 2014 16:39:09 -0700 Subject: opengl: rcOpenColorBuffer must be synchronous The gralloc register_buffer() function, which calls rcOpenColorBuffer, must actually increment the reference count before returning. Otherwise the buffer allocator may release its reference before the client has obtained one, and the buffer will be freed prematurely. Since rcOpenColorBuffer was just sending a message to the host without waiting for it to be received/processed, this guarantee was not met. Adding a return value makes the call synchronous. Bug: 12988668 Change-Id: I8b2399cfb0f600f99b3387f630343291b59bc9a6 --- .../opengl/host/libs/libOpenglRender/RenderControl.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp') diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp b/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp index 6a15138..83ba9c5 100644 --- a/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp +++ b/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp @@ -215,13 +215,20 @@ static uint32_t rcCreateColorBuffer(uint32_t width, return fb->createColorBuffer(width, height, internalFormat); } -static void rcOpenColorBuffer(uint32_t colorbuffer) +static int rcOpenColorBuffer2(uint32_t colorbuffer) { FrameBuffer *fb = FrameBuffer::getFB(); if (!fb) { - return; + return -1; } - fb->openColorBuffer( colorbuffer ); + return fb->openColorBuffer( colorbuffer ); +} + +// Deprecated, kept for compatibility with old system images only. +// Use rcOpenColorBuffer2 instead. +static void rcOpenColorBuffer(uint32_t colorbuffer) +{ + (void) rcOpenColorBuffer2(colorbuffer); } static void rcCloseColorBuffer(uint32_t colorbuffer) @@ -359,4 +366,5 @@ void initRenderControlContext(renderControl_decoder_context_t *dec) dec->set_rcColorBufferCacheFlush(rcColorBufferCacheFlush); dec->set_rcReadColorBuffer(rcReadColorBuffer); dec->set_rcUpdateColorBuffer(rcUpdateColorBuffer); + dec->set_rcOpenColorBuffer2(rcOpenColorBuffer2); } -- cgit v1.1