Title: [188902] trunk/Source/WebCore
Revision
188902
Author
commit-qu...@webkit.org
Date
2015-08-24 18:56:46 -0700 (Mon, 24 Aug 2015)

Log Message

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: trunk/Source/WebCore/ChangeLog (188901 => 188902)


--- trunk/Source/WebCore/ChangeLog	2015-08-25 01:48:18 UTC (rev 188901)
+++ trunk/Source/WebCore/ChangeLog	2015-08-25 01:56:46 UTC (rev 188902)
@@ -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-24  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Fix the build fixes in r188875 and r188874

Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp (188901 => 188902)


--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp	2015-08-25 01:48:18 UTC (rev 188901)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp	2015-08-25 01:56:46 UTC (rev 188902)
@@ -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