Commit b73bc6dc authored by ajuma@chromium.org's avatar ajuma@chromium.org

Make squashing work with subpixel layout

This changes GraphicsLayerPaintInfo::offsetFromSquashingCLM
from an IntSize to a LayoutSize and changes
SquashingState::offsetFromAbsoluteForSquashingCLM from an
IntPoint to a LayoutPoint. This also adds a
subpixelAccumulation field to GraphicsLayerPaintInfo; this
gets computed at the same time as
GraphicsLayerPaintInfo::offsetFromRenderer.

BUG=327387

Review URL: https://codereview.chromium.org/143283011

git-svn-id: svn://svn.chromium.org/blink/trunk@169584 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c9f7f887
<!DOCTYPE html>
<html>
<head>
<style>
.composited {
-webkit-transform: translateZ(0);
}
.background {
position: fixed;
background-color: lightgray;
width: 300px;
height: 300px;
top: 150px;
left: 100px;
}
.cyan {
background-color: cyan;
}
.lime {
background-color: lime;
}
.overlapping {
position: relative;
z-index: 1;
width: 200px;
height: 100.5px;
}
.nonsubpixel {
position: relative;
z-index: 1;
width: 200px;
height: 100px;
}
#description {
position: absolute;
top: 100px;
left: 450px;
width: 300px;
}
#testResults {
display: none;
}
body {
margin: 0px;
}
</style>
<script>
if (window.internals) {
internals.settings.setLayerSquashingEnabled(false);
}
</script>
</head>
<body>
<div id="description">
<p>This scenario tests that content is rendered correctly when the
squashing composited layer is itself at an integral position but contains
a render layer whose position is non-integral.</p>
</div>
<div class="composited background"> </div>
<div id="paragraph-a" class="nonsubpixel cyan"></div>
<div id="paragraph-b" class="overlapping lime"></div>
<div id="paragraph-c" class="overlapping cyan"></div>
<div id="paragraph-d" class="overlapping lime"></div>
<div id="paragraph-e" class="overlapping cyan"></div>
<div id="paragraph-f" class="overlapping lime"></div>
<div id="paragraph-g" class="overlapping cyan"></div>
<div id="paragraph-h" class="overlapping lime"></div>
<div id="paragraph-i" class="overlapping cyan"></div>
<div id="paragraph-j" class="overlapping lime"></div>
<div id="paragraph-k" class="overlapping cyan"></div>
<div id="paragraph-l" class="overlapping lime"></div>
<div id="paragraph-m" class="overlapping cyan"></div>
<div id="paragraph-n" class="overlapping lime"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
.composited {
-webkit-transform: translateZ(0);
}
.background {
position: fixed;
background-color: lightgray;
width: 300px;
height: 300px;
top: 150px;
left: 100px;
}
.cyan {
background-color: cyan;
}
.lime {
background-color: lime;
}
.overlapping {
position: relative;
z-index: 1;
width: 200px;
height: 100.5px;
}
.nonsubpixel {
position: relative;
z-index: 1;
width: 200px;
height: 100px;
}
#description {
position: absolute;
top: 100px;
left: 450px;
width: 300px;
}
#testResults {
display: none;
}
body {
margin: 0px;
}
</style>
<script>
if (window.internals) {
internals.settings.setLayerSquashingEnabled(true);
}
</script>
</head>
<body>
<div id="description">
<p>This scenario tests that content is rendered correctly when the
squashing composited layer is itself at an integral position but contains
a render layer whose position is non-integral.</p>
</div>
<div class="composited background"> </div>
<div id="paragraph-a" class="nonsubpixel cyan"></div>
<div id="paragraph-b" class="overlapping lime"></div>
<div id="paragraph-c" class="overlapping cyan"></div>
<div id="paragraph-d" class="overlapping lime"></div>
<div id="paragraph-e" class="overlapping cyan"></div>
<div id="paragraph-f" class="overlapping lime"></div>
<div id="paragraph-g" class="overlapping cyan"></div>
<div id="paragraph-h" class="overlapping lime"></div>
<div id="paragraph-i" class="overlapping cyan"></div>
<div id="paragraph-j" class="overlapping lime"></div>
<div id="paragraph-k" class="overlapping cyan"></div>
<div id="paragraph-l" class="overlapping lime"></div>
<div id="paragraph-m" class="overlapping cyan"></div>
<div id="paragraph-n" class="overlapping lime"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
.composited {
-webkit-transform: translateZ(0);
}
.background {
position: fixed;
background-color: lightgray;
width: 300px;
height: 300px;
top: 150px;
left: 100px;
}
.cyan {
background-color: cyan;
}
.lime {
background-color: lime;
}
.overlapping {
position: relative;
z-index: 1;
width: 200px;
height: 100.5px;
}
.nonsubpixel {
position: relative;
z-index: 1;
width: 200px;
height: 100px;
}
#description {
position: absolute;
top: 100px;
left: 450px;
width: 300px;
}
#testResults {
display: none;
}
body {
margin: 0px;
}
</style>
<script>
if (window.internals) {
internals.settings.setLayerSquashingEnabled(false);
}
</script>
</head>
<body>
<div id="description">
<p>This scenario tests that content is rendered correctly when
squashing composited layer is at a non-integral position, and contains
render layers at both integral and non-integral positions.</p>
</div>
<div class="composited background"> </div>
<div id="paragraph-a" class="overlapping cyan"></div>
<div id="paragraph-b" class="overlapping lime"></div>
<div id="paragraph-c" class="overlapping cyan"></div>
<div id="paragraph-d" class="overlapping lime"></div>
<div id="paragraph-e" class="overlapping cyan"></div>
<div id="paragraph-f" class="overlapping lime"></div>
<div id="paragraph-g" class="overlapping cyan"></div>
<div id="paragraph-h" class="overlapping lime"></div>
<div id="paragraph-i" class="overlapping cyan"></div>
<div id="paragraph-j" class="overlapping lime"></div>
<div id="paragraph-k" class="overlapping cyan"></div>
<div id="paragraph-l" class="overlapping lime"></div>
<div id="paragraph-m" class="overlapping cyan"></div>
<div id="paragraph-n" class="overlapping lime"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
.composited {
-webkit-transform: translateZ(0);
}
.background {
position: fixed;
background-color: lightgray;
width: 300px;
height: 300px;
top: 150px;
left: 100px;
}
.cyan {
background-color: cyan;
}
.lime {
background-color: lime;
}
.overlapping {
position: relative;
z-index: 1;
width: 200px;
height: 100.5px;
}
.nonsubpixel {
position: relative;
z-index: 1;
width: 200px;
height: 100px;
}
#description {
position: absolute;
top: 100px;
left: 450px;
width: 300px;
}
#testResults {
display: none;
}
body {
margin: 0px;
}
</style>
<script>
if (window.internals) {
internals.settings.setLayerSquashingEnabled(true);
}
</script>
</head>
<body>
<div id="description">
<p>This scenario tests that content is rendered correctly when
squashing composited layer is at a non-integral position, and contains
render layers at both integral and non-integral positions.</p>
</div>
<div class="composited background"> </div>
<div id="paragraph-a" class="overlapping cyan"></div>
<div id="paragraph-b" class="overlapping lime"></div>
<div id="paragraph-c" class="overlapping cyan"></div>
<div id="paragraph-d" class="overlapping lime"></div>
<div id="paragraph-e" class="overlapping cyan"></div>
<div id="paragraph-f" class="overlapping lime"></div>
<div id="paragraph-g" class="overlapping cyan"></div>
<div id="paragraph-h" class="overlapping lime"></div>
<div id="paragraph-i" class="overlapping cyan"></div>
<div id="paragraph-j" class="overlapping lime"></div>
<div id="paragraph-k" class="overlapping cyan"></div>
<div id="paragraph-l" class="overlapping lime"></div>
<div id="paragraph-m" class="overlapping cyan"></div>
<div id="paragraph-n" class="overlapping lime"></div>
</body>
</html>
<!DOCTYPE html>
<head>
<style>
.composited {
-webkit-transform: translatez(0);
}
.box {
width: 100px;
height: 100px;
}
.behind {
position: absolute;
z-index: 1;
top: 100px;
left: 100px;
background-color: blue;
}
.middle {
position: absolute;
z-index: 1;
top: 15px;
left: 15px;
background-color: lime;
}
.middle2 {
position: absolute;
z-index: 1;
top: 130.5px;
left: 60px;
background-color: magenta;
}
.top {
position: absolute;
z-index: 1;
top: 70.5px;
left: 120px;
background-color: cyan;
}
.container {
position: absolute;
z-index: 1;
top: 25.5px;
left: 25px;
width: 300px;
height: 300px;
background-color: gray;
}
div:hover {
background-color: green;
}
</style>
<script>
if (window.internals)
internals.settings.setLayerSquashingEnabled(false);
</script>
</head>
<body>
<div class="container">
<div class="composited box behind"></div>
<div class="box middle"></div>
</div>
<div class="box middle2"></div>
<div class="box top"></div>
</body>
<!DOCTYPE html>
<head>
<style>
.composited {
-webkit-transform: translatez(0);
}
.box {
width: 100px;
height: 100px;
}
.behind {
position: absolute;
z-index: 1;
top: 100px;
left: 100px;
background-color: blue;
}
.middle {
position: absolute;
z-index: 1;
top: 15px;
left: 15px;
background-color: lime;
}
.middle2 {
position: absolute;
z-index: 1;
top: 130.5px;
left: 60px;
background-color: magenta;
}
.top {
position: absolute;
z-index: 1;
top: 70.5px;
left: 120px;
background-color: cyan;
}
.container {
position: absolute;
z-index: 1;
top: 25.5px;
left: 25px;
width: 300px;
height: 300px;
background-color: gray;
}
div:hover {
background-color: green;
}
</style>
<script>
if (window.internals)
internals.settings.setLayerSquashingEnabled(true);
</script>
</head>
<body>
<div class="container">
<div class="composited box behind"></div>
<div class="box middle"></div>
</div>
<div class="box middle2"></div>
<div class="box top"></div>
</body>
<!DOCTYPE html>
<head>
<style>
.composited {
-webkit-transform: translatez(0);
}
.box {
width: 100px;
height: 100.5px;
}
.behind {
position: absolute;
z-index: 1;
top: 100px;
left: 100px;
background-color: blue;
}
.middle {
position: absolute;
z-index: 1;
top: 15px;
left: 15px;
background-color: lime;
}
.middle2 {
position: absolute;
z-index: 1;
top: 130.5px;
left: 60px;
background-color: magenta;
}
.top {
position: absolute;
z-index: 1;
top: 70.5px;
left: 120px;
background-color: cyan;
}
.container {
position: absolute;
z-index: 1;
top: 25.5px;
left: 25px;
width: 300px;
height: 300px;
background-color: gray;
}
div:hover {
background-color: green;
}
</style>
<script>
if (window.internals)
internals.settings.setLayerSquashingEnabled(false);
</script>
</head>
<body>
<div class="container">
<div class="composited box behind"></div>
<div class="box middle"></div>
</div>
<div class="box middle2"></div>
<div class="box top"></div>
</body>
<!DOCTYPE html>
<head>
<style>
.composited {
-webkit-transform: translatez(0);
}
.box {
width: 100px;
height: 100.5px;
}
.behind {
position: absolute;
z-index: 1;
top: 100px;
left: 100px;
background-color: blue;
}
.middle {
position: absolute;
z-index: 1;
top: 15px;
left: 15px;
background-color: lime;
}
.middle2 {
position: absolute;
z-index: 1;
top: 130.5px;
left: 60px;
background-color: magenta;
}
.top {
position: absolute;
z-index: 1;
top: 70.5px;
left: 120px;
background-color: cyan;
}
.container {
position: absolute;
z-index: 1;
top: 25.5px;
left: 25px;
width: 300px;
height: 300px;
background-color: gray;
}
div:hover {
background-color: green;
}
</style>
<script>
if (window.internals)
internals.settings.setLayerSquashingEnabled(true);
</script>
</head>
<body>
<div class="container">
<div class="composited box behind"></div>
<div class="box middle"></div>
</div>
<div class="box middle2"></div>
<div class="box top"></div>
</body>
<!DOCTYPE html>
<head>
<style>
.composited {
-webkit-transform: translatez(0);
}
.box {
width: 100px;
height: 100px;
}
.behind {
position: absolute;
z-index: 1;
top: 100.5px;
left: 100px;
background-color: blue;
}
.middle {
position: absolute;
z-index: 1;
top: 15.5px;
left: 15px;
background-color: lime;
}
.middle2 {
position: absolute;
z-index: 1;
top: 130.5px;
left: 60px;
background-color: magenta;
}
.top {
position: absolute;
z-index: 1;
top: 70.5px;
left: 120px;
background-color: cyan;
}
.container {
position: absolute;
z-index: 1;
top: 25px;
left: 25px;
width: 300px;
height: 300px;
background-color: gray;
}
div:hover {
background-color: green;
}
</style>
<script>
if (window.internals)
internals.settings.setLayerSquashingEnabled(false);
</script>
</head>
<body>
<div class="container">
<div class="composited box behind"></div>
<div class="box middle"></div>
</div>
<div class="box middle2"></div>
<div class="box top"></div>
</body>
<!DOCTYPE html>
<head>
<style>
.composited {
-webkit-transform: translatez(0);
}
.box {
width: 100px;
height: 100px;
}
.behind {
position: absolute;
z-index: 1;
top: 100.5px;
left: 100px;
background-color: blue;
}
.middle {
position: absolute;
z-index: 1;
top: 15.5px;
left: 15px;
background-color: lime;
}
.middle2 {
position: absolute;
z-index: 1;
top: 130.5px;
left: 60px;
background-color: magenta;
}
.top {
position: absolute;
z-index: 1;
top: 70.5px;
left: 120px;
background-color: cyan;
}
.container {
position: absolute;
z-index: 1;
top: 25px;
left: 25px;
width: 300px;
height: 300px;
background-color: gray;
}
div:hover {
background-color: green;
}
</style>
<script>
if (window.internals)
internals.settings.setLayerSquashingEnabled(true);
</script>
</head>
<body>
<div class="container">
<div class="composited box behind"></div>
<div class="box middle"></div>
</div>
<div class="box middle2"></div>
<div class="box top"></div>
</body>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
) )
(GraphicsLayer (GraphicsLayer
(position -1.00 -1.00) (position -1.00 -1.00)
(bounds 280.72 280.72) (bounds 281.00 281.00)
(drawsContent 1) (drawsContent 1)
) )
) )
......
...@@ -18,7 +18,7 @@ CASE 1, original layer tree ...@@ -18,7 +18,7 @@ CASE 1, original layer tree
) )
(GraphicsLayer (GraphicsLayer
(position -1.00 -1.00) (position -1.00 -1.00)
(bounds 280.72 280.72) (bounds 281.00 281.00)
(drawsContent 1) (drawsContent 1)
) )
) )
...@@ -47,12 +47,12 @@ CASE 2, hovering over the outer div ...@@ -47,12 +47,12 @@ CASE 2, hovering over the outer div
) )
(GraphicsLayer (GraphicsLayer
(position -1.00 -1.00) (position -1.00 -1.00)
(bounds 280.72 280.72) (bounds 281.00 281.00)
(drawsContent 1) (drawsContent 1)
(repaint rects (repaint rects
(rect 0.00 0.00 141.00 141.00) (rect 0.00 0.00 142.00 142.00)
(rect 0.00 0.00 141.00 141.00) (rect 0.00 0.00 142.00 142.00)
(rect 0.00 0.00 141.00 141.00) (rect 0.00 0.00 142.00 142.00)
) )
) )
) )
...@@ -81,15 +81,15 @@ CASE 3, hovering over the inner div ...@@ -81,15 +81,15 @@ CASE 3, hovering over the inner div
) )
(GraphicsLayer (GraphicsLayer
(position -1.00 -1.00) (position -1.00 -1.00)
(bounds 280.72 280.72) (bounds 281.00 281.00)
(drawsContent 1) (drawsContent 1)
(repaint rects (repaint rects
(rect 0.00 0.00 141.00 141.00) (rect 0.00 0.00 142.00 142.00)
(rect 0.00 0.00 141.00 141.00) (rect 0.00 0.00 142.00 142.00)
(rect 0.00 0.00 141.00 141.00) (rect 0.00 0.00 142.00 142.00)
(rect 31.00 31.00 71.00 71.00) (rect 32.00 32.00 71.00 71.00)
(rect 31.00 31.00 71.00 71.00) (rect 32.00 32.00 71.00 71.00)
(rect 31.00 31.00 71.00 71.00) (rect 32.00 32.00 71.00 71.00)
) )
) )
) )
......
...@@ -17,8 +17,8 @@ CASE 1, original layer tree ...@@ -17,8 +17,8 @@ CASE 1, original layer tree
(backgroundColor #0000FF) (backgroundColor #0000FF)
) )
(GraphicsLayer (GraphicsLayer
(position 5.00 5.00) (position 4.00 4.00)
(bounds 275.09 275.09) (bounds 276.00 276.00)
(drawsContent 1) (drawsContent 1)
) )
) )
...@@ -46,13 +46,13 @@ CASE 2, hovering over the outer div ...@@ -46,13 +46,13 @@ CASE 2, hovering over the outer div
(backgroundColor #0000FF) (backgroundColor #0000FF)
) )
(GraphicsLayer (GraphicsLayer
(position 5.00 5.00) (position 4.00 4.00)
(bounds 275.09 275.09) (bounds 276.00 276.00)
(drawsContent 1) (drawsContent 1)
(repaint rects (repaint rects
(rect 0.00 0.00 131.00 131.00) (rect 0.00 0.00 132.00 132.00)
(rect 0.00 0.00 131.00 131.00) (rect 0.00 0.00 132.00 132.00)
(rect 0.00 0.00 131.00 131.00) (rect 0.00 0.00 132.00 132.00)
) )
) )
) )
...@@ -80,16 +80,16 @@ CASE 3, hovering over the inner div ...@@ -80,16 +80,16 @@ CASE 3, hovering over the inner div
(backgroundColor #0000FF) (backgroundColor #0000FF)
) )
(GraphicsLayer (GraphicsLayer
(position 5.00 5.00) (position 4.00 4.00)
(bounds 275.09 275.09) (bounds 276.00 276.00)
(drawsContent 1) (drawsContent 1)
(repaint rects (repaint rects
(rect 0.00 0.00 131.00 131.00) (rect 0.00 0.00 132.00 132.00)
(rect 0.00 0.00 131.00 131.00) (rect 0.00 0.00 132.00 132.00)
(rect 0.00 0.00 131.00 131.00) (rect 0.00 0.00 132.00 132.00)
(rect 17.00 20.00 87.00 87.00) (rect 18.00 21.00 87.00 87.00)
(rect 17.00 20.00 87.00 87.00) (rect 18.00 21.00 87.00 87.00)
(rect 17.00 20.00 87.00 87.00) (rect 18.00 21.00 87.00 87.00)
) )
) )
) )
......
...@@ -561,13 +561,19 @@ static IntRect clipBox(RenderBox* renderer) ...@@ -561,13 +561,19 @@ static IntRect clipBox(RenderBox* renderer)
return pixelSnappedIntRect(result); return pixelSnappedIntRect(result);
} }
static LayoutPoint computeOffsetFromCompositedAncestor(const RenderLayer* layer, const RenderLayer* compositedAncestor)
{
LayoutPoint offset;
layer->convertToLayerCoords(compositedAncestor, offset);
if (compositedAncestor)
offset.move(compositedAncestor->compositedLayerMapping()->subpixelAccumulation());
return offset;
}
void CompositedLayerMapping::adjustBoundsForSubPixelAccumulation(const RenderLayer* compositedAncestor, IntRect& localBounds, IntRect& relativeBounds, IntPoint& delta) void CompositedLayerMapping::adjustBoundsForSubPixelAccumulation(const RenderLayer* compositedAncestor, IntRect& localBounds, IntRect& relativeBounds, IntPoint& delta)
{ {
LayoutRect localRawCompositingBounds = compositedBounds(); LayoutRect localRawCompositingBounds = compositedBounds();
LayoutPoint rawDelta; LayoutPoint rawDelta = computeOffsetFromCompositedAncestor(&m_owningLayer, compositedAncestor);
m_owningLayer.convertToLayerCoords(compositedAncestor, rawDelta);
if (compositedAncestor)
rawDelta.move(compositedAncestor->compositedLayerMapping()->subpixelAccumulation());
delta = flooredIntPoint(rawDelta); delta = flooredIntPoint(rawDelta);
m_subpixelAccumulation = toLayoutSize(rawDelta).fraction(); m_subpixelAccumulation = toLayoutSize(rawDelta).fraction();
RELEASE_ASSERT(m_subpixelAccumulation.width() < 1 && m_subpixelAccumulation.height() < 1); RELEASE_ASSERT(m_subpixelAccumulation.width() < 1 && m_subpixelAccumulation.height() < 1);
...@@ -600,13 +606,16 @@ void CompositedLayerMapping::updateSquashingLayerGeometry(const IntPoint& delta) ...@@ -600,13 +606,16 @@ void CompositedLayerMapping::updateSquashingLayerGeometry(const IntPoint& delta)
// The totalSquashBounds is positioned with respect to m_owningLayer of this CompositedLayerMapping. // The totalSquashBounds is positioned with respect to m_owningLayer of this CompositedLayerMapping.
// But the squashingLayer needs to be positioned with respect to the ancestor CompositedLayerMapping. // But the squashingLayer needs to be positioned with respect to the ancestor CompositedLayerMapping.
// The conversion between m_owningLayer and the ancestor CLM is already computed in the caller as |delta|. // The conversion between m_owningLayer and the ancestor CLM is already computed in the caller as
// FIXME: probably not the right place to round from LayoutPoint to IntPoint? // |delta| + |m_subpixelAccumulation|.
IntPoint squashLayerPosition = pixelSnappedIntRect(totalSquashBounds).location(); LayoutPoint rawDelta = delta + m_subpixelAccumulation;
squashLayerPosition.moveBy(delta); totalSquashBounds.moveBy(rawDelta);
IntRect squashLayerBounds = enclosingIntRect(totalSquashBounds);
IntPoint squashLayerOrigin = squashLayerBounds.location();
LayoutPoint squashLayerOriginInOwningLayerSpace = LayoutPoint(squashLayerOrigin - rawDelta);
m_squashingLayer->setPosition(squashLayerPosition); m_squashingLayer->setPosition(squashLayerBounds.location());
m_squashingLayer->setSize(totalSquashBounds.size()); m_squashingLayer->setSize(squashLayerBounds.size());
// Now that the squashing bounds are known, we can convert the RenderLayer painting offsets // Now that the squashing bounds are known, we can convert the RenderLayer painting offsets
// from CLM owning layer space to the squashing layer space. // from CLM owning layer space to the squashing layer space.
...@@ -615,11 +624,15 @@ void CompositedLayerMapping::updateSquashingLayerGeometry(const IntPoint& delta) ...@@ -615,11 +624,15 @@ void CompositedLayerMapping::updateSquashingLayerGeometry(const IntPoint& delta)
// the squashed RenderLayer described w.r.t. m_squashingLayer's origin. For this purpose we already cached // the squashed RenderLayer described w.r.t. m_squashingLayer's origin. For this purpose we already cached
// offsetFromSquashingCLM before, which describes where the squashed RenderLayer is located w.r.t. // offsetFromSquashingCLM before, which describes where the squashed RenderLayer is located w.r.t.
// m_owningLayer. So we just need to convert that point from m_owningLayer space to m_squashingLayer // m_owningLayer. So we just need to convert that point from m_owningLayer space to m_squashingLayer
// space. This is simply done by subtracing totalSquashBounds... but then the offset overall needs to be // space. This is simply done by subtracing squashLayerOriginInOwningLayerSpace, but then the offset
// negated because that's the direction that the painting code expects the offset to be. // overall needs to be negated because that's the direction that the painting code expects the
// offset to be.
for (size_t i = 0; i < m_squashedLayers.size(); ++i) { for (size_t i = 0; i < m_squashedLayers.size(); ++i) {
m_squashedLayers[i].offsetFromRenderer = IntSize(-m_squashedLayers[i].offsetFromSquashingCLM.width() + totalSquashBounds.x(), LayoutSize offsetFromSquashLayerOrigin = LayoutPoint(m_squashedLayers[i].offsetFromSquashingCLM) - squashLayerOriginInOwningLayerSpace;
-m_squashedLayers[i].offsetFromSquashingCLM.height() + totalSquashBounds.y()); m_squashedLayers[i].offsetFromRenderer = -flooredIntSize(offsetFromSquashLayerOrigin);
m_squashedLayers[i].subpixelAccumulation = offsetFromSquashLayerOrigin.fraction();
ASSERT(m_squashedLayers[i].subpixelAccumulation ==
toLayoutSize(computeOffsetFromCompositedAncestor(m_squashedLayers[i].renderLayer, m_squashedLayers[i].renderLayer->ancestorCompositingLayer())).fraction());
// FIXME: find a better design to avoid this redundant value - most likely it will make // FIXME: find a better design to avoid this redundant value - most likely it will make
// sense to move the paint task info into RenderLayer's m_compositingProperties. // sense to move the paint task info into RenderLayer's m_compositingProperties.
...@@ -1903,10 +1916,10 @@ void CompositedLayerMapping::doPaintTask(GraphicsLayerPaintInfo& paintInfo, Grap ...@@ -1903,10 +1916,10 @@ void CompositedLayerMapping::doPaintTask(GraphicsLayerPaintInfo& paintInfo, Grap
if (!(paintInfo.paintingPhase & GraphicsLayerPaintOverflowContents)) { if (!(paintInfo.paintingPhase & GraphicsLayerPaintOverflowContents)) {
LayoutRect bounds = paintInfo.compositedBounds; LayoutRect bounds = paintInfo.compositedBounds;
bounds.move(m_subpixelAccumulation); bounds.move(paintInfo.subpixelAccumulation);
dirtyRect.intersect(pixelSnappedIntRect(bounds)); dirtyRect.intersect(pixelSnappedIntRect(bounds));
} else { } else {
dirtyRect.move(roundedIntSize(m_subpixelAccumulation)); dirtyRect.move(roundedIntSize(paintInfo.subpixelAccumulation));
} }
#ifndef NDEBUG #ifndef NDEBUG
...@@ -1915,7 +1928,7 @@ void CompositedLayerMapping::doPaintTask(GraphicsLayerPaintInfo& paintInfo, Grap ...@@ -1915,7 +1928,7 @@ void CompositedLayerMapping::doPaintTask(GraphicsLayerPaintInfo& paintInfo, Grap
if (paintInfo.renderLayer->compositingState() != PaintsIntoGroupedBacking) { if (paintInfo.renderLayer->compositingState() != PaintsIntoGroupedBacking) {
// FIXME: GraphicsLayers need a way to split for RenderRegions. // FIXME: GraphicsLayers need a way to split for RenderRegions.
LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBehaviorNormal, m_subpixelAccumulation); LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBehaviorNormal, paintInfo.subpixelAccumulation);
paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFlags); paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFlags);
ASSERT(!paintInfo.isBackgroundLayer || paintFlags & PaintLayerPaintingRootBackgroundOnly); ASSERT(!paintInfo.isBackgroundLayer || paintFlags & PaintLayerPaintingRootBackgroundOnly);
...@@ -1924,7 +1937,7 @@ void CompositedLayerMapping::doPaintTask(GraphicsLayerPaintInfo& paintInfo, Grap ...@@ -1924,7 +1937,7 @@ void CompositedLayerMapping::doPaintTask(GraphicsLayerPaintInfo& paintInfo, Grap
paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFlags | PaintLayerPaintingOverlayScrollbars); paintInfo.renderLayer->paintLayerContents(context, paintingInfo, paintFlags | PaintLayerPaintingOverlayScrollbars);
} else { } else {
ASSERT(compositor()->layerSquashingEnabled()); ASSERT(compositor()->layerSquashingEnabled());
LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBehaviorNormal, LayoutSize()); LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBehaviorNormal, paintInfo.subpixelAccumulation);
paintInfo.renderLayer->paintLayer(context, paintingInfo, paintFlags); paintInfo.renderLayer->paintLayer(context, paintingInfo, paintFlags);
} }
...@@ -1973,6 +1986,7 @@ void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G ...@@ -1973,6 +1986,7 @@ void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G
paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer(); paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer();
paintInfo.paintingPhase = paintingPhase; paintInfo.paintingPhase = paintingPhase;
paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer); paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer);
paintInfo.subpixelAccumulation = m_subpixelAccumulation;
// We have to use the same root as for hit testing, because both methods can compute and cache clipRects. // We have to use the same root as for hit testing, because both methods can compute and cache clipRects.
doPaintTask(paintInfo, &context, clip); doPaintTask(paintInfo, &context, clip);
...@@ -2044,7 +2058,7 @@ void CompositedLayerMapping::setCompositedBounds(const LayoutRect& bounds) ...@@ -2044,7 +2058,7 @@ void CompositedLayerMapping::setCompositedBounds(const LayoutRect& bounds)
m_compositedBounds = bounds; m_compositedBounds = bounds;
} }
bool CompositedLayerMapping::updateSquashingLayerAssignment(RenderLayer* layer, IntSize offsetFromSquashingCLM, size_t nextSquashedLayerIndex) bool CompositedLayerMapping::updateSquashingLayerAssignment(RenderLayer* layer, LayoutSize offsetFromSquashingCLM, size_t nextSquashedLayerIndex)
{ {
ASSERT(compositor()->layerSquashingEnabled()); ASSERT(compositor()->layerSquashingEnabled());
......
...@@ -49,10 +49,11 @@ struct GraphicsLayerPaintInfo { ...@@ -49,10 +49,11 @@ struct GraphicsLayerPaintInfo {
// an intermediate offset for a squashed RenderLayer, described with respect to the CompositedLayerMapping's // an intermediate offset for a squashed RenderLayer, described with respect to the CompositedLayerMapping's
// owning layer that would eventually have the m_squashingLayer. Once the shared GraphicsLayer's bounds are // owning layer that would eventually have the m_squashingLayer. Once the shared GraphicsLayer's bounds are
// known, then we can trivially convert this offset to m_squashingLayer's space. // known, then we can trivially convert this offset to m_squashingLayer's space.
IntSize offsetFromSquashingCLM; LayoutSize offsetFromSquashingCLM;
// Offset describing where this squashed RenderLayer paints into the shared GraphicsLayer backing. // Offset describing where this squashed RenderLayer paints into the shared GraphicsLayer backing.
IntSize offsetFromRenderer; IntSize offsetFromRenderer;
LayoutSize subpixelAccumulation;
GraphicsLayerPaintingPhase paintingPhase; GraphicsLayerPaintingPhase paintingPhase;
...@@ -167,7 +168,7 @@ public: ...@@ -167,7 +168,7 @@ public:
bool hasUnpositionedOverflowControlsLayers() const; bool hasUnpositionedOverflowControlsLayers() const;
// Returns true if the assignment actually changed the assigned squashing layer. // Returns true if the assignment actually changed the assigned squashing layer.
bool updateSquashingLayerAssignment(RenderLayer*, IntSize offsetFromSquashingCLM, size_t nextSquashedLayerIndex); bool updateSquashingLayerAssignment(RenderLayer*, LayoutSize offsetFromSquashingCLM, size_t nextSquashedLayerIndex);
void removeRenderLayerFromSquashingGraphicsLayer(const RenderLayer*); void removeRenderLayerFromSquashingGraphicsLayer(const RenderLayer*);
void finishAccumulatingSquashingLayers(size_t nextSquashedLayerIndex); void finishAccumulatingSquashingLayers(size_t nextSquashedLayerIndex);
......
...@@ -648,12 +648,12 @@ bool RenderLayerCompositor::allocateOrClearCompositedLayerMapping(RenderLayer* l ...@@ -648,12 +648,12 @@ bool RenderLayerCompositor::allocateOrClearCompositedLayerMapping(RenderLayer* l
return compositedLayerMappingChanged || nonCompositedReasonChanged; return compositedLayerMappingChanged || nonCompositedReasonChanged;
} }
static IntPoint computeOffsetFromAbsolute(RenderLayer* layer) static LayoutPoint computeOffsetFromAbsolute(RenderLayer* layer)
{ {
TransformState transformState(TransformState::ApplyTransformDirection, FloatPoint()); TransformState transformState(TransformState::ApplyTransformDirection, FloatPoint());
layer->renderer()->mapLocalToContainer(0, transformState, ApplyContainerFlip); layer->renderer()->mapLocalToContainer(0, transformState, ApplyContainerFlip);
transformState.flatten(); transformState.flatten();
return roundedIntPoint(transformState.lastPlanarPoint()); return LayoutPoint(transformState.lastPlanarPoint());
} }
bool RenderLayerCompositor::updateSquashingAssignment(RenderLayer* layer, SquashingState& squashingState, const CompositingStateTransitionType compositedLayerUpdate) bool RenderLayerCompositor::updateSquashingAssignment(RenderLayer* layer, SquashingState& squashingState, const CompositingStateTransitionType compositedLayerUpdate)
...@@ -668,9 +668,9 @@ bool RenderLayerCompositor::updateSquashingAssignment(RenderLayer* layer, Squash ...@@ -668,9 +668,9 @@ bool RenderLayerCompositor::updateSquashingAssignment(RenderLayer* layer, Squash
ASSERT(!layer->hasCompositedLayerMapping()); ASSERT(!layer->hasCompositedLayerMapping());
ASSERT(squashingState.hasMostRecentMapping); ASSERT(squashingState.hasMostRecentMapping);
IntPoint offsetFromAbsoluteForSquashedLayer = computeOffsetFromAbsolute(layer); LayoutPoint offsetFromAbsoluteForSquashedLayer = computeOffsetFromAbsolute(layer);
IntSize offsetFromSquashingCLM(offsetFromAbsoluteForSquashedLayer.x() - squashingState.offsetFromAbsoluteForSquashingCLM.x(), LayoutSize offsetFromSquashingCLM(offsetFromAbsoluteForSquashedLayer.x() - squashingState.offsetFromAbsoluteForSquashingCLM.x(),
offsetFromAbsoluteForSquashedLayer.y() - squashingState.offsetFromAbsoluteForSquashingCLM.y()); offsetFromAbsoluteForSquashedLayer.y() - squashingState.offsetFromAbsoluteForSquashingCLM.y());
bool changedSquashingLayer = bool changedSquashingLayer =
...@@ -1138,7 +1138,7 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* ancestor ...@@ -1138,7 +1138,7 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* ancestor
overlapMap->geometryMap().popMappingsToAncestor(ancestorLayer); overlapMap->geometryMap().popMappingsToAncestor(ancestorLayer);
} }
void RenderLayerCompositor::SquashingState::updateSquashingStateForNewMapping(CompositedLayerMappingPtr newCompositedLayerMapping, bool hasNewCompositedLayerMapping, IntPoint newOffsetFromAbsoluteForSquashingCLM, RenderLayer* newClippingAncestorForMostRecentMapping) void RenderLayerCompositor::SquashingState::updateSquashingStateForNewMapping(CompositedLayerMappingPtr newCompositedLayerMapping, bool hasNewCompositedLayerMapping, LayoutPoint newOffsetFromAbsoluteForSquashingCLM, RenderLayer* newClippingAncestorForMostRecentMapping)
{ {
// The most recent backing is done accumulating any more squashing layers. // The most recent backing is done accumulating any more squashing layers.
if (hasMostRecentMapping) if (hasMostRecentMapping)
...@@ -1205,7 +1205,7 @@ void RenderLayerCompositor::assignLayersToBackingsInternal(RenderLayer* layer, S ...@@ -1205,7 +1205,7 @@ void RenderLayerCompositor::assignLayersToBackingsInternal(RenderLayer* layer, S
// At this point, if the layer is to be "separately" composited, then its backing becomes the most recent in paint-order. // At this point, if the layer is to be "separately" composited, then its backing becomes the most recent in paint-order.
if (layer->compositingState() == PaintsIntoOwnBacking || layer->compositingState() == HasOwnBackingButPaintsIntoAncestor) { if (layer->compositingState() == PaintsIntoOwnBacking || layer->compositingState() == HasOwnBackingButPaintsIntoAncestor) {
ASSERT(!requiresSquashing(layer->compositingReasons())); ASSERT(!requiresSquashing(layer->compositingReasons()));
IntPoint offsetFromAbsoluteForSquashingCLM = computeOffsetFromAbsolute(layer); LayoutPoint offsetFromAbsoluteForSquashingCLM = computeOffsetFromAbsolute(layer);
squashingState.updateSquashingStateForNewMapping(layer->compositedLayerMapping(), layer->hasCompositedLayerMapping(), offsetFromAbsoluteForSquashingCLM, clippingAncestor); squashingState.updateSquashingStateForNewMapping(layer->compositedLayerMapping(), layer->hasCompositedLayerMapping(), offsetFromAbsoluteForSquashingCLM, clippingAncestor);
} }
} }
......
...@@ -217,7 +217,7 @@ private: ...@@ -217,7 +217,7 @@ private:
, nextSquashedLayerIndex(0) , nextSquashedLayerIndex(0)
, clippingAncestorForMostRecentMapping(0) { } , clippingAncestorForMostRecentMapping(0) { }
void updateSquashingStateForNewMapping(CompositedLayerMappingPtr, bool hasNewCompositedLayerMapping, IntPoint newOffsetFromAbsoluteForSquashingCLM, RenderLayer* clippingAncestorForMostRecentMapping); void updateSquashingStateForNewMapping(CompositedLayerMappingPtr, bool hasNewCompositedLayerMapping, LayoutPoint newOffsetFromAbsoluteForSquashingCLM, RenderLayer* clippingAncestorForMostRecentMapping);
// The most recent composited backing that the layer should squash onto if needed. // The most recent composited backing that the layer should squash onto if needed.
CompositedLayerMappingPtr mostRecentMapping; CompositedLayerMappingPtr mostRecentMapping;
...@@ -225,7 +225,7 @@ private: ...@@ -225,7 +225,7 @@ private:
// Absolute coordinates of the compositedLayerMapping's owning layer. This is used for computing the correct // Absolute coordinates of the compositedLayerMapping's owning layer. This is used for computing the correct
// positions of renderlayers when they paint into the squashing layer. // positions of renderlayers when they paint into the squashing layer.
IntPoint offsetFromAbsoluteForSquashingCLM; LayoutPoint offsetFromAbsoluteForSquashingCLM;
// Counter that tracks what index the next RenderLayer would be if it gets squashed to the current squashing layer. // Counter that tracks what index the next RenderLayer would be if it gets squashed to the current squashing layer.
size_t nextSquashedLayerIndex; size_t nextSquashedLayerIndex;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment