diff options
author | Jesse Hall <jessehall@google.com> | 2014-05-23 16:39:09 -0700 |
---|---|---|
committer | Jesse Hall <jessehall@google.com> | 2014-05-27 16:55:32 -0700 |
commit | 40e0b05e6dbceced8b666108d100e5a28e81b7dd (patch) | |
tree | ea734a41c68024924002c1a9e0df728dadea498d /emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp | |
parent | 93aa02793ea1594d788a3ec67139db183dc307b4 (diff) | |
download | sdk-40e0b05e6dbceced8b666108d100e5a28e81b7dd.zip sdk-40e0b05e6dbceced8b666108d100e5a28e81b7dd.tar.gz sdk-40e0b05e6dbceced8b666108d100e5a28e81b7dd.tar.bz2 |
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
Diffstat (limited to 'emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp')
-rw-r--r-- | emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp index 238f2c9..e7a7960 100644 --- a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp +++ b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp @@ -551,15 +551,17 @@ void FrameBuffer::DestroyWindowSurface(HandleType p_surface) m_windows.erase(p_surface); } -void FrameBuffer::openColorBuffer(HandleType p_colorbuffer) +int FrameBuffer::openColorBuffer(HandleType p_colorbuffer) { emugl::Mutex::AutoLock mutex(m_lock); ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer)); if (c == m_colorbuffers.end()) { // bad colorbuffer handle - return; + ERR("FB: openColorBuffer cb handle %#x not found\n", p_colorbuffer); + return -1; } (*c).second.refcount++; + return 0; } void FrameBuffer::closeColorBuffer(HandleType p_colorbuffer) @@ -567,6 +569,7 @@ void FrameBuffer::closeColorBuffer(HandleType p_colorbuffer) emugl::Mutex::AutoLock mutex(m_lock); ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer)); if (c == m_colorbuffers.end()) { + ERR("FB: closeColorBuffer cb handle %#x not found\n", p_colorbuffer); // bad colorbuffer handle return; } @@ -581,6 +584,7 @@ bool FrameBuffer::flushWindowSurfaceColorBuffer(HandleType p_surface) WindowSurfaceMap::iterator w( m_windows.find(p_surface) ); if (w == m_windows.end()) { + ERR("FB::flushWindowSurfaceColorBuffer: window handle %#x not found\n", p_surface); // bad surface handle return false; } @@ -596,11 +600,13 @@ bool FrameBuffer::setWindowSurfaceColorBuffer(HandleType p_surface, WindowSurfaceMap::iterator w( m_windows.find(p_surface) ); if (w == m_windows.end()) { // bad surface handle + ERR("%s: bad window surface handle %#x\n", __FUNCTION__, p_surface); return false; } ColorBufferMap::iterator c( m_colorbuffers.find(p_colorbuffer) ); if (c == m_colorbuffers.end()) { + ERR("%s: bad color buffer handle %#x\n", __FUNCTION__, p_colorbuffer); // bad colorbuffer handle return false; } |