From 9ca0017d2a6651ce9b795082b249f66e476aaf44 Mon Sep 17 00:00:00 2001 From: Stuart Scott Date: Fri, 23 Aug 2013 10:54:47 -0700 Subject: Catch NULL context and bubbling error up. bug: 10456411 Fix for internal bug Change-Id: I85181d358f1844b25cc85fbaf5f64842d5ed6f22 --- .../host/libs/libOpenglRender/FrameBuffer.cpp | 4 +--- .../host/libs/libOpenglRender/RenderControl.cpp | 4 +++- .../host/libs/libOpenglRender/WindowSurface.cpp | 23 ++++++++++++++-------- .../host/libs/libOpenglRender/WindowSurface.h | 4 ++-- 4 files changed, 21 insertions(+), 14 deletions(-) (limited to 'emulator') diff --git a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp index 2c9e8c5..8609e09 100644 --- a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp +++ b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp @@ -578,9 +578,7 @@ bool FrameBuffer::flushWindowSurfaceColorBuffer(HandleType p_surface) return false; } - (*w).second->flushColorBuffer(); - - return true; + return (*w).second->flushColorBuffer(); } bool FrameBuffer::setWindowSurfaceColorBuffer(HandleType p_surface, diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp b/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp index 960dec7..6a15138 100644 --- a/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp +++ b/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp @@ -239,7 +239,9 @@ static int rcFlushWindowColorBuffer(uint32_t windowSurface) if (!fb) { return -1; } - fb->flushWindowSurfaceColorBuffer(windowSurface); + if (!fb->flushWindowSurfaceColorBuffer(windowSurface)) { + return -1; + } return 0; } diff --git a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp b/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp index 3674120..9c32ff8 100644 --- a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp +++ b/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp @@ -81,11 +81,12 @@ WindowSurface *WindowSurface::create(int p_config, int p_width, int p_height) // previous attached color buffer is updated, if copy or blit should be done // in order to update it - it is being done here. // -void WindowSurface::flushColorBuffer() +bool WindowSurface::flushColorBuffer() { if (m_attachedColorBuffer.Ptr() != NULL) { - blitToColorBuffer(); + return blitToColorBuffer(); } + return true; } // @@ -140,14 +141,15 @@ void WindowSurface::bind(RenderContextPtr p_ctx, SurfaceBindType p_bindType) } -void WindowSurface::blitToColorBuffer() +bool WindowSurface::blitToColorBuffer() { - if (!m_width && !m_height) return; + if (!m_width && !m_height) return false; if (m_attachedColorBuffer->getWidth() != m_width || m_attachedColorBuffer->getHeight() != m_height) { // XXX: should never happen - how this needs to be handled? - return; + fprintf(stderr, "Dimensions do not match\n"); + return false; } // @@ -157,9 +159,14 @@ void WindowSurface::blitToColorBuffer() EGLSurface prevReadSurf = s_egl.eglGetCurrentSurface(EGL_READ); EGLSurface prevDrawSurf = s_egl.eglGetCurrentSurface(EGL_DRAW); FrameBuffer *fb = FrameBuffer::getFB(); + if (!m_drawContext.Ptr()) { + fprintf(stderr, "Draw context is NULL\n"); + return false; + } if (!s_egl.eglMakeCurrent(fb->getDisplay(), m_eglSurface, m_eglSurface, m_drawContext->getEGLContext())) { - return; + fprintf(stderr, "Error making draw context current\n"); + return false; } m_attachedColorBuffer->blitFromCurrentReadBuffer(); @@ -167,12 +174,12 @@ void WindowSurface::blitToColorBuffer() // restore current context/surface s_egl.eglMakeCurrent(fb->getDisplay(), prevDrawSurf, prevReadSurf, prevContext); - + return true; } bool WindowSurface::resizePbuffer(unsigned int p_width, unsigned int p_height) { - if (m_eglSurface && + if (m_eglSurface && m_pbufWidth == p_width && m_pbufHeight == p_height) { // no need to resize diff --git a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h b/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h index 1b655c9..e9f1f7d 100644 --- a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h +++ b/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h @@ -38,13 +38,13 @@ public: EGLSurface getEGLSurface() const { return m_eglSurface; } void setColorBuffer(ColorBufferPtr p_colorBuffer); - void flushColorBuffer(); + bool flushColorBuffer(); void bind(RenderContextPtr p_ctx, SurfaceBindType p_bindType); private: WindowSurface(); - void blitToColorBuffer(); // copy pbuffer content with texload and blit + bool blitToColorBuffer(); // copy pbuffer content with texload and blit bool resizePbuffer(unsigned int p_width, unsigned int p_height); private: -- cgit v1.1