Implement EGL Lock Surface extension runtime check 75/3575/1
authorKalyan Kondapally <kalyan.kondapally@intel.com>
Sat, 18 May 2013 22:12:54 +0000 (15:12 -0700)
committerRusty Lynch <rusty.lynch@intel.com>
Sun, 19 May 2013 01:22:49 +0000 (18:22 -0700)
mesa 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.

Change-Id: I7e0db439896f35ad50f4d3443a229b285f11a737
Signed-off-by: Kalyan Kondapally <kalyan.kondapally@intel.com>
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
Source/WTF/wtf/Platform.h [changed mode: 0755->0644]
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/WebProcess/WebPage/LayerTreeCoordinator/WebGraphicsLayer.cpp

old mode 100755 (executable)
new mode 100644 (file)
index 3d7e798..485853f
@@ -703,10 +703,7 @@ com) : Patch to do not adjust cover rect as fixed pixel size*/
 #define WTF_USE_TIZEN_TEXTURE_MAPPER 1
 #endif
 
-#if ENABLE(TIZEN_WEBKIT2) && ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
-#define ENABLE_TIZEN_ACCELERATED_2D_CANVAS_EFL 1 /* Kyungjin Kim(gen.kim@samsung.com), Hyunki Baik(hyunki.baik@samsung.com) : Accelerated 2D Canvas */
-#endif
-#if ENABLE(TIZEN_ACCELERATED_2D_CANVAS_EFL)
+#if ENABLE(TIZEN_WEBKIT2) && ENABLE(ENABLE_TIZEN_ACCELERATED_2D_CANVAS_EFL)
 #if CPU(ARM)
 #define ENABLE_TIZEN_CANVAS_CAIRO_GLES_RENDERING 1 /* Kyungjin Kim(gen.kim@samsung.com), Hyunki Baik(hyunki.baik@samsung.com) : canvas cairo/GLES rendering */
 #else
index bbd1381..139ff7b 100755 (executable)
@@ -38,6 +38,7 @@
 #include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
 #include <wtf/StdLibExtras.h>
+#include <wtf/text/WTFString.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 
@@ -351,6 +352,39 @@ PassOwnPtr<SharedPlatformSurfaceTizen> SharedPlatformSurfaceTizen::create(const
     return pixmap.release();
 }
 
+// FIXME: This function needs a better place
+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(const IntSize& size, bool lockable, bool hasAlpha, bool hasDepth, bool hasStencil, PixmapContextTizen* pixmapContext)
     : m_pixmap(0)
     , m_size(size)
index b29966c..d95256c 100755 (executable)
@@ -40,6 +40,7 @@ class SharedPlatformSurfaceTizen {
 public:
     static PassOwnPtr<SharedPlatformSurfaceTizen> create(const IntSize&, bool lockable, bool hasAlpha = true, bool hasDepth = true, bool hasStencil = false, PixmapContextTizen* pixmapContext = NULL);
     virtual ~SharedPlatformSurfaceTizen();
+    static bool supportsLockSurfaceExtension();
     bool makeContextCurrent();
 
     bool lockSurface();
index 2eb80c7..4f7e705 100755 (executable)
 #include "WebLayerTreeRendererTizen.h"
 #endif
 
+#include <EGL/egl.h>
+#ifdef HAVE_ECORE_X
+#include <X11/Xlib.h>
+#endif
+
 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;
+
+#ifdef HAVE_ECORE_X
+    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();
+    }
+#endif // HAVE_ECORE_X
+
+    return supportLockSurfaceExt;
+}
+
 LayerTreeCoordinatorProxy::LayerTreeCoordinatorProxy(DrawingAreaProxy* drawingAreaProxy)
     : m_drawingAreaProxy(drawingAreaProxy)
 #if !ENABLE(TIZEN_WEBKIT2_TILED_AC)
@@ -55,7 +95,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));
@@ -88,7 +128,7 @@ void LayerTreeCoordinatorProxy::createTileForLayer(int layerID, int tileID, cons
 void LayerTreeCoordinatorProxy::updateTileForLayer(int layerID, int tileID, const IntRect& targetRect, const WebKit::SurfaceUpdateInfo& updateInfo)
 {
     RefPtr<ShareableSurface> surface;
-#if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
+#if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION) && ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
     if (!m_renderer->isUsingPlatformSurface()) {
 #endif
 #if USE(GRAPHICS_SURFACE)
@@ -105,22 +145,24 @@ void LayerTreeCoordinatorProxy::updateTileForLayer(int layerID, int tileID, cons
 #else
     surface = ShareableSurface::create(updateInfo.surfaceHandle);
 #endif
-#if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
+#if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION) && ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
     }
 #endif
 
 #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..365b371 100755 (executable)
@@ -66,19 +66,22 @@ 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
         {
         }
+#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,10 +119,8 @@ 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();
-
     void createImage(int64_t, PassRefPtr<ShareableBitmap>);
     void destroyImage(int64_t);
     void setLayerAnimations(WebLayerID, const WebCore::GraphicsLayerAnimations&);
@@ -130,6 +131,7 @@ public:
     TIZEN_VIRTUAL void clearBackingStores();
 
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
+    virtual bool isUsingPlatformSurface() { return false; }
     virtual void freePlatformSurface() { }
     virtual bool hasPlatformSurfaceToFree() { return false; }
 
index 33669b3..f5d1791 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>
@@ -729,16 +730,22 @@ void WebGraphicsLayer::adjustContentsScale()
 
 void WebGraphicsLayer::createBackingStore()
 {
+
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
+    if (SharedPlatformSurfaceTizen::supportsLockSurfaceExtension()) {
 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
-    if (!m_webGraphicsLayerClient->isGLAccelerationMode())
+        if (!m_webGraphicsLayerClient->isGLAccelerationMode())
+            m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)));
+        else
+#endif // TIZEN_RUNTIME_BACKEND_SELECTION
+            m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackendTizen::create(this)));
+    } else {
         m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)));
-    else
-#endif
-    m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackendTizen::create(this)));
+    }
 #else
     m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)));
 #endif
+
     m_mainBackingStore->setSupportsAlpha(!contentsOpaque());
     m_mainBackingStore->setContentsScale(effectiveContentsScale());
 }