Commit a63dd559 authored by Stephen Chenney's avatar Stephen Chenney Committed by Commit Bot

[PE] Apply border-radius clips to squashed layers that need them.

When layers are squashed they currently lose their border radius clips.
Fix that by using ClipRects instead of IntRects in the sqaushed layer
clipping code, and gathering the clips appropriately.

Based on https://chromium-review.googlesource.com/c/chromium/src/+/772081 by chrishtr@.

R=chrishtr@chromium.org
Bug: 761298

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I58a4c8bc785a5cea562a7de52ba24ee1600c9cff
Reviewed-on: https://chromium-review.googlesource.com/797337
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521403}
parent f0e1a93c
......@@ -1040,6 +1040,7 @@ Bug(none) compositing/composited-scaled-child-with-border-radius-parent-clip.htm
Bug(none) compositing/composited-translated-child-with-border-radius-parent-clip.html [ Failure ]
Bug(none) compositing/overflow/border-radius-on-grandparent-composited-grandchild.html [ Failure ]
Bug(none) compositing/overflow/border-radius-on-two-ancestors-composited-grandchild.html [ Failure ]
Bug(none) compositing/overflow/border-radius-on-squashed-layers.html [ Failure ]
Bug(none) compositing/overflow/border-radius-styles-with-composited-child.html [ Failure ]
Bug(none) compositing/overflow/grandchild-composited-with-border-radius-ancestor.html [ Failure ]
Bug(none) compositing/overflow/grandchild-with-border-radius-ancestor.html [ Failure ]
......
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x98
LayoutBlockFlow {HTML} at (0,0) size 800x98
LayoutBlockFlow {BODY} at (8,8) size 784x82
layer at (8,8) size 100x40
LayoutBlockFlow {DIV} at (0,0) size 100x40 [bgcolor=#0000FF]
layer at (8,3) size 102x42 clip at (9,4) size 100x40 scrollWidth 190 scrollHeight 200
LayoutBlockFlow (relative positioned) {DIV} at (0,40) size 102x42 [bgcolor=#FF0000] [border: (1px solid #000000)]
layer at (-1,-6) size 200x200 backgroundClip at (9,4) size 100x40 clip at (9,4) size 100x40
LayoutBlockFlow (relative positioned) {DIV} at (1,1) size 200x200 [bgcolor=#008000]
<!DOCTYPE html>
<style>
.precursor {
width: 100px;
height: 40px;
background-color: blue;
will-change: transform;
}
.container {
position: relative;
top: -45px;
width: 100px;
height: 40px;
background-color: red;
border: 1px solid black;
border-radius: 10px;
overflow: hidden;
}
.contents {
background-color: green;
height: 200px;
width: 200px;
position: relative;
top: -10px;
left: -10px;
}
</style>
<div class="precursor"></div>
<div class="container">
<div class="contents"></div>
</div>
......@@ -1117,8 +1117,7 @@ void CompositedLayerMapping::UpdateSquashingLayerGeometry(
squash_layer_origin_in_compositing_container_space);
for (size_t i = 0; i < layers.size(); ++i) {
layers[i].local_clip_rect_for_squashed_layer =
LocalClipRectForSquashedLayer(owning_layer_, layers[i], layers);
LocalClipRectForSquashedLayer(owning_layer_, layers, layers[i]);
}
}
......@@ -3118,14 +3117,19 @@ const GraphicsLayerPaintInfo* CompositedLayerMapping::ContainingSquashedLayer(
layout_object, squashed_layers_, max_squashed_layer_index);
}
IntRect CompositedLayerMapping::LocalClipRectForSquashedLayer(
void CompositedLayerMapping::LocalClipRectForSquashedLayer(
const PaintLayer& reference_layer,
const GraphicsLayerPaintInfo& paint_info,
const Vector<GraphicsLayerPaintInfo>& layers) {
const Vector<GraphicsLayerPaintInfo>& layers,
GraphicsLayerPaintInfo& paint_info) {
const LayoutObject* clipping_container =
paint_info.paint_layer->ClippingContainer();
if (clipping_container == reference_layer.ClippingContainer())
return LayoutRect::InfiniteIntRect();
if (clipping_container == reference_layer.ClippingContainer()) {
paint_info.local_clip_rect_for_squashed_layer =
ClipRect(LayoutRect(LayoutRect::InfiniteIntRect()));
paint_info.offset_from_clip_rect_root = LayoutPoint();
paint_info.local_clip_rect_root = paint_info.paint_layer;
return;
}
DCHECK(clipping_container);
......@@ -3144,16 +3148,15 @@ IntRect CompositedLayerMapping::LocalClipRectForSquashedLayer(
paint_info.paint_layer->Clipper(PaintLayer::kDoNotUseGeometryMapper)
.CalculateBackgroundClipRect(clip_rects_context, parent_clip_rect);
IntRect snapped_parent_clip_rect(
PixelSnappedIntRect(parent_clip_rect.Rect()));
DCHECK(snapped_parent_clip_rect != LayoutRect::InfiniteIntRect());
// Convert from ancestor to local coordinates.
IntSize ancestor_to_local_offset =
paint_info.offset_from_layout_object -
ancestor_paint_info->offset_from_layout_object;
snapped_parent_clip_rect.Move(ancestor_to_local_offset);
return snapped_parent_clip_rect;
parent_clip_rect.Move(ancestor_to_local_offset);
paint_info.local_clip_rect_for_squashed_layer = parent_clip_rect;
paint_info.offset_from_clip_rect_root = LayoutPoint(
ancestor_to_local_offset.Width(), ancestor_to_local_offset.Height());
paint_info.local_clip_rect_root = ancestor_paint_info->paint_layer;
}
void CompositedLayerMapping::DoPaintTask(
......@@ -3227,11 +3230,15 @@ void CompositedLayerMapping::DoPaintTask(
// squash layers that need clipping in software from clipping ancestors (see
// CompositedLayerMapping::localClipRectForSquashedLayer()).
// FIXME: Is it correct to clip to dirtyRect in slimming paint mode?
// FIXME: Combine similar code here and LayerClipRecorder.
dirty_rect.Intersect(paint_info.local_clip_rect_for_squashed_layer);
ClipRecorder clip_recorder(context, graphics_layer,
DisplayItem::kClipLayerOverflowControls,
dirty_rect);
ClipRect clip_rect = paint_info.local_clip_rect_for_squashed_layer;
clip_rect.Intersect(LayoutRect(dirty_rect));
LayerClipRecorder layer_clip_recorder(
context, *paint_info.paint_layer,
DisplayItem::kClipLayerOverflowControls, clip_rect,
paint_info.local_clip_rect_root, paint_info.offset_from_clip_rect_root,
paint_layer_flags, graphics_layer,
LayerClipRecorder::kDoNotIncludeSelfForBorderRadius);
PaintLayerPainter(*paint_info.paint_layer)
.Paint(context, painting_info, paint_layer_flags);
}
......
......@@ -50,7 +50,9 @@ struct GraphicsLayerPaintInfo {
// The clip rect to apply, in the local coordinate space of the squashed
// layer, when painting it.
IntRect local_clip_rect_for_squashed_layer;
ClipRect local_clip_rect_for_squashed_layer;
PaintLayer* local_clip_rect_root;
LayoutPoint offset_from_clip_rect_root;
// Offset describing where this squashed Layer paints into the shared
// GraphicsLayer backing.
......@@ -484,10 +486,10 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
// no such containing layer, returns the infinite rect.
// FIXME: unify this code with the code that sets up ancestor_clipping_layer_.
// They are doing very similar things.
static IntRect LocalClipRectForSquashedLayer(
static void LocalClipRectForSquashedLayer(
const PaintLayer& reference_layer,
const GraphicsLayerPaintInfo&,
const Vector<GraphicsLayerPaintInfo>& layers);
const Vector<GraphicsLayerPaintInfo>& layers,
GraphicsLayerPaintInfo&);
// Conservatively check whether there exists any border-radius clip that
// must be applied by an ancestor clipping mask layer. There are two inputs
......
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