From 18e32a8c5cf3850a20b9eec0053be1b09b8c23ab Mon Sep 17 00:00:00 2001 From: Kalyan Kondapally Date: Tue, 16 Apr 2013 14:05:33 +0300 Subject: [PATCH] Implement EGL Lock Surface extension runtime check 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 Signed-off-by: Mikko Ylinen --- Source/WTF/wtf/Platform.h | 5 +-- .../graphics/efl/SharedPlatformSurfaceEfl.cpp | 34 +++++++++++++++ .../graphics/efl/SharedPlatformSurfaceEfl.h | 1 + .../UIProcess/LayerTreeCoordinatorProxy.cpp | 51 +++++++++++++++++++--- Source/WebKit2/UIProcess/WebLayerTreeRenderer.h | 17 +++++--- .../LayerTreeCoordinator/WebGraphicsLayer.cpp | 7 ++- 6 files changed, 96 insertions(+), 19 deletions(-) diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h index 8f1fd6d..97f59d9 100755 --- a/Source/WTF/wtf/Platform.h +++ b/Source/WTF/wtf/Platform.h @@ -707,10 +707,7 @@ #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 diff --git a/Source/WebCore/platform/graphics/efl/SharedPlatformSurfaceEfl.cpp b/Source/WebCore/platform/graphics/efl/SharedPlatformSurfaceEfl.cpp index b1f4bfe..ea17e6c 100644 --- a/Source/WebCore/platform/graphics/efl/SharedPlatformSurfaceEfl.cpp +++ b/Source/WebCore/platform/graphics/efl/SharedPlatformSurfaceEfl.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -345,6 +346,39 @@ PassOwnPtr SharedPlatformSurfaceEfl::create(const IntS return pixmap.release(); } +// FIXME: This function needs a better place +bool SharedPlatformSurfaceEfl::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(nativeDisplay)); + eglInitialize(display, 0, 0); + } + + if (display != EGL_NO_DISPLAY) { + String rawExtensions = reinterpret_cast(eglQueryString(display, EGL_EXTENSIONS)); + Vector extNames; + rawExtensions.lower().split(" ", extNames); + + if (extNames.contains("egl_khr_lock_surface")) + supportLockSurfaceExt = true; + + extNames.clear(); + } + + return supportLockSurfaceExt; +} + SharedPlatformSurfaceEfl::SharedPlatformSurfaceEfl(const IntSize& size, bool lockable, bool hasAlpha, bool hasDepth, bool hasStencil) : m_size(size) , m_pixmap(0) diff --git a/Source/WebCore/platform/graphics/efl/SharedPlatformSurfaceEfl.h b/Source/WebCore/platform/graphics/efl/SharedPlatformSurfaceEfl.h index ce558cd..f9dc4ec 100644 --- a/Source/WebCore/platform/graphics/efl/SharedPlatformSurfaceEfl.h +++ b/Source/WebCore/platform/graphics/efl/SharedPlatformSurfaceEfl.h @@ -39,6 +39,7 @@ class PixmapContextEfl; class SharedPlatformSurfaceEfl { public: static PassOwnPtr create(const IntSize&, bool lockable, bool hasAlpha = true, bool hasDepth = true, bool hasStencil = false); + static bool supportsLockSurfaceExtension(); virtual ~SharedPlatformSurfaceEfl(); bool makeContextCurrent(); diff --git a/Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.cpp b/Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.cpp index db25c4f..3644f5d 100755 --- a/Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.cpp +++ b/Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.cpp @@ -30,11 +30,46 @@ #include "WebPageProxy.h" #include "WebProcessProxy.h" +#include +#include 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(nativeDisplay)); + eglInitialize(display, 0, 0); + } + + if (display != EGL_NO_DISPLAY) { + String rawExtensions = reinterpret_cast(eglQueryString(display, EGL_EXTENSIONS)); + Vector 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) @@ -53,7 +88,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)); @@ -109,16 +144,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 } diff --git a/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h b/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h index 996c54e..2c11c97 100755 --- a/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h +++ b/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h @@ -73,19 +73,22 @@ public: int platformSurfaceID; WebCore::IntSize platformSurfaceSize; TileUpdate(const WebCore::IntRect& source, const WebCore::IntRect& target, PassRefPtr newSurface, const WebCore::IntPoint& newOffset, int pmID, WebCore::IntSize pmSize) -#else - TileUpdate(const WebCore::IntRect& source, const WebCore::IntRect& target, PassRefPtr 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 newSurface, const WebCore::IntPoint& newOffset) + : sourceRect(source) + , targetRect(target) + , surface(newSurface) + , offset(newOffset) + { + } }; WebLayerTreeRenderer(LayerTreeCoordinatorProxy*); virtual ~WebLayerTreeRenderer(); @@ -123,7 +126,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(); @@ -137,6 +139,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; } @@ -283,6 +286,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(); diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/WebGraphicsLayer.cpp b/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/WebGraphicsLayer.cpp index d453081..70f69a3 100755 --- a/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/WebGraphicsLayer.cpp +++ b/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/WebGraphicsLayer.cpp @@ -32,6 +32,7 @@ #include "Page.h" #include "TextureMapperPlatformLayer.h" #include "TiledBackingStoreRemoteTile.h" +#include "SharedPlatformSurfaceEfl.h" #include "WebPage.h" #include #include @@ -941,6 +942,7 @@ void WebGraphicsLayer::adjustContentsScale() void WebGraphicsLayer::createBackingStore() { + if (SharedPlatformSurfaceEfl::supportsLockSurfaceExtension()) { #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE) #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION) if (m_webGraphicsLayerClient->isGLAccelerationMode()) @@ -950,9 +952,10 @@ void WebGraphicsLayer::createBackingStore() #else m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemotePlatformSurfaceTileBackend::create(this))); #endif -#else - m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this))); #endif + } else + m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this))); + m_mainBackingStore->setSupportsAlpha(!contentsOpaque()); m_mainBackingStore->setContentsScale(effectiveContentsScale()); } -- 2.7.4