Commit 7c9c5a1f authored by chrishtr@chromium.org's avatar chrishtr@chromium.org

Don't add subpixel accumulations for squashed layers when invalidating them.

Also clean up the code related to squashing in CompositedLayerMapping a little bit.

BUG=417994

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

git-svn-id: svn://svn.chromium.org/blink/trunk@183703 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 5788b56f
{
"bounds": [800, 600],
"children": [
{
"bounds": [800, 600],
"contentsOpaque": true,
"drawsContent": true,
"children": [
{
"shouldFlattenTransform": false,
"children": [
{
"position": [8, 8],
"bounds": [200, 200],
"contentsOpaque": true,
"drawsContent": true,
"backgroundColor": "#D3D3D3"
},
{
"position": [50, 50],
"bounds": [251, 251],
"drawsContent": true,
"repaintRects": [
[50, 50, 200, 200]
]
}
]
}
]
}
]
}
<!DOCTYPE html>
<div style="position: absolute; width: 200px; height: 200px; background: lightgray; will-change: transform"></div>
<div style="position: absolute; width: 200px; height: 200px; top: 50px; left: 50px; background: lightblue"></div>
<div id="target" style="position: absolute; width: 200px; height: 200px; top: 100.45px; left: 100.45px; background: papayawhip"></div>
<script src="../../fast/repaint/resources/text-based-repaint.js"></script>
<script>
if (window.internals)
internals.settings.setLayerSquashingEnabled(true);
function repaintTest() {
target.style.backgroundColor = 'red';
}
runRepaintTest();
</script>
\ No newline at end of file
...@@ -201,9 +201,10 @@ void RenderLayerModelObject::setBackingNeedsPaintInvalidationInRect(const Layout ...@@ -201,9 +201,10 @@ void RenderLayerModelObject::setBackingNeedsPaintInvalidationInRect(const Layout
// FIXME: generalize accessors to backing GraphicsLayers so that this code is squashing-agnostic. // FIXME: generalize accessors to backing GraphicsLayers so that this code is squashing-agnostic.
if (layer()->groupedMapping()) { if (layer()->groupedMapping()) {
LayoutRect paintInvalidationRect = r; LayoutRect paintInvalidationRect = r;
paintInvalidationRect.move(layer()->subpixelAccumulation()); if (GraphicsLayer* squashingLayer = layer()->groupedMapping()->squashingLayer()) {
if (GraphicsLayer* squashingLayer = layer()->groupedMapping()->squashingLayer()) // Note: the subpixel accumulation of layer() does not need to be added here. It is already taken into account.
squashingLayer->setNeedsDisplayInRect(pixelSnappedIntRect(paintInvalidationRect), invalidationReason); squashingLayer->setNeedsDisplayInRect(pixelSnappedIntRect(paintInvalidationRect), invalidationReason);
}
} else { } else {
layer()->compositedLayerMapping()->setContentsNeedDisplayInRect(r, invalidationReason); layer()->compositedLayerMapping()->setContentsNeedDisplayInRect(r, invalidationReason);
} }
......
...@@ -594,28 +594,27 @@ void CompositedLayerMapping::updateSquashingLayerGeometry(const LayoutPoint& off ...@@ -594,28 +594,27 @@ void CompositedLayerMapping::updateSquashingLayerGeometry(const LayoutPoint& off
// The conversion between referenceLayer and the ancestor CLM is already computed as // The conversion between referenceLayer and the ancestor CLM is already computed as
// offsetFromReferenceLayerToParentGraphicsLayer. // offsetFromReferenceLayerToParentGraphicsLayer.
totalSquashBounds.moveBy(offsetFromReferenceLayerToParentGraphicsLayer); totalSquashBounds.moveBy(offsetFromReferenceLayerToParentGraphicsLayer);
IntRect squashLayerBounds = enclosingIntRect(totalSquashBounds); const IntRect squashLayerBounds = enclosingIntRect(totalSquashBounds);
IntPoint squashLayerOrigin = squashLayerBounds.location(); const IntPoint squashLayerOrigin = squashLayerBounds.location();
LayoutSize squashLayerOriginInOwningLayerSpace = squashLayerOrigin - offsetFromReferenceLayerToParentGraphicsLayer; const LayoutSize squashLayerOriginInOwningLayerSpace = squashLayerOrigin - offsetFromReferenceLayerToParentGraphicsLayer;
// 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.
// //
// The painting offset we want to compute for each squashed RenderLayer is essentially the position of // The painting offset we want to compute for each squashed RenderLayer is essentially the position of
// the squashed RenderLayer described w.r.t. referenceLayer's origin. For this purpose we already cached // the squashed RenderLayer described w.r.t. referenceLayer's origin.
// offsetFromSquashingCLM before, which describes where the squashed RenderLayer is located w.r.t. // So we just need to convert that point from referenceLayer space to the squashing layer's
// referenceLayer. So we just need to convert that point from referenceLayer space to referenceLayer
// space. This is simply done by subtracing squashLayerOriginInOwningLayerSpace, but then the offset // space. This is simply done by subtracing squashLayerOriginInOwningLayerSpace, but then the offset
// overall needs to be negated because that's the direction that the painting code expects the // overall needs to be negated because that's the direction that the painting code expects the
// offset to be. // offset to be.
for (size_t i = 0; i < layers.size(); ++i) { for (size_t i = 0; i < layers.size(); ++i) {
LayoutPoint offsetFromTransformedAncestorForSquashedLayer = layers[i].renderLayer->computeOffsetFromTransformedAncestor(); const LayoutPoint offsetFromTransformedAncestorForSquashedLayer = layers[i].renderLayer->computeOffsetFromTransformedAncestor();
LayoutSize offsetFromSquashLayerOrigin = (offsetFromTransformedAncestorForSquashedLayer - referenceOffsetFromTransformedAncestor) - squashLayerOriginInOwningLayerSpace; const LayoutSize offsetFromSquashLayerOrigin = (offsetFromTransformedAncestorForSquashedLayer - referenceOffsetFromTransformedAncestor) - squashLayerOriginInOwningLayerSpace;
// It is ok to issue paint invalidation here, because all of the geometry needed to correctly invalidate paint is computed by this point.
IntSize newOffsetFromRenderer = -IntSize(offsetFromSquashLayerOrigin.width().round(), offsetFromSquashLayerOrigin.height().round()); IntSize newOffsetFromRenderer = -IntSize(offsetFromSquashLayerOrigin.width().round(), offsetFromSquashLayerOrigin.height().round());
LayoutSize subpixelAccumulation = offsetFromSquashLayerOrigin + newOffsetFromRenderer; LayoutSize subpixelAccumulation = offsetFromSquashLayerOrigin + newOffsetFromRenderer;
if (layers[i].offsetFromRendererSet && layers[i].offsetFromRenderer != newOffsetFromRenderer) { if (layers[i].offsetFromRendererSet && layers[i].offsetFromRenderer != newOffsetFromRenderer) {
// It is ok to issue paint invalidation here, because all of the geometry needed to correctly invalidate paint is computed by this point.
layers[i].renderLayer->renderer()->invalidatePaintIncludingNonCompositingDescendants(); layers[i].renderLayer->renderer()->invalidatePaintIncludingNonCompositingDescendants();
TRACE_LAYER_INVALIDATION(layers[i].renderLayer, InspectorLayerInvalidationTrackingEvent::SquashingLayerGeometryWasUpdated); TRACE_LAYER_INVALIDATION(layers[i].renderLayer, InspectorLayerInvalidationTrackingEvent::SquashingLayerGeometryWasUpdated);
......
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