[Cairo] Accelerated canvas should fall back to non-accelerated canvas on creation...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Aug 2015 16:44:43 +0000 (16:44 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Aug 2015 16:44:43 +0000 (16:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148476

Patch by Jinyoung Hur <hur.ims@navercorp.com> on 2015-08-26
Reviewed by Brent Fulgham.

Cairo-gl backed surface might fail to be created with large dimensions, e.g., 50x32000, depending on
the gl implementations. In case of Mac port, ImageBufferCG falls back to a software surface when it fails to create
IOSurface, an accelerated surface. Though the unaccelerated surface could be slower, it would be better
to create a working surface than nothing.

Because the max dimensions of gl texture might vary among the OpenGL implementations, below test can't guarantee
the verification of behavior difference depending on the running platform.

Test: fast/canvas/canvas-large-dimensions.html

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

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188968 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp

index e1d09b6..c802a5e 100644 (file)
@@ -1,3 +1,23 @@
+2015-08-26  Jinyoung Hur  <hur.ims@navercorp.com>
+
+        [Cairo] Accelerated canvas should fall back to non-accelerated canvas on creation failure
+        https://bugs.webkit.org/show_bug.cgi?id=148476
+
+        Reviewed by Brent Fulgham.
+
+        Cairo-gl backed surface might fail to be created with large dimensions, e.g., 50x32000, depending on 
+        the gl implementations. In case of Mac port, ImageBufferCG falls back to a software surface when it fails to create
+        IOSurface, an accelerated surface. Though the unaccelerated surface could be slower, it would be better
+        to create a working surface than nothing.
+
+        Because the max dimensions of gl texture might vary among the OpenGL implementations, below test can't guarantee
+        the verification of behavior difference depending on the running platform.
+
+        Test: fast/canvas/canvas-large-dimensions.html
+
+        * platform/graphics/cairo/ImageBufferCairo.cpp:
+        (WebCore::ImageBuffer::ImageBuffer):
+
 2015-08-26  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r188960.
index d7710a0..415f9dc 100644 (file)
@@ -117,9 +117,12 @@ ImageBuffer::ImageBuffer(const FloatSize& size, float /* resolutionScale */, Col
         return;
 
 #if ENABLE(ACCELERATED_2D_CANVAS)
-    if (renderingMode == Accelerated)
+    if (renderingMode == Accelerated) {
         m_data.m_surface = createCairoGLSurface(size, m_data.m_texture);
-    else
+        if (!m_data.m_surface || cairo_surface_status(m_data.m_surface.get()) != CAIRO_STATUS_SUCCESS)
+            renderingMode = Unaccelerated; // If allocation fails, fall back to non-accelerated path.
+    }
+    if (renderingMode == Unaccelerated)
 #else
     ASSERT_UNUSED(renderingMode, renderingMode != Accelerated);
 #endif