From 421738c622cf20e411c28120fe30e01e134ef75d Mon Sep 17 00:00:00 2001 From: Kondapally Kalyan Date: Tue, 6 Aug 2013 08:21:07 +0300 Subject: [PATCH] This patch adds support for LockSurface. Changes in SharedPlatformSurfaceTizen are based on initial patch provided by Joone Hur. Change-Id: Ib572872447056b1777135ff6b65d458b2fcaab26 --- .../efl/tizen/SharedPlatformSurfaceTizen.cpp | 30 +++++++++++++++++++--- .../graphics/surfaces/egl/EGLWaylandSurface.cpp | 8 +++++- .../graphics/surfaces/egl/EGLWaylandSurface.h | 1 + .../graphics/surfaces/wayland/WaylandDisplay.cpp | 21 +++++++++++++++ .../graphics/surfaces/wayland/WaylandDisplay.h | 4 +++ .../graphics/surfaces/wayland/WaylandSurface.cpp | 13 ++++++++-- .../texmap/tizen/LayerBackingStoreTizen.cpp | 4 +++ 7 files changed, 75 insertions(+), 6 deletions(-) diff --git a/Source/WebCore/platform/graphics/efl/tizen/SharedPlatformSurfaceTizen.cpp b/Source/WebCore/platform/graphics/efl/tizen/SharedPlatformSurfaceTizen.cpp index 9a7ff9c..35c42dd 100755 --- a/Source/WebCore/platform/graphics/efl/tizen/SharedPlatformSurfaceTizen.cpp +++ b/Source/WebCore/platform/graphics/efl/tizen/SharedPlatformSurfaceTizen.cpp @@ -34,6 +34,7 @@ #include namespace WebCore { +static bool needsLockSurfaceWorkAround = false; class PixmapContextPool { protected: @@ -89,7 +90,16 @@ PassOwnPtr SharedPlatformSurfaceTizen::create(const bool SharedPlatformSurfaceTizen::supportsLockSurfaceExtension() { - static bool supportLockSurfaceExt = GLPlatformContext::supportsEGLExtension(EGLHelper::currentDisplay(), "EGL_KHR_lock_surface"); + static bool initialized = false; + static bool supportLockSurfaceExt = false; + if (initialized) + return supportLockSurfaceExt; + + initialized = true; +#if PLATFORM(WAYLAND) + needsLockSurfaceWorkAround = EGLHelper::isVendor("mesa"); +#endif + supportLockSurfaceExt = GLPlatformContext::supportsEGLExtension(EGLHelper::currentDisplay(), "EGL_KHR_lock_surface"); return supportLockSurfaceExt; } @@ -146,6 +156,9 @@ bool SharedPlatformSurfaceTizen::initialize(GLPlatformSurface::SurfaceAttributes return false; } + if (needsLockSurfaceWorkAround) + makeContextCurrent(); + return true; } @@ -165,13 +178,24 @@ bool SharedPlatformSurfaceTizen::lockSurface() static bool needsMakeCurrent = !(EGLHelper::isVendor("imagination") || EGLHelper::isVendor("mesa") || EGLHelper::isVendor("arm")); if (needsMakeCurrent) makeContextCurrent(); - +#if PLATFORM(WAYLAND) + else if (needsLockSurfaceWorkAround) + m_offScreenContext->releaseCurrent(); +#endif return m_offScreenSurface->lockSurface(); } bool SharedPlatformSurfaceTizen::unlockSurface() { - return m_offScreenSurface->unlockSurface(); + bool value = m_offScreenSurface->unlockSurface(); +#if PLATFORM(WAYLAND) + if (needsLockSurfaceWorkAround) + makeContextCurrent(); + + if (m_offScreenSurface->attributes() & GLPlatformSurface::DoubleBuffered) + m_offScreenSurface->swapBuffers(); +#endif + return value; } bool SharedPlatformSurfaceTizen::querySurface(int** value) diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLWaylandSurface.cpp b/Source/WebCore/platform/graphics/surfaces/egl/EGLWaylandSurface.cpp index e98f800..d749e72 100644 --- a/Source/WebCore/platform/graphics/surfaces/egl/EGLWaylandSurface.cpp +++ b/Source/WebCore/platform/graphics/surfaces/egl/EGLWaylandSurface.cpp @@ -39,6 +39,7 @@ namespace WebCore { EGLWindowSurface::EGLWindowSurface(const IntSize& size, GLPlatformSurface::SurfaceAttributes attributes) : EGLOffScreenSurface(attributes) , m_nativeWindow(0) + , m_bufferAttached(false) { if (!m_configSelector) return; @@ -74,7 +75,6 @@ EGLWindowSurface::EGLWindowSurface(const IntSize& size, GLPlatformSurface::Surfa } m_bufferHandle = m_surface->handle(); - WaylandDisplay::instance()->syncDisplay(); m_rect = IntRect(0, 0, size.width(), size.height()); } @@ -97,6 +97,12 @@ void EGLWindowSurface::swapBuffers() LOG_ERROR("Failed to SwapBuffers(%d).", eglGetError()); m_surface->deleteFrameCallBack(); } + + if (!m_bufferAttached) { + // FIXME: Need a better way to handle this. + WaylandDisplay::instance()->syncDisplay(); + m_bufferAttached = true; + } } void EGLWindowSurface::destroy() diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLWaylandSurface.h b/Source/WebCore/platform/graphics/surfaces/egl/EGLWaylandSurface.h index d87e28c..d4cce9e 100644 --- a/Source/WebCore/platform/graphics/surfaces/egl/EGLWaylandSurface.h +++ b/Source/WebCore/platform/graphics/surfaces/egl/EGLWaylandSurface.h @@ -48,6 +48,7 @@ public: private: struct wl_egl_window* m_nativeWindow; OwnPtr m_surface; + bool m_bufferAttached :1; }; } diff --git a/Source/WebCore/platform/graphics/surfaces/wayland/WaylandDisplay.cpp b/Source/WebCore/platform/graphics/surfaces/wayland/WaylandDisplay.cpp index b1e0a0e..35f7cd8 100644 --- a/Source/WebCore/platform/graphics/surfaces/wayland/WaylandDisplay.cpp +++ b/Source/WebCore/platform/graphics/surfaces/wayland/WaylandDisplay.cpp @@ -497,6 +497,27 @@ PassOwnPtr WaylandDisplay::createSurface() return nullptr; } +void WaylandDisplay::lock() +{ + if (m_compositor && m_eventDispatcher) { + bool lockedDisplay = false; + // Aquire lock. + while (!lockedDisplay) + lockedDisplay = m_eventDispatcher->lock(); + } +} + +void WaylandDisplay::unlock() +{ + if (m_eventDispatcher) + m_eventDispatcher->unlock(); +} + +void WaylandDisplay::handlePendingEvents() +{ + m_compositor->flush(); +} + void WaylandDisplay::handleGlobal(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t) { WaylandDisplay* display = static_cast(data); diff --git a/Source/WebCore/platform/graphics/surfaces/wayland/WaylandDisplay.h b/Source/WebCore/platform/graphics/surfaces/wayland/WaylandDisplay.h index 103b883..35bdff2 100644 --- a/Source/WebCore/platform/graphics/surfaces/wayland/WaylandDisplay.h +++ b/Source/WebCore/platform/graphics/surfaces/wayland/WaylandDisplay.h @@ -68,6 +68,9 @@ protected: private: void terminate(); + void lock(); + void unlock(); + void handlePendingEvents(); void initialize(wl_display* = 0); static WaylandDisplay* openStaticConnection(); @@ -87,6 +90,7 @@ private: struct wl_registry* m_registry; struct wl_compositor* m_wlCompositor; struct wl_event_queue* m_queue; + friend class WaylandBuffer; }; } diff --git a/Source/WebCore/platform/graphics/surfaces/wayland/WaylandSurface.cpp b/Source/WebCore/platform/graphics/surfaces/wayland/WaylandSurface.cpp index 007f0e1..fba2707 100644 --- a/Source/WebCore/platform/graphics/surfaces/wayland/WaylandSurface.cpp +++ b/Source/WebCore/platform/graphics/surfaces/wayland/WaylandSurface.cpp @@ -64,8 +64,7 @@ WaylandSurface::WaylandSurface(struct wl_compositor* compositor) bufferHandleId++; m_id = bufferHandleId; - m_queue = wl_display_create_queue(WaylandDisplay::instance()->nativeDisplay()); - wl_proxy_set_queue((struct wl_proxy *)WaylandDisplay::instance()->registry(), m_queue); + WaylandDisplay::instance()->syncDisplay(); } void WaylandSurface::addFrameCallBack() @@ -159,6 +158,16 @@ uint WaylandBuffer::textureId() if (m_state & PendingUpdate) bindTextureToImage(); + if (!m_textureId) { + WaylandDisplay::instance()->lock(); + WaylandDisplay::instance()->handlePendingEvents(); + if (!m_textureId) + handleSurfaceCommit(); + + bindTextureToImage(); + WaylandDisplay::instance()->unlock(); + } + return m_textureId; } diff --git a/Source/WebKit2/UIProcess/texmap/tizen/LayerBackingStoreTizen.cpp b/Source/WebKit2/UIProcess/texmap/tizen/LayerBackingStoreTizen.cpp index 9404d46..54e3df7 100644 --- a/Source/WebKit2/UIProcess/texmap/tizen/LayerBackingStoreTizen.cpp +++ b/Source/WebKit2/UIProcess/texmap/tizen/LayerBackingStoreTizen.cpp @@ -33,6 +33,10 @@ using namespace WebCore; namespace WebKit { void LayerBackingStoreTileTizen::paintPlatformSurfaceTile(WebCore::TextureMapper* textureMapper, const WebCore::TransformationMatrix& transform, float opacity) { +#if PLATFORM(WAYLAND) + if (!m_textureId) + return; +#endif FloatRect targetRect(m_targetRect); targetRect.scale(1. / m_scale); if (targetRect != rect()) -- 2.7.4