#if ENABLE(TIZEN_CANVAS_CAIRO_GLES_RENDERING)
if (m_isLockable || renderingMode == Unaccelerated)
m_data.m_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, size.width(), size.height());
- else
- m_data.m_surface = cairo_gl_surface_create_for_egl(static_cast<cairo_device_t*>(g_sharedCairoDevice), m_offScreenSurface->drawable(), size.width(), size.height());
+ else {
+#if PLATFORM(WAYLAND)
+ // FIXME: On Wayland platform, we cannot simply share a single buffer (like pixmap)
+ // with the UI process. We have to use one gl surface for texture to represent the
+ // canvas content. Then, when we need to share it with the web process
+ // (at swapPlatformSurfaces), we copy it to the shared window buffer. This is inefficient
+ // indeed, but this is the only way to fix some weird issues when we use a double buffer
+ // window as a single pixmap.
+ m_data.m_surface = cairo_gl_surface_create(static_cast<cairo_device_t*>(g_sharedCairoDevice),
+ CAIRO_CONTENT_COLOR_ALPHA, size.width(), size.height());
+ if (cairo_surface_status(m_data.m_surface) != CAIRO_STATUS_SUCCESS)
+ return;
+ m_data.m_shared_surface = cairo_gl_surface_create_for_egl(static_cast<cairo_device_t*>(g_sharedCairoDevice),
+ m_offScreenSurface->drawable(), size.width(), size.height());
+ if (cairo_surface_status(m_data.m_shared_surface) != CAIRO_STATUS_SUCCESS) {
+#if ENABLE(TIZEN_DLOG_SUPPORT)
+ TIZEN_LOGE("cairo_gl_surface_create_for_egl() failed!\n");
+#endif
+ cairo_surface_destroy(m_data.m_surface);
+ m_data.m_surface = NULL;
+ }
+#else
+ m_data.m_surface = cairo_gl_surface_create_for_egl(static_cast<cairo_device_t*>(g_sharedCairoDevice),
+ m_offScreenSurface->drawable(), size.width(), size.height());
+#endif
+ }
#else
m_data.m_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, size.width(), size.height());
#endif
- if (cairo_surface_status(m_data.m_surface) != CAIRO_STATUS_SUCCESS) {
-#if ENABLE(TIZEN_DLOG_SUPPORT)
- TIZEN_LOGE("cairo_gl_surface_create_for_egl() failed!\n");
-#endif
+ if (cairo_surface_status(m_data.m_surface) != CAIRO_STATUS_SUCCESS)
return; // create will notice we didn't set m_initialized and fail.
- }
RefPtr<cairo_t> cr = adoptRef(cairo_create(m_data.m_surface));
m_data.m_platformContext.setCr(cr.get());
glFlush();
}
#endif
+
+#if PLATFORM(WAYLAND)
+ if (m_data.m_shared_surface)
+ cairo_surface_destroy(m_data.m_shared_surface);
+#endif
destroy();
}
#endif
- cairo_surface_destroy(m_data.m_surface);
+ if (m_data.m_surface)
+ cairo_surface_destroy(m_data.m_surface);
}
#if ENABLE(TIZEN_CANVAS_CAIRO_GLES_RENDERING) || ENABLE(TIZEN_CANVAS_SURFACE_LOCKING)
void ImageBuffer::swapPlatformSurfaces()
{
#if PLATFORM(WAYLAND)
+ cairo_t *cr = cairo_create(m_data.m_shared_surface);
+ cairo_set_source_surface(cr, m_data.m_surface, 0, 0);
+ cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+ cairo_paint(cr);
+ cairo_destroy(cr);
+ cairo_surface_flush(m_data.m_shared_surface);
+ glFlush();
+
m_offScreenContext->makeCurrent(m_offScreenSurface.get());
m_offScreenSurface->swapBuffers();
#else