From: Kalyan Kondapally Date: Sat, 18 May 2013 22:12:54 +0000 (-0700) Subject: Implement EGL Lock Surface extension runtime check X-Git-Tag: accepted/tizen/20130521.102327~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c5374086e6b7c47b9b685c0d53bf0ac92b662545;p=platform%2Fframework%2Fweb%2Fwebkit-efl.git 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 --- diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h old mode 100755 new mode 100644 index 3d7e798..485853f --- a/Source/WTF/wtf/Platform.h +++ b/Source/WTF/wtf/Platform.h @@ -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 diff --git a/Source/WebCore/platform/graphics/efl/tizen/SharedPlatformSurfaceTizen.cpp b/Source/WebCore/platform/graphics/efl/tizen/SharedPlatformSurfaceTizen.cpp index bbd1381..139ff7b7 100755 --- a/Source/WebCore/platform/graphics/efl/tizen/SharedPlatformSurfaceTizen.cpp +++ b/Source/WebCore/platform/graphics/efl/tizen/SharedPlatformSurfaceTizen.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -351,6 +352,39 @@ PassOwnPtr 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(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; +} + SharedPlatformSurfaceTizen::SharedPlatformSurfaceTizen(const IntSize& size, bool lockable, bool hasAlpha, bool hasDepth, bool hasStencil, PixmapContextTizen* pixmapContext) : m_pixmap(0) , m_size(size) diff --git a/Source/WebCore/platform/graphics/efl/tizen/SharedPlatformSurfaceTizen.h b/Source/WebCore/platform/graphics/efl/tizen/SharedPlatformSurfaceTizen.h index b29966c..d95256c 100755 --- a/Source/WebCore/platform/graphics/efl/tizen/SharedPlatformSurfaceTizen.h +++ b/Source/WebCore/platform/graphics/efl/tizen/SharedPlatformSurfaceTizen.h @@ -40,6 +40,7 @@ class SharedPlatformSurfaceTizen { public: static PassOwnPtr 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(); diff --git a/Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.cpp b/Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.cpp index 2eb80c7..4f7e705 100755 --- a/Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.cpp +++ b/Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.cpp @@ -33,10 +33,50 @@ #include "WebLayerTreeRendererTizen.h" #endif +#include +#ifdef HAVE_ECORE_X +#include +#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(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(); + } +#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 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 } diff --git a/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h b/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h index f3c73b2..365b371 100755 --- a/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h +++ b/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h @@ -66,19 +66,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(); @@ -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); 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; } diff --git a/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/WebGraphicsLayer.cpp b/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/WebGraphicsLayer.cpp index 33669b3..f5d1791 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 "SharedPlatformSurfaceTizen.h" #include "WebPage.h" #include #include @@ -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()); }