Title: [188955] releases/WebKitGTK/webkit-2.10/Source/WebCore
Revision
188955
Author
carlo...@webkit.org
Date
2015-08-26 01:03:04 -0700 (Wed, 26 Aug 2015)

Log Message

Merge r188902 - Clear cairo-gl surface for initialization
https://bugs.webkit.org/show_bug.cgi?id=148307

Patch by Jinyoung Hur <hur....@navercorp.com> on 2015-08-24
Reviewed by Martin Robinson.

A cairo-gl surface that is created from an uninitialized texture, should be cleared before use.
A texture memory created by calling glTexImage2D with null data parameter, is uninitialized.
And cairo_gl_surface_create_for_texture doesn't clear the provided texture for initialization.
So it seems safe to clear the surface explicitly.

It is hard to verify this behavior change because the texture memory status is undefined. Undefined means
it can be either initialized or not, though mostly initialized in my experiences.

* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::clearSurface):
(WebCore::createCairoGLSurface):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog (188954 => 188955)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2015-08-26 07:52:01 UTC (rev 188954)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2015-08-26 08:03:04 UTC (rev 188955)
@@ -1,3 +1,22 @@
+2015-08-24  Jinyoung Hur  <hur....@navercorp.com>
+
+        Clear cairo-gl surface for initialization
+        https://bugs.webkit.org/show_bug.cgi?id=148307
+
+        Reviewed by Martin Robinson.
+
+        A cairo-gl surface that is created from an uninitialized texture, should be cleared before use.
+        A texture memory created by calling glTexImage2D with null data parameter, is uninitialized.
+        And cairo_gl_surface_create_for_texture doesn't clear the provided texture for initialization.
+        So it seems safe to clear the surface explicitly.
+
+        It is hard to verify this behavior change because the texture memory status is undefined. Undefined means
+        it can be either initialized or not, though mostly initialized in my experiences.
+
+        * platform/graphics/cairo/ImageBufferCairo.cpp:
+        (WebCore::clearSurface):
+        (WebCore::createCairoGLSurface):
+
 2015-08-25  Carlos Garcia Campos  <cgar...@igalia.com>
 
         IconDatabase: syncThreadMainLoop() is unlocking m_syncLock twice when thread termination is requested

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp (188954 => 188955)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp	2015-08-26 07:52:01 UTC (rev 188954)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp	2015-08-26 08:03:04 UTC (rev 188955)
@@ -68,6 +68,16 @@
 }
 
 #if ENABLE(ACCELERATED_2D_CANVAS)
+void clearSurface(cairo_surface_t* surface)
+{
+    if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS)
+        return;
+
+    RefPtr<cairo_t> cr = adoptRef(cairo_create(surface));
+    cairo_set_operator(cr.get(), CAIRO_OPERATOR_CLEAR);
+    cairo_paint(cr.get());
+}
+
 PassRefPtr<cairo_surface_t> createCairoGLSurface(const FloatSize& size, uint32_t& texture)
 {
     GLContext::sharingContext()->makeContextCurrent();
@@ -91,7 +101,9 @@
     // Thread-awareness is a huge performance hit on non-Intel drivers.
     cairo_gl_device_set_thread_aware(device, FALSE);
 
-    return adoptRef(cairo_gl_surface_create_for_texture(device, CAIRO_CONTENT_COLOR_ALPHA, texture, size.width(), size.height()));
+    auto surface = adoptRef(cairo_gl_surface_create_for_texture(device, CAIRO_CONTENT_COLOR_ALPHA, texture, size.width(), size.height()));
+    clearSurface(surface.get());
+    return surface;
 }
 #endif
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to