Commit 65189942 authored by leviw@chromium.org's avatar leviw@chromium.org

Fix pixel snapping of clipLayers and their descendants

Hopefully the last in a line of compositing sub-pixel
patches. This correctly pixel snaps the clipping layer
used by composited layers with overflow: clip and
accumulates it into their children.

BUG=347521

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

git-svn-id: svn://svn.chromium.org/blink/trunk@169624 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 716859c5
...@@ -31,11 +31,9 @@ filter change with non-composited child ...@@ -31,11 +31,9 @@ filter change with non-composited child
(bounds 100.00 100.00) (bounds 100.00 100.00)
(children 1 (children 1
(GraphicsLayer (GraphicsLayer
(position 0.00 -1.00)
(bounds 100.00 100.00) (bounds 100.00 100.00)
(children 1 (children 1
(GraphicsLayer (GraphicsLayer
(position 0.00 1.00)
(bounds 152.00 152.00) (bounds 152.00 152.00)
(contentsOpaque 1) (contentsOpaque 1)
(drawsContent 1) (drawsContent 1)
...@@ -116,11 +114,9 @@ filter change with non-composited child ...@@ -116,11 +114,9 @@ filter change with non-composited child
) )
(children 1 (children 1
(GraphicsLayer (GraphicsLayer
(position 0.00 -1.00)
(bounds 100.00 100.00) (bounds 100.00 100.00)
(children 1 (children 1
(GraphicsLayer (GraphicsLayer
(position 0.00 1.00)
(bounds 152.00 152.00) (bounds 152.00 152.00)
(contentsOpaque 1) (contentsOpaque 1)
(drawsContent 1) (drawsContent 1)
...@@ -143,11 +139,9 @@ filter change with non-composited child ...@@ -143,11 +139,9 @@ filter change with non-composited child
(bounds 100.00 100.00) (bounds 100.00 100.00)
(children 1 (children 1
(GraphicsLayer (GraphicsLayer
(position 0.00 -1.00)
(bounds 100.00 100.00) (bounds 100.00 100.00)
(children 1 (children 1
(GraphicsLayer (GraphicsLayer
(position 0.00 1.00)
(bounds 152.00 152.00) (bounds 152.00 152.00)
(contentsOpaque 1) (contentsOpaque 1)
(drawsContent 1) (drawsContent 1)
......
...@@ -2,14 +2,17 @@ ...@@ -2,14 +2,17 @@
<html> <html>
<head> <head>
<style> <style>
#subPixelContainer { .subPixelContainer {
left: 10.5px; left: 10.5px;
width: 100px; width: 100px;
height: 100px; height: 100px;
position: relative; position: relative;
-webkit-transform: translateZ(0); -webkit-transform: translateZ(0);
} }
#ref { .overflowHidden {
overflow: hidden;
}
.ref {
position: absolute; position: absolute;
width: 50.5px; width: 50.5px;
right: 0px; right: 0px;
...@@ -20,6 +23,9 @@ ...@@ -20,6 +23,9 @@
</head> </head>
<body> <body>
<div>This tests that sub-pixel offsets in nested composited layers are properly accumulated. You should see no red.</div> <div>This tests that sub-pixel offsets in nested composited layers are properly accumulated. You should see no red.</div>
<div id="subPixelContainer"> <div class="subPixelContainer">
<div id="ref"></div> <div class="ref"></div>
</div>
<div class="subPixelContainer overflowHidden">
<div class="ref"></div>
</div> </div>
...@@ -2,31 +2,38 @@ ...@@ -2,31 +2,38 @@
<html> <html>
<head> <head>
<style> <style>
#subPixelContainer { .subPixelContainer {
left: 10.5px; left: 10.5px;
width: 100px; width: 100px;
height: 100px; height: 100px;
position: relative; position: relative;
-webkit-transform: translateZ(0); -webkit-transform: translateZ(0);
} }
#subPixelContainer > div { .subPixelContainer > div {
position: absolute; position: absolute;
width: 50.5px; width: 50.5px;
right: 0px; right: 0px;
height: 50px; height: 50px;
} }
#test { .overflowHidden {
overflow: hidden;
}
.test {
-webkit-transform: translateZ(0); -webkit-transform: translateZ(0);
background-color: green; background-color: green;
} }
#ref { .ref {
background-color: red; background-color: red;
} }
</style> </style>
</head> </head>
<body> <body>
<div>This tests that sub-pixel offsets in nested composited layers are properly accumulated. You should see no red.</div> <div>This tests that sub-pixel offsets in nested composited layers are properly accumulated. You should see no red.</div>
<div id="subPixelContainer"> <div class="subPixelContainer">
<div id="ref"></div> <div class="ref"></div>
<div id="test"></div> <div class="test"></div>
</div>
<div class="subPixelContainer overflowHidden">
<div class="ref"></div>
<div class="test"></div>
</div> </div>
...@@ -696,7 +696,7 @@ GraphicsLayerUpdater::UpdateType CompositedLayerMapping::updateGraphicsLayerGeom ...@@ -696,7 +696,7 @@ GraphicsLayerUpdater::UpdateType CompositedLayerMapping::updateGraphicsLayerGeom
// If the compositing ancestor has a layer to clip children, we parent in that, and therefore // If the compositing ancestor has a layer to clip children, we parent in that, and therefore
// position relative to it. // position relative to it.
IntRect clippingBox = clipBox(toRenderBox(compAncestor->renderer())); IntRect clippingBox = clipBox(toRenderBox(compAncestor->renderer()));
graphicsLayerParentLocation = clippingBox.location(); graphicsLayerParentLocation = clippingBox.location() + roundedIntSize(compAncestor->compositedLayerMapping()->subpixelAccumulation());
} else if (compAncestor) { } else if (compAncestor) {
graphicsLayerParentLocation = ancestorCompositingBounds.location(); graphicsLayerParentLocation = ancestorCompositingBounds.location();
} else { } else {
...@@ -737,7 +737,7 @@ GraphicsLayerUpdater::UpdateType CompositedLayerMapping::updateGraphicsLayerGeom ...@@ -737,7 +737,7 @@ GraphicsLayerUpdater::UpdateType CompositedLayerMapping::updateGraphicsLayerGeom
IntRect clippingBox; IntRect clippingBox;
if (GraphicsLayer* clipLayer = clippingLayer()) { if (GraphicsLayer* clipLayer = clippingLayer()) {
clippingBox = clipBox(toRenderBox(renderer())); clippingBox = clipBox(toRenderBox(renderer()));
clipLayer->setPosition(FloatPoint(clippingBox.location() - localCompositingBounds.location())); clipLayer->setPosition(FloatPoint(clippingBox.location() - localCompositingBounds.location() + roundedIntSize(m_subpixelAccumulation)));
clipLayer->setSize(clippingBox.size()); clipLayer->setSize(clippingBox.size());
clipLayer->setOffsetFromRenderer(toIntSize(clippingBox.location())); clipLayer->setOffsetFromRenderer(toIntSize(clippingBox.location()));
if (m_childClippingMaskLayer && !m_scrollingLayer) { if (m_childClippingMaskLayer && !m_scrollingLayer) {
......
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