Title: [141333] trunk/Source/WebCore
Revision
141333
Author
timothy_hor...@apple.com
Date
2013-01-30 15:34:57 -0800 (Wed, 30 Jan 2013)

Log Message

[mac] ImageBuffer should create accelerated buffers for small canvases, but we shouldn't force them to create compositing layers
https://bugs.webkit.org/show_bug.cgi?id=107804
<rdar://problem/11752381>

Reviewed by Simon Fraser.

Make all canvases IOSurface-backed if requested, instead of having a size threshold
under which we won't use accelerated canvas.

Make requiresCompositingForCanvas take the size of the canvas into account, using
the threshold which was previously in ImageBuffer to determine whether or not a
canvas should be forced into a compositing layer.

This improves canvas performance on some benchmarks
(http://www.mikechambers.com/html5/_javascript_/QuadTree/examples/collision.html, for example)
significantly, in cases where canvases which fall below the size limit
(and thus are unaccelerated) are being drawn rapidly into either accelerated
tiles or another accelerated canvas, by preventing excessive copying to/from the GPU.

* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore):
(WebCore::ImageBuffer::ImageBuffer):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::requiresCompositingForCanvas):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (141332 => 141333)


--- trunk/Source/WebCore/ChangeLog	2013-01-30 23:30:39 UTC (rev 141332)
+++ trunk/Source/WebCore/ChangeLog	2013-01-30 23:34:57 UTC (rev 141333)
@@ -1,3 +1,30 @@
+2013-01-30  Tim Horton  <timothy_hor...@apple.com>
+
+        [mac] ImageBuffer should create accelerated buffers for small canvases, but we shouldn't force them to create compositing layers
+        https://bugs.webkit.org/show_bug.cgi?id=107804
+        <rdar://problem/11752381>
+
+        Reviewed by Simon Fraser.
+
+        Make all canvases IOSurface-backed if requested, instead of having a size threshold
+        under which we won't use accelerated canvas.
+
+        Make requiresCompositingForCanvas take the size of the canvas into account, using
+        the threshold which was previously in ImageBuffer to determine whether or not a
+        canvas should be forced into a compositing layer.
+
+        This improves canvas performance on some benchmarks
+        (http://www.mikechambers.com/html5/_javascript_/QuadTree/examples/collision.html, for example)
+        significantly, in cases where canvases which fall below the size limit
+        (and thus are unaccelerated) are being drawn rapidly into either accelerated
+        tiles or another accelerated canvas, by preventing excessive copying to/from the GPU.
+
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore):
+        (WebCore::ImageBuffer::ImageBuffer):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::requiresCompositingForCanvas):
+
 2013-01-30  Alec Flett  <alecfl...@chromium.org>
 
         IndexedDB: clean up scheduleTask return type

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (141332 => 141333)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2013-01-30 23:30:39 UTC (rev 141332)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2013-01-30 23:34:57 UTC (rev 141333)
@@ -62,7 +62,6 @@
 
 #if USE(IOSURFACE_CANVAS_BACKING_STORE)
 static const int maxIOSurfaceDimension = 4096;
-static const int minIOSurfaceArea = 50 * 100;
 
 static RetainPtr<IOSurfaceRef> createIOSurface(const IntSize& size)
 {
@@ -136,7 +135,7 @@
         return;
 
 #if USE(IOSURFACE_CANVAS_BACKING_STORE)
-    if (width.unsafeGet() >= maxIOSurfaceDimension || height.unsafeGet() >= maxIOSurfaceDimension || (width * height).unsafeGet() < minIOSurfaceArea)
+    if (width.unsafeGet() >= maxIOSurfaceDimension || height.unsafeGet() >= maxIOSurfaceDimension)
         accelerateRendering = false;
 #else
     ASSERT(renderingMode == Unaccelerated);

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (141332 => 141333)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2013-01-30 23:30:39 UTC (rev 141332)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2013-01-30 23:34:57 UTC (rev 141333)
@@ -80,6 +80,12 @@
 bool WebCoreHas3DRendering = true;
 #endif
 
+#if !PLATFORM(MAC) && !PLATFORM(IOS)
+#define WTF_USE_COMPOSITING_FOR_SMALL_CANVASES 1
+#endif
+
+static const int canvasAreaThresholdRequiringCompositing = 50 * 100;
+
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -1906,7 +1912,12 @@
 
     if (renderer->isCanvas()) {
         HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(renderer->node());
-        return canvas->renderingContext() && canvas->renderingContext()->isAccelerated();
+#if USE(COMPOSITING_FOR_SMALL_CANVASES)
+        bool isCanvasLargeEnoughToForceCompositing = true;
+#else
+        bool isCanvasLargeEnoughToForceCompositing = canvas->size().area() >= canvasAreaThresholdRequiringCompositing;
+#endif
+        return canvas->renderingContext() && canvas->renderingContext()->isAccelerated() && (canvas->renderingContext()->is3d() || isCanvasLargeEnoughToForceCompositing);
     }
     return false;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to