Call eglMakeCurrent function before glReadPixels.
authorYongGeol Jung <yg48.jung@samsung.com>
Thu, 6 Sep 2012 02:02:13 +0000 (11:02 +0900)
committerYongGeol Jung <yg48.jung@samsung.com>
Fri, 7 Sep 2012 06:56:04 +0000 (15:56 +0900)
[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
Source/WebCore/platform/graphics/efl/GraphicsContext3DOffscreen.cpp
Source/WebCore/platform/graphics/efl/GraphicsContext3DOffscreen.h

index 395e9c1..c708df2 100755 (executable)
 
 #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)
index 3e0a631..1fe1e9c 100755 (executable)
@@ -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)
index ef43bf5..5a2cc64 100755 (executable)
@@ -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);