From 9605693dec310fa5dc95e096560e5fca1cb5c9c7 Mon Sep 17 00:00:00 2001 From: YongGeol Jung Date: Thu, 6 Sep 2012 11:02:13 +0900 Subject: [PATCH] Call eglMakeCurrent function before glReadPixels. [Title] Call eglMakeCurrent function before glReadPixels. [Issue#] N/A [Problem] glReadPixels function doesn't return proper data if called multiple times in same frame. [Cause] N/A [Solution] Call eglMakeCurrent function before glReadPixels. Change-Id: Ie38aeddde3afa0ca979be22605c0a43088391699 --- Source/WTF/wtf/Platform.h | 1 + .../platform/graphics/efl/GraphicsContext3DOffscreen.cpp | 16 ++++++++++++++-- .../platform/graphics/efl/GraphicsContext3DOffscreen.h | 3 +++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h index 395e9c1..c708df2 100755 --- a/Source/WTF/wtf/Platform.h +++ b/Source/WTF/wtf/Platform.h @@ -793,6 +793,7 @@ #if ENABLE(TIZEN_WEBKIT2) #define ENABLE_TIZEN_MOBILE_WEB_PRINT 1 /* Hyunsoo Shim(hyunsoo.shim@samsung.com) : Mobile Web Print for AC layer */ +#define ENABLE_TIZEN_EMULATOR_CONTEXT_ERROR_WORKAROUND 1 /* YongGeol Jung(yg48.jung@samsung.com) : eglMakeCurrent should be called before glReadPixels(emulator issue).*/ #endif #define ENABLE_TIZEN_CSS_FIXED_ACCELERATION 1 /* Jaehun Lim(ljaehun.lim@samsung.com) : Accelerated CSS FIXED elements */ #if ENABLE(OVERFLOW_SCROLLING) diff --git a/Source/WebCore/platform/graphics/efl/GraphicsContext3DOffscreen.cpp b/Source/WebCore/platform/graphics/efl/GraphicsContext3DOffscreen.cpp index 3e0a631..1fe1e9c 100755 --- a/Source/WebCore/platform/graphics/efl/GraphicsContext3DOffscreen.cpp +++ b/Source/WebCore/platform/graphics/efl/GraphicsContext3DOffscreen.cpp @@ -286,13 +286,20 @@ bool GraphicsContext3DOffscreen::createSurface(Evas_Object* view) } #endif #if ENABLE(TIZEN_WEBKIT2) -bool GraphicsContext3DOffscreen::makeContextCurrent() { - +bool GraphicsContext3DOffscreen::makeContextCurrent() +{ if (eglGetCurrentSurface(EGL_READ) == m_surface && eglGetCurrentContext() == m_context) return true; return eglMakeCurrent(m_display, m_surface, m_surface, m_context); } + +#if ENABLE(TIZEN_EMULATOR_CONTEXT_ERROR_WORKAROUND) +bool GraphicsContext3DOffscreen::forceMakeContextCurrent() +{ + return eglMakeCurrent(m_display, m_surface, m_surface, m_context); +} +#endif #endif bool GraphicsContext3DOffscreen::paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight, int canvasWidth, int canvasHeight, PlatformContextCairo* context) @@ -462,7 +469,12 @@ void GraphicsContext3DOffscreen::readRenderingResults(unsigned char *pixels, int if (pixelsSize < totalBytes) return; +#if ENABLE(TIZEN_WEBKIT2) && ENABLE(TIZEN_EMULATOR_CONTEXT_ERROR_WORKAROUND) + // FIXME: eglMakeCurrent should be called before glReadPixels(emulator issue). + forceMakeContextCurrent(); +#else makeContextCurrent(); +#endif bool mustRestoreFBO = false; if (m_attributes.antialias) diff --git a/Source/WebCore/platform/graphics/efl/GraphicsContext3DOffscreen.h b/Source/WebCore/platform/graphics/efl/GraphicsContext3DOffscreen.h index ef43bf5..5a2cc64 100755 --- a/Source/WebCore/platform/graphics/efl/GraphicsContext3DOffscreen.h +++ b/Source/WebCore/platform/graphics/efl/GraphicsContext3DOffscreen.h @@ -68,6 +68,9 @@ public: #if ENABLE(TIZEN_WEBKIT2) virtual bool makeContextCurrent(); +#if ENABLE(TIZEN_EMULATOR_CONTEXT_ERROR_WORKAROUND) + bool forceMakeContextCurrent(); +#endif #endif virtual void prepareTexture(int width, int height); -- 2.7.4