#include <wtf/HashMap.h>
namespace WebCore {
+static bool needsLockSurfaceWorkAround = false;
class PixmapContextPool {
protected:
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;
}
return false;
}
+ if (needsLockSurfaceWorkAround)
+ makeContextCurrent();
+
return true;
}
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)
EGLWindowSurface::EGLWindowSurface(const IntSize& size, GLPlatformSurface::SurfaceAttributes attributes)
: EGLOffScreenSurface(attributes)
, m_nativeWindow(0)
+ , m_bufferAttached(false)
{
if (!m_configSelector)
return;
}
m_bufferHandle = m_surface->handle();
- WaylandDisplay::instance()->syncDisplay();
m_rect = IntRect(0, 0, size.width(), size.height());
}
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()
private:
struct wl_egl_window* m_nativeWindow;
OwnPtr<WaylandSurface> m_surface;
+ bool m_bufferAttached :1;
};
}
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);
private:
void terminate();
+ void lock();
+ void unlock();
+ void handlePendingEvents();
void initialize(wl_display* = 0);
static WaylandDisplay* openStaticConnection();
struct wl_registry* m_registry;
struct wl_compositor* m_wlCompositor;
struct wl_event_queue* m_queue;
+ friend class WaylandBuffer;
};
}
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()
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;
}
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())