Use the env value "TIZEN_WEBKIT_DIRECT_RENDERING" to enable EVAS_GL_DIRECT_RENDERING.
authorHyowon Kim <hw1008.kim@samsung.com>
Tue, 16 Apr 2013 09:33:09 +0000 (18:33 +0900)
committerGerrit Code Review <gerrit2@kim11>
Thu, 2 May 2013 08:20:53 +0000 (17:20 +0900)
Default value is On.
Therefore, if you want to disable direct rendering explicitly,
set the env value "TIZEN_WEBKIT_DIRECT_RENDERING" as 0.

[Title] Use the env value "TIZEN_WEBKIT_DIRECT_RENDERING" to enable EVAS_GL_DIRECT_RENDERING.
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] N/A

Change-Id: Ia039c9b7a809010d542ebdbff90f1f3b5dc700e3

Conflicts:

Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp

Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
Source/WebKit2/UIProcess/API/efl/PageClientImpl.h
Source/WebKit2/UIProcess/DrawingAreaProxy.h
Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp
Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h
Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.cpp
Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.h

index 087653c..f29c35a 100755 (executable)
@@ -66,6 +66,7 @@
 namespace WebCore {
 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
 static int gAngle = 0;
+static bool gDirectRendering = false;
 #endif
 
 struct TextureMapperGLData {
@@ -201,13 +202,16 @@ static void scissorClip(const IntRect& rect)
     GLint viewport[4];
     GL_CMD(glGetIntegerv(GL_VIEWPORT, viewport));
 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
-    if (gAngle == 90)
-        GL_CMD(glScissor(viewport[3] - rect.maxX(), viewport[2] - rect.maxY(), rect.width(), rect.height()));
-    else if (gAngle == 180)
-        GL_CMD(glScissor(viewport[2] - rect.maxX(), rect.y(), rect.width(), rect.height()));
-    else if (gAngle == 270)
-        GL_CMD(glScissor(rect.x(), rect.y(), rect.width(), rect.height()));
-    else
+    if (gDirectRendering) {
+        if (gAngle == 90)
+            GL_CMD(glScissor(viewport[3] - rect.maxX(), viewport[2] - rect.maxY(), rect.width(), rect.height()));
+        else if (gAngle == 180)
+            GL_CMD(glScissor(viewport[2] - rect.maxX(), rect.y(), rect.width(), rect.height()));
+        else if (gAngle == 270)
+            GL_CMD(glScissor(rect.x(), rect.y(), rect.width(), rect.height()));
+        else
+            GL_CMD(glScissor(rect.x(), viewport[3] - rect.maxY(), rect.width(), rect.height()));
+    } else
 #endif
     GL_CMD(glScissor(rect.x(), viewport[3] - rect.maxY(), rect.width(), rect.height()));
 }
@@ -253,6 +257,10 @@ TextureMapperGL::TextureMapperGL()
     , m_context(0)
     , m_enableEdgeDistanceAntialiasing(false)
 {
+#if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
+    char* directRenderingEnv = getenv("TIZEN_WEBKIT_DIRECT_RENDERING");
+    gDirectRendering = directRenderingEnv ? atoi(directRenderingEnv) : true;
+#endif
 }
 
 TextureMapperGL::ClipStack& TextureMapperGL::clipStack()
@@ -276,11 +284,13 @@ void TextureMapperGL::beginPainting(PaintFlags flags)
         return;
 
 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
-    data().didModifyStencil = false;
-    GL_CMD(glGetIntegerv(GL_VIEWPORT, data().viewport));
-    m_clipStack.init(IntRect(0, 0, data().viewport[2], data().viewport[3]));
-    GL_CMD(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &data().targetFrameBuffer));
-#else
+    if (gDirectRendering) {
+        data().didModifyStencil = false;
+        GL_CMD(glGetIntegerv(GL_VIEWPORT, data().viewport));
+        m_clipStack.init(IntRect(0, 0, data().viewport[2], data().viewport[3]));
+        GL_CMD(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &data().targetFrameBuffer));
+    } else {
+#endif
     GL_CMD(glGetIntegerv(GL_CURRENT_PROGRAM, &data().previousProgram));
     data().previousScissorState = glIsEnabled(GL_SCISSOR_TEST);
     data().previousDepthState = glIsEnabled(GL_DEPTH_TEST);
@@ -300,6 +310,8 @@ void TextureMapperGL::beginPainting(PaintFlags flags)
     glGetIntegerv(GL_FRAMEBUFFER_BINDING, &data().targetFrameBuffer);
     m_clipStack.init(IntRect(0, 0, data().viewport[2], data().viewport[3]));
     GL_CMD(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &data().targetFrameBuffer));
+#if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
+    }
 #endif
 
     data().PaintFlags = flags;
@@ -313,7 +325,10 @@ void TextureMapperGL::endPainting()
         glClear(GL_STENCIL_BUFFER_BIT);
     }
 
-#if !ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
+#if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
+    if (gDirectRendering)
+        return;
+#endif
     glUseProgram(data().previousProgram);
 
     glScissor(data().previousScissor[0], data().previousScissor[1], data().previousScissor[2], data().previousScissor[3]);
@@ -334,7 +349,6 @@ void TextureMapperGL::endPainting()
     painter->endNativePainting();
     painter->restore();
 #endif
-#endif
 }
 
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
@@ -940,21 +954,24 @@ PassRefPtr<BitmapTexture> BitmapTextureGL::applyFilters(const BitmapTexture& con
 }
 #endif
 
-#if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
-static inline TransformationMatrix createProjectionMatrix(const IntSize& size, bool mirrored, int angle = 0)
-#else
 static inline TransformationMatrix createProjectionMatrix(const IntSize& size, bool mirrored)
-#endif
 {
     const float near = 9999999;
     const float far = -99999;
 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
-    if (angle == 90 || angle == 270)
-        return TransformationMatrix(2.0 / float(size.height()), 0, 0, 0,
-                                    0, (mirrored ? 2.0 : -2.0) / float(size.width()), 0, 0,
-                                    0, 0, -2.f / (far - near), 0,
-                                    -1, mirrored ? -1 : 1, -(far + near) / (far - near), 1);
-    else
+    if (gDirectRendering) {
+        if (gAngle == 90 || gAngle == 270)
+            return TransformationMatrix(2.0 / float(size.height()), 0, 0, 0,
+                                        0, (mirrored ? 2.0 : -2.0) / float(size.width()), 0, 0,
+                                        0, 0, -2.f / (far - near), 0,
+                                        -1, mirrored ? -1 : 1, -(far + near) / (far - near), 1);
+
+        else
+            return TransformationMatrix(2.0 / float(size.width()), 0, 0, 0,
+                                        0, (mirrored ? 2.0 : -2.0) / float(size.height()), 0, 0,
+                                        0, 0, -2.f / (far - near), 0,
+                                        -1, mirrored ? -1 : 1, -(far + near) / (far - near), 1);
+    } else
 #endif
     return TransformationMatrix(2.0 / float(size.width()), 0, 0, 0,
                                 0, (mirrored ? 2.0 : -2.0) / float(size.height()), 0, 0,
@@ -1045,11 +1062,7 @@ void TextureMapperGL::bindDefaultSurface()
     GL_CMD(glBindFramebuffer(GL_FRAMEBUFFER, data().targetFrameBuffer));
     IntSize viewportSize(data().viewport[2], data().viewport[3]);
 
-#if !ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
     data().projectionMatrix = createProjectionMatrix(viewportSize, data().PaintFlags & PaintingMirrored);
-#else
-    data().projectionMatrix = createProjectionMatrix(viewportSize, data().PaintFlags & PaintingMirrored, gAngle);
-#endif
 
 #if !USE(TIZEN_TEXTURE_MAPPER)
     GL_CMD(glViewport(data().viewport[0], data().viewport[1], viewportSize.width(), viewportSize.height()));
@@ -1097,8 +1110,9 @@ bool TextureMapperGL::beginScissorClip(const TransformationMatrix& modelViewMatr
         return false;
 
 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
-    if (gAngle == 90 || gAngle == 270)
-        rect = IntRect(rect.y(), rect.x(), rect.height(), rect.width());
+    if (gDirectRendering)
+        if (gAngle == 90 || gAngle == 270)
+            rect = IntRect(rect.y(), rect.x(), rect.height(), rect.width());
 #endif
 
     clipStack().current().scissorBox.intersect(rect);
index b1c6b2d..7c9b1f5 100755 (executable)
@@ -1468,9 +1468,10 @@ void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize,
 
 void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect)
 {
-#if !ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
-    drawContents();
+#if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
+    if (!isDirectRendering())
 #endif
+    drawContents();
     m_viewImpl->redrawRegion(rect);
 
 #if ENABLE(TIZEN_SCREEN_READER)
@@ -1484,10 +1485,11 @@ void PageClientEvasGL::displayViewport()
 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
     // We should not draw here when Direct Rendering is enabled.
     // Because we will draw directly when evas is updated - on_pixels_for_accelerated_compositing().
-    ewk_view_mark_for_sync(m_viewImpl->view());
-#else
-    setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
+    if (isDirectRendering())
+        ewk_view_mark_for_sync(m_viewImpl->view());
+    else
 #endif
+    setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
 
 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
     updateScrollbar();
@@ -1500,7 +1502,14 @@ void PageClientEvasGL::displayViewport()
 
 void PageClientEvasGL::drawContents()
 {
-    if (evas_gl_make_current(m_evasGL, m_surface, m_context) != EINA_TRUE)
+    if (!drawingArea() || !(drawingArea()->layerTreeCoordinatorProxy()))
+        return;
+
+    WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
+    if (!renderer)
+        return;
+
+    if (!makeContextCurrent())
         return;
 
     WebCore::TransformationMatrix matrix;
@@ -1508,50 +1517,48 @@ void PageClientEvasGL::drawContents()
     IntSize ewkViewSize = viewSize();
 
 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
-    Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
-    m_angle = ecore_evas_rotation_get(ee);
-    if (drawingArea())
-        drawingArea()->setAngle(m_angle);
-    matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle);
-
-    if (m_angle == 90 || m_angle == 270) {
-        glViewport(0, 0, ewkViewSize.height(), ewkViewSize.width());
-        if (m_angle == 90)
-            matrix.translate(-ewkViewSize.width(), 0);
-        else if (m_angle == 270)
-            matrix.translate(0, -ewkViewSize.height());
-        clipRect = IntRect(IntPoint(), ewkViewSize.transposedSize());
-    } else {
+    if (isDirectRendering()) {
+        Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
+        m_angle = ecore_evas_rotation_get(ee);
+        renderer->setAngle(m_angle);
+        matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle);
+
+        if (m_angle == 90 || m_angle == 270) {
+            glViewport(0, 0, ewkViewSize.height(), ewkViewSize.width());
+            if (m_angle == 90)
+                matrix.translate(-ewkViewSize.width(), 0);
+            else if (m_angle == 270)
+                matrix.translate(0, -ewkViewSize.height());
+            clipRect = IntRect(IntPoint(), ewkViewSize.transposedSize());
+        } else {
+            glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
+            if (m_angle == 180)
+                matrix.translate(-ewkViewSize.width(), -ewkViewSize.height());
+            clipRect = IntRect(IntPoint(), ewkViewSize);
+        }
+    } else
+#endif
+    {
         glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
-        if (m_angle == 180)
-            matrix.translate(-ewkViewSize.width(), -ewkViewSize.height());
         clipRect = IntRect(IntPoint(), ewkViewSize);
     }
-#else
-    glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
-    clipRect = IntRect(IntPoint(), ewkViewSize);
-#endif
+
     matrix *= m_viewImpl->transformToView().toTransformationMatrix();
 
-    if (drawingArea()) {
-        if (drawingArea()->layerTreeCoordinatorProxy()) {
-            WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
-            if (m_shouldMakeBackupTexture) {
-                glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
-                glClearColor(1, 1, 1, 1);
-                glClear(GL_COLOR_BUFFER_BIT);
-                renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor);
-                m_shouldMakeBackupTexture = false;
-            } else if (m_shouldShowBackupTexture) {
-                matrix.makeIdentity();
-                glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
-                renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect);
-            } else
-#endif
-            renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor);
-        }
-    }
+    if (m_shouldMakeBackupTexture) {
+        glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
+        glClearColor(1, 1, 1, 1);
+        glClear(GL_COLOR_BUFFER_BIT);
+        renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor);
+        m_shouldMakeBackupTexture = false;
+    } else if (m_shouldShowBackupTexture) {
+        matrix.makeIdentity();
+        glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
+        renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect);
+    } else
+#endif
+    renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor);
 }
 
 void PageClientEvasGL::didRenderFrame()
@@ -1571,8 +1578,11 @@ void PageClientEvasGL::initializeAcceleratedCompositingMode()
 
     m_config = evas_gl_config_new();
 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
-    setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1);
-    m_config->options_bits = EVAS_GL_OPTIONS_DIRECT;
+    char* directRenderingEnv = getenv("TIZEN_WEBKIT_DIRECT_RENDERING");
+    if (!directRenderingEnv || atoi(directRenderingEnv)) {
+        setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1);
+        m_config->options_bits = EVAS_GL_OPTIONS_DIRECT;
+    }
 #endif
     m_config->color_format = EVAS_GL_RGBA_8888;
     m_config->depth_bits = EVAS_GL_DEPTH_BIT_24;
@@ -1665,15 +1675,18 @@ void PageClientEvasGL::setTargetSurface()
     }
 
 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
-    makeContextCurrent();
-#else
-    if (makeContextCurrent()) {
-        glViewport(0, 0, width, height);
-        glClearColor(1.0, 1.0, 1.0, 1.0);
-        glClear(GL_COLOR_BUFFER_BIT);
-        glFinish();
-    }
+    if (isDirectRendering())
+        makeContextCurrent();
+    else
 #endif
+    {
+        if (makeContextCurrent()) {
+            glViewport(0, 0, width, height);
+            glClearColor(1.0, 1.0, 1.0, 1.0);
+            glClear(GL_COLOR_BUFFER_BIT);
+            glFinish();
+        }
+    }
 
     Evas_Native_Surface nativeSurface;
     if (evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface))
index 49ac0a0..3a63d24 100755 (executable)
@@ -492,6 +492,10 @@ private:
 
     void setTargetSurface();
 
+#if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
+    bool isDirectRendering() { return (m_config->options_bits == EVAS_GL_OPTIONS_DIRECT); }
+#endif
+
     Evas_GL* m_evasGL;
     Evas_GL_API* m_evasGlApi;
     Evas_GL_Context* m_context;
index 5e20209..55f9903 100755 (executable)
@@ -109,9 +109,6 @@ public:
 #endif
 
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
-#if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
-    virtual void setAngle(int) { }
-#endif
     virtual void didSuspendPainting() { }
 #endif
 
index ce8814e..5a3091a 100755 (executable)
@@ -393,14 +393,6 @@ void DrawingAreaProxyImpl::setVisibleContentsRectForScrollingContentsLayers(cons
         m_layerTreeCoordinatorProxy->setVisibleContentsRectForScrollingContentsLayers(visibleRect);
 }
 #endif
-
-#if ENABLE(TIZEN_WEBKIT2_TILED_AC) && ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
-void DrawingAreaProxyImpl::setAngle(int angle)
-{
-    if (m_layerTreeCoordinatorProxy)
-        m_layerTreeCoordinatorProxy->setAngle(angle);
-}
-#endif
 #endif // #if USE(UI_SIDE_COMPOSITING)
 
 void DrawingAreaProxyImpl::exitAcceleratedCompositingMode()
index 238f0c5..3321f97 100755 (executable)
@@ -53,9 +53,6 @@ public:
     void paint(BackingStore::PlatformGraphicsContext, const WebCore::IntRect&, WebCore::Region& unpaintedRegion);
 
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
-#if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
-    virtual void setAngle(int);
-#endif
     virtual void didSuspendPainting();
 #endif
 
index d775e25..2eb80c7 100755 (executable)
@@ -239,13 +239,6 @@ void LayerTreeCoordinatorProxy::purgeBackingStores()
 }
 
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
-#if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
-void LayerTreeCoordinatorProxy::setAngle(int angle)
-{
-    m_renderer->setAngle(angle);
-}
-#endif
-
 void LayerTreeCoordinatorProxy::clearBackingStores()
 {
     m_renderer->syncRemoteContent();
index f5d8ca3..a38a789 100755 (executable)
@@ -88,9 +88,6 @@ public:
     void setLayerAnimations(WebLayerID, const WebCore::GraphicsLayerAnimations&);
     void setAnimationsLocked(bool);
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
-#if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
-    void setAngle(int);
-#endif
     void clearBackingStores();
 #endif