[Title] Implement EGL Lock Surface extension runtime check.
authorKondapally Kalyan <kalyan.kondapally@intel.com>
Fri, 10 May 2013 11:38:15 +0000 (14:38 +0300)
committerGerrit Code Review <gerrit2@kim11>
Thu, 16 May 2013 12:13:51 +0000 (21:13 +0900)
[Issue#] TIVI-641
[Problem] GenX drivers dont support Lock Surface.
[Solution] GenX drivers does not support EGL Lock Surface extension which causes webpage rendering
           to fail if ENABLE_TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE is enabled.
           ENABLE_TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE is still needed for
           HW accelerated video and WebGL. With this patch,
           ENABLE_TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE can be enabled and
           web pages still render correctly.

Source/WebCore/platform/graphics/efl/tizen/SharedPlatformSurfaceTizen.cpp
Source/WebCore/platform/graphics/efl/tizen/SharedPlatformSurfaceTizen.h
Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.cpp
Source/WebKit2/UIProcess/WebLayerTreeRenderer.h
Source/WebKit2/UIProcess/tizen/WebLayerTreeRendererTizen.h
Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/WebGraphicsLayer.cpp

index 84b5a22..12ce9ea 100755 (executable)
@@ -364,6 +364,38 @@ SharedPlatformSurfaceTizen::SharedPlatformSurfaceTizen(const IntSize& size, bool
     m_pixmapContext = pixmapContext;
 }
 
+bool SharedPlatformSurfaceTizen::supportsLockSurfaceExtension()
+{
+    static bool extSupportQueried = false;
+    static bool supportLockSurfaceExt = false;
+
+    if (extSupportQueried)
+        return supportLockSurfaceExt;
+
+    extSupportQueried = true;
+    Display* nativeDisplay = 0;
+    EGLDisplay display = eglGetCurrentDisplay();
+
+    if (display == EGL_NO_DISPLAY) {
+        nativeDisplay = XOpenDisplay(0);
+        display = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(nativeDisplay));
+        eglInitialize(display, 0, 0);
+    }
+
+    if (display != EGL_NO_DISPLAY) {
+        String rawExtensions = reinterpret_cast<const char*>(eglQueryString(display, EGL_EXTENSIONS));
+        Vector<String> extNames;
+        rawExtensions.lower().split(" ", extNames);
+
+        if (extNames.contains("egl_khr_lock_surface"))
+            supportLockSurfaceExt = true;
+
+        extNames.clear();
+    }
+
+    return supportLockSurfaceExt;
+}
+
 SharedPlatformSurfaceTizen::~SharedPlatformSurfaceTizen()
 {
     if (m_surface != EGL_NO_SURFACE) {
index b29966c..af558db 100755 (executable)
@@ -39,6 +39,7 @@ class PixmapContextTizen;
 class SharedPlatformSurfaceTizen {
 public:
     static PassOwnPtr<SharedPlatformSurfaceTizen> create(const IntSize&, bool lockable, bool hasAlpha = true, bool hasDepth = true, bool hasStencil = false, PixmapContextTizen* pixmapContext = NULL);
+    static bool supportsLockSurfaceExtension();
     virtual ~SharedPlatformSurfaceTizen();
     bool makeContextCurrent();
 
index 2eb80c7..1ff9307 100755 (executable)
 #include "WebLayerTreeRendererTizen.h"
 #endif
 
+#include <EGL/egl.h>
+#include <X11/Xlib.h>
+
 namespace WebKit {
 
 using namespace WebCore;
 
+// FIXME: This function needs a better place
+static bool supportsLockSurfaceExtension()
+{
+    static bool extSupportQueried = false;
+    static bool supportLockSurfaceExt = false;
+
+    if (extSupportQueried)
+        return supportLockSurfaceExt;
+
+    extSupportQueried = true;
+    Display* nativeDisplay = 0;
+    EGLDisplay display = eglGetCurrentDisplay();
+
+    if (display == EGL_NO_DISPLAY) {
+        nativeDisplay = XOpenDisplay(0);
+        display = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(nativeDisplay));
+        eglInitialize(display, 0, 0);
+    }
+
+    if (display != EGL_NO_DISPLAY) {
+        String rawExtensions = reinterpret_cast<const char*>(eglQueryString(display, EGL_EXTENSIONS));
+        Vector<String> extNames;
+        rawExtensions.lower().split(" ", extNames);
+
+        if (extNames.contains("egl_khr_lock_surface"))
+            supportLockSurfaceExt = true;
+
+        extNames.clear();
+    }
+
+    return supportLockSurfaceExt;
+}
+
 LayerTreeCoordinatorProxy::LayerTreeCoordinatorProxy(DrawingAreaProxy* drawingAreaProxy)
     : m_drawingAreaProxy(drawingAreaProxy)
 #if !ENABLE(TIZEN_WEBKIT2_TILED_AC)
@@ -55,7 +91,7 @@ LayerTreeCoordinatorProxy::LayerTreeCoordinatorProxy(DrawingAreaProxy* drawingAr
     : m_drawingAreaProxy(drawingAreaProxy)
 {
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
-    WebLayerTreeRenderer* renderer = isGLMode ? new WebLayerTreeRendererTizen(this, drawingAreaProxy) : new WebLayerTreeRenderer(this, drawingAreaProxy, isGLMode);
+    WebLayerTreeRenderer* renderer = (isGLMode && supportsLockSurfaceExtension()) ? new WebLayerTreeRendererTizen(this, drawingAreaProxy) : new WebLayerTreeRenderer(this, drawingAreaProxy, isGLMode);
     m_renderer = adoptRef(renderer);
 #else
     m_renderer = adoptRef(new WebLayerTreeRenderer(this, drawingAreaProxy, isGLMode));
@@ -111,16 +147,18 @@ void LayerTreeCoordinatorProxy::updateTileForLayer(int layerID, int tileID, cons
 
 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
-    dispatchUpdate(bind(&WebLayerTreeRenderer::updateTileWithUpdateInfo, m_renderer.get(), layerID, tileID, WebLayerTreeRenderer::TileUpdate(updateInfo.updateRect, targetRect, surface, updateInfo.surfaceOffset, updateInfo.platformSurfaceID, updateInfo.platformSurfaceSize)));
-#else
-    dispatchUpdate(bind(&WebLayerTreeRenderer::updateTileWithUpdateInfo, m_renderer.get(), layerID, tileID, WebLayerTreeRenderer::TileUpdate(updateInfo.updateRect, targetRect, surface, updateInfo.surfaceOffset)));
+    if (m_renderer->isUsingPlatformSurface())
+        dispatchUpdate(bind(&WebLayerTreeRenderer::updateTileWithUpdateInfo, m_renderer.get(), layerID, tileID, WebLayerTreeRenderer::TileUpdate(updateInfo.updateRect, targetRect, surface, updateInfo.surfaceOffset, updateInfo.platformSurfaceID, updateInfo.platformSurfaceSize)));
+    else
 #endif
+        dispatchUpdate(bind(&WebLayerTreeRenderer::updateTileWithUpdateInfo, m_renderer.get(), layerID, tileID, WebLayerTreeRenderer::TileUpdate(updateInfo.updateRect, targetRect, surface, updateInfo.surfaceOffset)));
 #else
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
-    dispatchUpdate(bind(&WebLayerTreeRenderer::updatePlatformSurfaceTile, m_renderer.get(), layerID, tileID, updateInfo.updateRect, updateInfo.platformSurfaceID, updateInfo.platformSurfaceSize));
-#else
-    dispatchUpdate(bind(&WebLayerTreeRenderer::updateTile, m_renderer.get(), layerID, tileID, WebLayerTreeRenderer::TileUpdate(updateInfo.updateRect, targetRect, surface, updateInfo.surfaceOffset)));
+    if (m_renderer->isUsingPlatformSurface())
+        dispatchUpdate(bind(&WebLayerTreeRenderer::updatePlatformSurfaceTile, m_renderer.get(), layerID, tileID, updateInfo.updateRect, updateInfo.platformSurfaceID, updateInfo.platformSurfaceSize));
+    else
 #endif
+        dispatchUpdate(bind(&WebLayerTreeRenderer::updateTile, m_renderer.get(), layerID, tileID, WebLayerTreeRenderer::TileUpdate(updateInfo.updateRect, targetRect, surface, updateInfo.surfaceOffset)));
 #endif
 }
 
index f3c73b2..7e0bb46 100755 (executable)
@@ -66,20 +66,25 @@ public:
         int platformSurfaceID;
         WebCore::IntSize platformSurfaceSize;
         TileUpdate(const WebCore::IntRect& source, const WebCore::IntRect& target, PassRefPtr<ShareableSurface> newSurface, const WebCore::IntPoint& newOffset, int pmID, WebCore::IntSize pmSize)
-#else
-        TileUpdate(const WebCore::IntRect& source, const WebCore::IntRect& target, PassRefPtr<ShareableSurface> newSurface, const WebCore::IntPoint& newOffset)
-#endif
             : sourceRect(source)
             , targetRect(target)
             , surface(newSurface)
             , offset(newOffset)
-#if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
             , platformSurfaceID(pmID)
             , platformSurfaceSize(pmSize)
+        {
+        }
+
 #endif
+        TileUpdate(const WebCore::IntRect& source, const WebCore::IntRect& target, PassRefPtr<ShareableSurface> newSurface, const WebCore::IntPoint& newOffset)
+            : sourceRect(source)
+            , targetRect(target)
+            , surface(newSurface)
+            , offset(newOffset)
         {
         }
     };
+
     WebLayerTreeRenderer(LayerTreeCoordinatorProxy*);
     virtual ~WebLayerTreeRenderer();
 
@@ -116,7 +121,6 @@ public:
     void updateTile(WebLayerID, int, const TileUpdate&);
 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
     virtual void updateTileWithUpdateInfo(WebLayerID, int, const TileUpdate&);
-    virtual bool isUsingPlatformSurface() { return false; }
 #endif
     TIZEN_VIRTUAL void flushLayerChanges();
 
@@ -132,7 +136,7 @@ public:
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
     virtual void freePlatformSurface() { }
     virtual bool hasPlatformSurfaceToFree() { return false; }
-
+    virtual bool isUsingPlatformSurface() { return false; }
     virtual void updatePlatformSurfaceTile(WebLayerID, int tileID, const WebCore::IntRect& sourceRect, int platformSurfaceID, const WebCore::IntSize& pixplatformSurfaceSizemapSize) { }
 #endif
 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
index 45c63ab..fe49268 100644 (file)
@@ -54,6 +54,8 @@ public:
     virtual void removeTile(WebLayerID, int);
 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
     virtual void updateTileWithUpdateInfo(WebLayerID, int, const TileUpdate&);
+#endif
+#if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
     virtual bool isUsingPlatformSurface() { return true; }
 #endif
     virtual void flushLayerChanges();
index 33669b3..c6b6249 100755 (executable)
@@ -32,6 +32,7 @@
 #include "Page.h"
 #include "TextureMapperPlatformLayer.h"
 #include "TiledBackingStoreRemoteTile.h"
+#include "SharedPlatformSurfaceTizen.h"
 #include "WebPage.h"
 #include <wtf/CurrentTime.h>
 #include <wtf/HashMap.h>
@@ -731,7 +732,7 @@ void WebGraphicsLayer::createBackingStore()
 {
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
-    if (!m_webGraphicsLayerClient->isGLAccelerationMode())
+    if (!m_webGraphicsLayerClient->isGLAccelerationMode() || !SharedPlatformSurfaceTizen::supportsLockSurfaceExtension())
         m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)));
     else
 #endif