Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Use device pixel ratio scaled backing stores for unscaled bitmap cont…
…ent if the page is downscaling https://bugs.webkit.org/show_bug.cgi?id=242978 Reviewed by Simon Fraser and Dean Jackson. If the page is downscaled, then not including the device pixel ratio in the backing store means that we'll end up downscaling the image/canvas content and then upscaling it again by the device pixel ratio during compositing. This checks if we'd downscaling during painting if we removed the device pixel ratio, and skips the unscaled bitmap optimization if so. * LayoutTests/compositing/canvas/hidpi-canvas-backing-store-invalidation-2-expected.txt: Added. * LayoutTests/compositing/canvas/hidpi-canvas-backing-store-invalidation-2.html: Added. * Source/WebCore/rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::isUnscaledBitmapOnly const): Canonical link: https://commits.webkit.org/252855@main
- Loading branch information
1 parent
9b9da1b
commit fe12c1c
Showing
8 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
LayoutTests/compositing/canvas/hidpi-canvas-backing-store-invalidation-2-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
Tests whether we switch back to a hidpi backing store when we zoom out (and would otherwise downscale the content too much). | ||
|
||
(GraphicsLayer | ||
(anchor 0.00 0.00) | ||
(bounds 2008.00 1141.00) | ||
(device scale 2.00) | ||
(children 1 | ||
(GraphicsLayer | ||
(bounds 2008.00 1141.00) | ||
(contentsOpaque 1) | ||
(device scale 2.00) | ||
(children 1 | ||
(GraphicsLayer | ||
(position 8.00 68.00) | ||
(bounds 2000.00 1004.00) | ||
(opacity 0.50) | ||
(device scale 2.00) | ||
(children 1 | ||
(GraphicsLayer | ||
(anchor 0.00 0.00) | ||
(bounds 2000.00 1000.00) | ||
(drawsContent 1) | ||
(transform [0.50 0.00 0.00 0.00] [0.00 0.50 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00]) | ||
(device scale 1.00) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
(GraphicsLayer | ||
(anchor 0.00 0.00) | ||
(bounds 1004.00 780.00) | ||
(device scale 2.00) | ||
(children 1 | ||
(GraphicsLayer | ||
(anchor 0.00 0.00) | ||
(bounds 2008.00 1561.00) | ||
(contentsOpaque 1) | ||
(transform [0.50 0.00 0.00 0.00] [0.00 0.50 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00]) | ||
(device scale 2.00) | ||
(children 1 | ||
(GraphicsLayer | ||
(position 8.00 68.00) | ||
(bounds 2000.00 1004.00) | ||
(opacity 0.50) | ||
(device scale 2.00) | ||
(children 1 | ||
(GraphicsLayer | ||
(anchor 0.00 0.00) | ||
(bounds 2000.00 1000.00) | ||
(drawsContent 1) | ||
(transform [0.50 0.00 0.00 0.00] [0.00 0.50 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00]) | ||
(device scale 2.00) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
|
56 changes: 56 additions & 0 deletions
56
LayoutTests/compositing/canvas/hidpi-canvas-backing-store-invalidation-2.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="initial-scale=1"> | ||
<script> | ||
|
||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.waitUntilDone(); | ||
} | ||
|
||
function doTest() { | ||
var canvasElement = document.getElementById("canvas"); | ||
let dpr = window.devicePixelRatio || 1; | ||
|
||
canvas.width *= dpr; | ||
canvas.height *= dpr; | ||
|
||
canvas.style.transform = "scale(" + 1/dpr + ", " + 1/dpr + ")"; | ||
|
||
let ctx = canvas.getContext('2d'); | ||
ctx.scale(dpr, dpr); | ||
|
||
ctx.fillStyle = 'green'; | ||
ctx.fillRect(0, 0, 1000, 500); | ||
|
||
if (window.testRunner) { | ||
document.getElementById('layers-before').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_DEVICE_SCALE); | ||
} | ||
|
||
requestAnimationFrame(function() { | ||
if (window.internals) { | ||
window.internals.setPageScaleFactor(0.5, 0, 0); | ||
} | ||
|
||
if (window.testRunner) { | ||
document.getElementById('layers-after').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_DEVICE_SCALE); | ||
testRunner.notifyDone(); | ||
} | ||
}); | ||
} | ||
|
||
window.addEventListener('load', doTest, false); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<p> Tests whether we switch back to a hidpi backing store when we zoom out (and would otherwise downscale the content too much).</p> | ||
<div style="opacity:0.5"> | ||
<canvas id="canvas" width="1000" height="500" style="transform-origin:top left"></canvas> | ||
</div> | ||
<pre id="layers-before">Initial layer tree goes here in DRT</pre> | ||
<pre id="layers-after">Mutated layer tree goes here in DRT</pre> | ||
</body> | ||
|
||
</html> |
3 changes: 3 additions & 0 deletions
3
...ts/platform/gtk/compositing/canvas/hidpi-canvas-backing-store-invalidation-2-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Tests whether we switch back to a hidpi backing store when we zoom out (and would otherwise downscale the content too much). | ||
|
||
|
62 changes: 62 additions & 0 deletions
62
...latform/ios-wk2/compositing/canvas/hidpi-canvas-backing-store-invalidation-2-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Tests whether we switch back to a hidpi backing store when we zoom out (and would otherwise downscale the content too much). | ||
|
||
(GraphicsLayer | ||
(anchor 0.00 0.00) | ||
(bounds 2008.00 1144.00) | ||
(device scale 2.00) | ||
(children 1 | ||
(GraphicsLayer | ||
(bounds 2008.00 1144.00) | ||
(contentsOpaque 1) | ||
(device scale 2.00) | ||
(children 1 | ||
(GraphicsLayer | ||
(position 8.00 72.00) | ||
(bounds 2000.00 1005.00) | ||
(opacity 0.50) | ||
(device scale 2.00) | ||
(children 1 | ||
(GraphicsLayer | ||
(anchor 0.00 0.00) | ||
(bounds 2000.00 1000.00) | ||
(usingTiledLayer 1) | ||
(drawsContent 1) | ||
(transform [0.50 0.00 0.00 0.00] [0.00 0.50 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00]) | ||
(device scale 1.00) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
(GraphicsLayer | ||
(anchor 0.00 0.00) | ||
(bounds 2008.00 1550.00) | ||
(device scale 2.00) | ||
(children 1 | ||
(GraphicsLayer | ||
(bounds 2008.00 1550.00) | ||
(contentsOpaque 1) | ||
(device scale 2.00) | ||
(children 1 | ||
(GraphicsLayer | ||
(position 8.00 72.00) | ||
(bounds 2000.00 1005.00) | ||
(opacity 0.50) | ||
(device scale 2.00) | ||
(children 1 | ||
(GraphicsLayer | ||
(anchor 0.00 0.00) | ||
(bounds 2000.00 1000.00) | ||
(drawsContent 1) | ||
(transform [0.50 0.00 0.00 0.00] [0.00 0.50 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00]) | ||
(device scale 1.00) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters