This patch adds support for LockSurface. 00/7800/1 submit/tizen/20130809.012127
authorKondapally Kalyan <kalyan.kondapally@intel.com>
Tue, 6 Aug 2013 05:21:07 +0000 (08:21 +0300)
committerKondapally Kalyan <kalyan.kondapally@intel.com>
Tue, 6 Aug 2013 05:21:07 +0000 (08:21 +0300)
Changes in SharedPlatformSurfaceTizen are based on initial patch
provided by Joone Hur.

Change-Id: Ib572872447056b1777135ff6b65d458b2fcaab26

Source/WebCore/platform/graphics/efl/tizen/SharedPlatformSurfaceTizen.cpp
Source/WebCore/platform/graphics/surfaces/egl/EGLWaylandSurface.cpp
Source/WebCore/platform/graphics/surfaces/egl/EGLWaylandSurface.h
Source/WebCore/platform/graphics/surfaces/wayland/WaylandDisplay.cpp
Source/WebCore/platform/graphics/surfaces/wayland/WaylandDisplay.h
Source/WebCore/platform/graphics/surfaces/wayland/WaylandSurface.cpp
Source/WebKit2/UIProcess/texmap/tizen/LayerBackingStoreTizen.cpp

index 9a7ff9c..35c42dd 100755 (executable)
@@ -34,6 +34,7 @@
 #include <wtf/HashMap.h>
 
 namespace WebCore {
+static bool needsLockSurfaceWorkAround = false;
 
 class PixmapContextPool {
 protected:
@@ -89,7 +90,16 @@ PassOwnPtr<SharedPlatformSurfaceTizen> 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)
index e98f800..d749e72 100644 (file)
@@ -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()
index d87e28c..d4cce9e 100644 (file)
@@ -48,6 +48,7 @@ public:
 private:
     struct wl_egl_window* m_nativeWindow;
     OwnPtr<WaylandSurface> m_surface;
+    bool m_bufferAttached :1;
 };
 
 }
index b1e0a0e..35f7cd8 100644 (file)
@@ -497,6 +497,27 @@ PassOwnPtr<WaylandSurface> 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<WaylandDisplay*>(data);
index 103b883..35bdff2 100644 (file)
@@ -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;
 };
 
 }
index 007f0e1..fba2707 100644 (file)
@@ -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;
 }
 
index 9404d46..54e3df7 100644 (file)
@@ -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())