Title: [212069] branches/safari-603-branch

Diff

Modified: branches/safari-603-branch/LayoutTests/ChangeLog (212068 => 212069)


--- branches/safari-603-branch/LayoutTests/ChangeLog	2017-02-10 06:37:13 UTC (rev 212068)
+++ branches/safari-603-branch/LayoutTests/ChangeLog	2017-02-10 06:37:18 UTC (rev 212069)
@@ -1,5 +1,24 @@
 2017-02-09  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r211949. rdar://problem/30119483
+
+    2017-02-09  Andreas Kling  <akl...@apple.com>
+
+            Disallow accelerated rendering for ginormous 2D canvases.
+            <https://webkit.org/b/167968>
+            <rdar://problem/30119483>
+
+            Reviewed by Antti Koivisto.
+
+            Add a simple test that documents the fact that we no longer accelerate canvases
+            larger than 5120x2880.
+
+            * compositing/canvas/accelerated-canvas-compositing-size-limit-expected.txt: Added.
+            * compositing/canvas/accelerated-canvas-compositing-size-limit.html: Added.
+            * platform/ios-simulator/compositing/canvas/accelerated-canvas-compositing-size-limit-expected.txt: Added.
+
+2017-02-09  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r211926. rdar://problem/30275036
 
     2017-02-08  Youenn Fablet  <youe...@gmail.com>

Added: branches/safari-603-branch/LayoutTests/compositing/canvas/accelerated-canvas-compositing-size-limit-expected.txt (0 => 212069)


--- branches/safari-603-branch/LayoutTests/compositing/canvas/accelerated-canvas-compositing-size-limit-expected.txt	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/compositing/canvas/accelerated-canvas-compositing-size-limit-expected.txt	2017-02-10 06:37:18 UTC (rev 212069)
@@ -0,0 +1,35 @@
+Verifies that 2D canvases with higher than 5120x2880 resolution don't create accelerated backing stores.
+
+ 
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 5208.00 6171.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 5208.00 6171.00)
+      (contentsOpaque 1)
+      (children 3
+        (GraphicsLayer
+          (position 8.00 50.00)
+          (bounds 512.00 288.00)
+          (drawsContent 1)
+          (acceleratesDrawing 1)
+        )
+        (GraphicsLayer
+          (position 8.00 342.00)
+          (bounds 5120.00 2880.00)
+          (usingTiledLayer 1)
+          (drawsContent 1)
+          (acceleratesDrawing 1)
+        )
+        (GraphicsLayer
+          (position 8.00 3226.00)
+          (bounds 5200.00 2900.00)
+          (usingTiledLayer 1)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+

Added: branches/safari-603-branch/LayoutTests/compositing/canvas/accelerated-canvas-compositing-size-limit.html (0 => 212069)


--- branches/safari-603-branch/LayoutTests/compositing/canvas/accelerated-canvas-compositing-size-limit.html	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/compositing/canvas/accelerated-canvas-compositing-size-limit.html	2017-02-10 06:37:18 UTC (rev 212069)
@@ -0,0 +1,40 @@
+<!DOCTYPE html><html>
+<head>
+<style>
+canvas {
+    -webkit-transform: translateZ(0);
+}
+</style>
+<script>
+    if (window.testRunner) {
+      testRunner.dumpAsText();
+      testRunner.waitUntilDone();
+    }
+
+    function doTest() {
+        var canvases = document.getElementsByTagName("canvas");
+        for (var i = 0; i < canvases.length; ++i) {
+            var c = canvases[i];
+            var ctx = c.getContext('2d');
+            if (!ctx)
+                continue;
+            ctx.fillStyle = 'rgba(255,0,0,1)';
+            ctx.fillRect(0,0,c.width, c.height);
+        }
+        if (window.testRunner) {
+            document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_ACCELERATES_DRAWING);
+            testRunner.notifyDone();
+        }
+    }
+
+    window.addEventListener('load', doTest, false);
+</script>
+</head>
+<body>
+<p>Verifies that 2D canvases with higher than 5120x2880 resolution don't create accelerated backing stores.</p>
+<canvas id="c1" width="512" height="288"></canvas>
+<canvas id="c2" width="5120" height="2880"></canvas>
+<canvas id="c3" width="5200" height="2900"></canvas>
+<pre id="layers">Layer tree goes here in DRT</pre>
+</body>
+</html>

Added: branches/safari-603-branch/LayoutTests/platform/ios-simulator/compositing/canvas/accelerated-canvas-compositing-size-limit-expected.txt (0 => 212069)


--- branches/safari-603-branch/LayoutTests/platform/ios-simulator/compositing/canvas/accelerated-canvas-compositing-size-limit-expected.txt	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/platform/ios-simulator/compositing/canvas/accelerated-canvas-compositing-size-limit-expected.txt	2017-02-10 06:37:18 UTC (rev 212069)
@@ -0,0 +1,33 @@
+Verifies that 2D canvases with higher than 5120x2880 resolution don't create accelerated backing stores.
+
+ 
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 5208.00 6175.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 5208.00 6175.00)
+      (contentsOpaque 1)
+      (children 3
+        (GraphicsLayer
+          (position 8.00 52.00)
+          (bounds 512.00 288.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 8.00 345.00)
+          (bounds 5120.00 2880.00)
+          (usingTiledLayer 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 8.00 3230.00)
+          (bounds 5200.00 2900.00)
+          (usingTiledLayer 1)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+

Modified: branches/safari-603-branch/Source/WebCore/ChangeLog (212068 => 212069)


--- branches/safari-603-branch/Source/WebCore/ChangeLog	2017-02-10 06:37:13 UTC (rev 212068)
+++ branches/safari-603-branch/Source/WebCore/ChangeLog	2017-02-10 06:37:18 UTC (rev 212069)
@@ -1,5 +1,38 @@
 2017-02-09  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r211949. rdar://problem/30119483
+
+    2017-02-09  Andreas Kling  <akl...@apple.com>
+
+            Disallow accelerated rendering for ginormous 2D canvases.
+            <https://webkit.org/b/167968>
+            <rdar://problem/30119483>
+
+            Reviewed by Antti Koivisto.
+
+            Add a "maximumAccelerated2dCanvasSize" setting that defaults to 5120x2880
+            which is the 5K resolution for 16:9.
+
+            Also added a way to include the "accelerates drawing" flag in layer tree dumps.
+
+            Test: compositing/canvas/accelerated-canvas-compositing-size-limit.html
+
+            * html/HTMLCanvasElement.cpp:
+            (WebCore::HTMLCanvasElement::shouldAccelerate):
+            * page/Frame.h:
+            * page/Settings.in:
+            * platform/graphics/GraphicsLayer.cpp:
+            (WebCore::GraphicsLayer::dumpProperties):
+            * platform/graphics/GraphicsLayerClient.h:
+            * rendering/RenderLayerCompositor.cpp:
+            (WebCore::RenderLayerCompositor::layerTreeAsText):
+            * testing/Internals.cpp:
+            (WebCore::toLayerTreeFlags):
+            * testing/Internals.h:
+            * testing/Internals.idl:
+
+2017-02-09  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r211926. rdar://problem/30275036
 
     2017-02-08  Youenn Fablet  <youe...@gmail.com>

Modified: branches/safari-603-branch/Source/WebCore/html/HTMLCanvasElement.cpp (212068 => 212069)


--- branches/safari-603-branch/Source/WebCore/html/HTMLCanvasElement.cpp	2017-02-10 06:37:13 UTC (rev 212068)
+++ branches/safari-603-branch/Source/WebCore/html/HTMLCanvasElement.cpp	2017-02-10 06:37:18 UTC (rev 212069)
@@ -543,19 +543,27 @@
 
 bool HTMLCanvasElement::shouldAccelerate(const IntSize& size) const
 {
+    if (!document().settings())
+        return false;
+    auto& settings = *document().settings();
+
+    auto area = size.area<RecordOverflow>();
+    if (area.hasOverflowed())
+        return false;
+
+    if (area > settings.maximumAccelerated2dCanvasSize())
+        return false;
+
 #if USE(IOSURFACE_CANVAS_BACKING_STORE)
-    UNUSED_PARAM(size);
-    return document().settings() && document().settings()->canvasUsesAcceleratedDrawing();
+    return settings.canvasUsesAcceleratedDrawing();
 #elif ENABLE(ACCELERATED_2D_CANVAS)
     if (m_context && !m_context->is2d())
         return false;
 
-    Settings* settings = document().settings();
-    if (!settings || !settings->accelerated2dCanvasEnabled())
+    if (!settings.accelerated2dCanvasEnabled())
         return false;
 
-    // Do not use acceleration for small canvas.
-    if (size.width() * size.height() < settings->minimumAccelerated2dCanvasSize())
+    if (area < settings.minimumAccelerated2dCanvasSize())
         return false;
 
     return true;

Modified: branches/safari-603-branch/Source/WebCore/page/Frame.h (212068 => 212069)


--- branches/safari-603-branch/Source/WebCore/page/Frame.h	2017-02-10 06:37:13 UTC (rev 212068)
+++ branches/safari-603-branch/Source/WebCore/page/Frame.h	2017-02-10 06:37:18 UTC (rev 212069)
@@ -105,7 +105,8 @@
     LayerTreeFlagsIncludeTileCaches = 1 << 2,
     LayerTreeFlagsIncludeRepaintRects = 1 << 3,
     LayerTreeFlagsIncludePaintingPhases = 1 << 4,
-    LayerTreeFlagsIncludeContentLayers = 1 << 5
+    LayerTreeFlagsIncludeContentLayers = 1 << 5,
+    LayerTreeFlagsIncludeAcceleratesDrawing = 1 << 6,
 };
 typedef unsigned LayerTreeFlags;
 

Modified: branches/safari-603-branch/Source/WebCore/page/Settings.in (212068 => 212069)


--- branches/safari-603-branch/Source/WebCore/page/Settings.in	2017-02-10 06:37:13 UTC (rev 212068)
+++ branches/safari-603-branch/Source/WebCore/page/Settings.in	2017-02-10 06:37:18 UTC (rev 212069)
@@ -25,6 +25,8 @@
 # draw canvas in software.
 minimumAccelerated2dCanvasSize type=int, initial=257*256
 
+maximumAccelerated2dCanvasSize type=unsigned, initial=5120*2880
+
 layoutFallbackWidth type=int, initial=980
 deviceWidth type=int, initial=0
 deviceHeight type=int, initial=0

Modified: branches/safari-603-branch/Source/WebCore/platform/graphics/GraphicsLayer.cpp (212068 => 212069)


--- branches/safari-603-branch/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2017-02-10 06:37:13 UTC (rev 212068)
+++ branches/safari-603-branch/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2017-02-10 06:37:18 UTC (rev 212069)
@@ -775,6 +775,11 @@
         ts << "(backgroundColor " << m_backgroundColor.nameForRenderTreeAsText() << ")\n";
     }
 
+    if (behavior & LayerTreeAsTextIncludeAcceleratesDrawing && m_acceleratesDrawing) {
+        writeIndent(ts, indent + 1);
+        ts << "(acceleratesDrawing " << m_acceleratesDrawing << ")\n";
+    }
+
     if (!m_transform.isIdentity()) {
         writeIndent(ts, indent + 1);
         ts << "(transform ";

Modified: branches/safari-603-branch/Source/WebCore/platform/graphics/GraphicsLayerClient.h (212068 => 212069)


--- branches/safari-603-branch/Source/WebCore/platform/graphics/GraphicsLayerClient.h	2017-02-10 06:37:13 UTC (rev 212068)
+++ branches/safari-603-branch/Source/WebCore/platform/graphics/GraphicsLayerClient.h	2017-02-10 06:37:18 UTC (rev 212069)
@@ -72,6 +72,7 @@
     LayerTreeAsTextIncludePaintingPhases        = 1 << 4,
     LayerTreeAsTextIncludeContentLayers         = 1 << 5,
     LayerTreeAsTextIncludePageOverlayLayers     = 1 << 6,
+    LayerTreeAsTextIncludeAcceleratesDrawing    = 1 << 7,
 };
 typedef unsigned LayerTreeAsTextBehavior;
 

Modified: branches/safari-603-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp (212068 => 212069)


--- branches/safari-603-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp	2017-02-10 06:37:13 UTC (rev 212068)
+++ branches/safari-603-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp	2017-02-10 06:37:18 UTC (rev 212069)
@@ -1831,6 +1831,8 @@
         layerTreeBehavior |= LayerTreeAsTextIncludePaintingPhases;
     if (flags & LayerTreeFlagsIncludeContentLayers)
         layerTreeBehavior |= LayerTreeAsTextIncludeContentLayers;
+    if (flags & LayerTreeFlagsIncludeAcceleratesDrawing)
+        layerTreeBehavior |= LayerTreeAsTextIncludeAcceleratesDrawing;
 
     // We skip dumping the scroll and clip layers to keep layerTreeAsText output
     // similar between platforms.

Modified: branches/safari-603-branch/Source/WebCore/testing/Internals.cpp (212068 => 212069)


--- branches/safari-603-branch/Source/WebCore/testing/Internals.cpp	2017-02-10 06:37:13 UTC (rev 212068)
+++ branches/safari-603-branch/Source/WebCore/testing/Internals.cpp	2017-02-10 06:37:18 UTC (rev 212069)
@@ -1989,6 +1989,8 @@
         layerTreeFlags |= LayerTreeFlagsIncludePaintingPhases;
     if (flags & LAYER_TREE_INCLUDES_CONTENT_LAYERS)
         layerTreeFlags |= LayerTreeFlagsIncludeContentLayers;
+    if (flags & LAYER_TREE_INCLUDES_ACCELERATES_DRAWING)
+        layerTreeFlags |= LayerTreeFlagsIncludeAcceleratesDrawing;
 
     return document.frame()->layerTreeAsText(layerTreeFlags);
 }

Modified: branches/safari-603-branch/Source/WebCore/testing/Internals.h (212068 => 212069)


--- branches/safari-603-branch/Source/WebCore/testing/Internals.h	2017-02-10 06:37:13 UTC (rev 212068)
+++ branches/safari-603-branch/Source/WebCore/testing/Internals.h	2017-02-10 06:37:18 UTC (rev 212069)
@@ -258,7 +258,8 @@
         LAYER_TREE_INCLUDES_TILE_CACHES = 2,
         LAYER_TREE_INCLUDES_REPAINT_RECTS = 4,
         LAYER_TREE_INCLUDES_PAINTING_PHASES = 8,
-        LAYER_TREE_INCLUDES_CONTENT_LAYERS = 16
+        LAYER_TREE_INCLUDES_CONTENT_LAYERS = 16,
+        LAYER_TREE_INCLUDES_ACCELERATES_DRAWING = 32,
     };
     ExceptionOr<String> layerTreeAsText(Document&, unsigned short flags) const;
     ExceptionOr<String> repaintRectsAsText() const;

Modified: branches/safari-603-branch/Source/WebCore/testing/Internals.idl (212068 => 212069)


--- branches/safari-603-branch/Source/WebCore/testing/Internals.idl	2017-02-10 06:37:13 UTC (rev 212068)
+++ branches/safari-603-branch/Source/WebCore/testing/Internals.idl	2017-02-10 06:37:18 UTC (rev 212069)
@@ -251,6 +251,7 @@
     const unsigned short LAYER_TREE_INCLUDES_REPAINT_RECTS = 4;
     const unsigned short LAYER_TREE_INCLUDES_PAINTING_PHASES = 8;
     const unsigned short LAYER_TREE_INCLUDES_CONTENT_LAYERS = 16;
+    const unsigned short LAYER_TREE_INCLUDES_ACCELERATES_DRAWING = 32;
     [MayThrowException] DOMString layerTreeAsText(Document document, optional unsigned short flags = 0);
 
     [MayThrowException] DOMString scrollingStateTreeAsText();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to