Commit 29f69353 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Chromium LUCI CQ

Reland "Add CullRect::ApplyPaintProperties()"

This reverts commit 91c206e0.

Reason for revert: The original CL accidentally removed some
RuntimeEnabledFeatures::CompositeAfterPaintEnabled() guard. Fixed in
this reland.

Original change's description:
> Revert "Add CullRect::ApplyPaintProperties()"
>
> This reverts commit 6f895b07.
>
> Reason for revert: The reverted CL is supposed not to affect
> production, but it seems to cause crbug.com/1166540.
>
> Original change's description:
> > Add CullRect::ApplyPaintProperties()
> >
> > It will be called to map a cull rect from parent space to local space
> > in cull rect update during PrePaint. The purpose is to mark PaintLayers
> > needing repaint on cull rect changes before paint, instead of checking
> > interest rect / cull rect changes during paint, to avoid setting
> > PaintLayer needing repaint unnecessarily, especially for CAP during
> > composited scrolling.
> >
> > Besides the original features of CullRect::ApplyTransforms() which is
> > used in cull rect mapping for CompositeAfterPaint, it also implements
> > the following features to be on par with CompositedLayerMapping::
> > ReComputeInterestRect():
> >
> > - Considering clips in additional to scroll clips,
> > - Clipping expanded cull rect by scrolling contents rect for composited
> >   scroll translations,
> > - Clamping extreme geometry values,
> > - Adaptive expansion distance for composited transforms.
> >
> > The next steps are:
> > 1. Add CullRectUpdater which updates cull rects during PrePaint when
> >    runtime feature CullRectUpdate is enabled.
> > 2. Use the updated cull rect to replace interest rect in pre-CAP and
> >    cull rect in CAP and pre-CAP, still behind the runtime feature.
> > 3. Enable CullRectUpdate for CAP
> > 4. Enable CullRectUpdate for pre-CAP.
> > 5. Remove old interest rect / cull rect code.
> >
> > Bug: 1046544
> > Change-Id: I6e7e9f85bc0b4640e67de1732744e647b6f7e230
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2620090
> > Reviewed-by: Philip Rogers <pdr@chromium.org>
> > Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#843304}
>
> TBR=szager@chromium.org,wangxianzhu@chromium.org,pdr@chromium.org,chromium-scoped@luci-project-accounts.iam.gserviceaccount.com
>
> Change-Id: Idc3374d3d426b9f571e417b1acbbc18227fdf274
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 1046544, 1166540
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2628021
> Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
> Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#843592}

TBR=szager@chromium.org,wangxianzhu@chromium.org,pdr@chromium.org,chromium-scoped@luci-project-accounts.iam.gserviceaccount.com

# Not skipping CQ checks because this is a reland.

Bug: 1046544
Bug: 1166540
Change-Id: Idb93eed1ab34750cfd1c0903551ba8fd66102354
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2628383Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843679}
parent 3423b77f
...@@ -18,6 +18,7 @@ class AffineTransform; ...@@ -18,6 +18,7 @@ class AffineTransform;
class FloatRect; class FloatRect;
class LayoutRect; class LayoutRect;
class LayoutUnit; class LayoutUnit;
class PropertyTreeState;
class TransformPaintPropertyNode; class TransformPaintPropertyNode;
class PLATFORM_EXPORT CullRect { class PLATFORM_EXPORT CullRect {
...@@ -47,9 +48,9 @@ class PLATFORM_EXPORT CullRect { ...@@ -47,9 +48,9 @@ class PLATFORM_EXPORT CullRect {
// 1. it's clipped by the container rect, // 1. it's clipped by the container rect,
// 2. transformed by inverse of the scroll translation, // 2. transformed by inverse of the scroll translation,
// 3. expanded by thousands of pixels for composited scrolling. // 3. expanded by thousands of pixels for composited scrolling.
void ApplyTransform(const TransformPaintPropertyNode& transform) { // 4. clipped by the contents rect.
ApplyTransformInternal(transform); // TODO(wangxianzhu): Remove this function for CullRectUpdate.
} void ApplyTransform(const TransformPaintPropertyNode&);
// For CompositeAfterPaint only. Applies transforms from |source| (not // For CompositeAfterPaint only. Applies transforms from |source| (not
// included) to |destination| (included). For each scroll translation, the // included) to |destination| (included). For each scroll translation, the
...@@ -58,10 +59,21 @@ class PLATFORM_EXPORT CullRect { ...@@ -58,10 +59,21 @@ class PLATFORM_EXPORT CullRect {
// doesn't cover the whole scrolling contents, and the new cull rect doesn't // doesn't cover the whole scrolling contents, and the new cull rect doesn't
// change enough (by hundreds of pixels) from |old_cull_rect|, the cull rect // change enough (by hundreds of pixels) from |old_cull_rect|, the cull rect
// will be set to |old_cull_rect| to avoid repaint on each composited scroll. // will be set to |old_cull_rect| to avoid repaint on each composited scroll.
// TODO(wangxianzhu): Remove this function for CullRectUpdate.
void ApplyTransforms(const TransformPaintPropertyNode& source, void ApplyTransforms(const TransformPaintPropertyNode& source,
const TransformPaintPropertyNode& destination, const TransformPaintPropertyNode& destination,
const base::Optional<CullRect>& old_cull_rect); const base::Optional<CullRect>& old_cull_rect);
// For CullRectUpdate only. Similar to the above but also applies clips and
// expands for all directly composited transforms (including scrolling and
// non-scrolling ones). |root| is used to calculate the expansion distance in
// the local space, to make the expansion distance approximately the same in
// the root space.
void ApplyPaintProperties(const PropertyTreeState& root,
const PropertyTreeState& source,
const PropertyTreeState& destination,
const base::Optional<CullRect>& old_cull_rect);
const IntRect& Rect() const { return rect_; } const IntRect& Rect() const { return rect_; }
String ToString() const { return rect_.ToString(); } String ToString() const { return rect_.ToString(); }
...@@ -82,10 +94,17 @@ class PLATFORM_EXPORT CullRect { ...@@ -82,10 +94,17 @@ class PLATFORM_EXPORT CullRect {
// doesn't cover the whole scrolling contents. // doesn't cover the whole scrolling contents.
kExpandedForPartialScrollingContents, kExpandedForPartialScrollingContents,
}; };
ApplyTransformResult ApplyTransformInternal( ApplyTransformResult ApplyScrollTranslation(
const TransformPaintPropertyNode&); const TransformPaintPropertyNode& root_transform,
const TransformPaintPropertyNode& scroll_translation);
void ApplyTransformWithoutExpansion(const TransformPaintPropertyNode&);
void ApplyPaintPropertiesWithoutExpansion(
const PropertyTreeState& source,
const PropertyTreeState& destination);
bool ChangedEnough(const CullRect& old_cull_rect) const; bool ChangedEnough(const CullRect& old_cull_rect,
const IntSize* bounds) const;
IntRect rect_; IntRect rect_;
}; };
......
...@@ -653,6 +653,9 @@ ...@@ -653,6 +653,9 @@
name: "CSSVariables2TransformValues", name: "CSSVariables2TransformValues",
status: "test", status: "test",
}, },
{
name: "CullRectUpdate",
},
{ {
name: "CustomElementDefaultStyle", name: "CustomElementDefaultStyle",
status: "experimental", status: "experimental",
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "third_party/blink/renderer/platform/graphics/paint/clip_paint_property_node.h" #include "third_party/blink/renderer/platform/graphics/paint/clip_paint_property_node.h"
#include "third_party/blink/renderer/platform/graphics/paint/effect_paint_property_node.h" #include "third_party/blink/renderer/platform/graphics/paint/effect_paint_property_node.h"
#include "third_party/blink/renderer/platform/graphics/paint/property_tree_state.h" #include "third_party/blink/renderer/platform/graphics/paint/property_tree_state.h"
#include "third_party/blink/renderer/platform/graphics/paint/ref_counted_property_tree_state.h"
#include "third_party/blink/renderer/platform/graphics/paint/transform_paint_property_node.h" #include "third_party/blink/renderer/platform/graphics/paint/transform_paint_property_node.h"
#include "third_party/blink/renderer/platform/testing/paint_property_test_helpers.h" #include "third_party/blink/renderer/platform/testing/paint_property_test_helpers.h"
...@@ -23,6 +24,9 @@ inline const ClipPaintPropertyNode& c0() { ...@@ -23,6 +24,9 @@ inline const ClipPaintPropertyNode& c0() {
inline const EffectPaintPropertyNode& e0() { inline const EffectPaintPropertyNode& e0() {
return EffectPaintPropertyNode::Root(); return EffectPaintPropertyNode::Root();
} }
inline const ScrollPaintPropertyNode& s0() {
return ScrollPaintPropertyNode::Root();
}
constexpr int c0_id = 1; constexpr int c0_id = 1;
constexpr int e0_id = 1; constexpr int e0_id = 1;
...@@ -217,6 +221,28 @@ inline scoped_refptr<TransformPaintPropertyNode> CreateScrollTranslation( ...@@ -217,6 +221,28 @@ inline scoped_refptr<TransformPaintPropertyNode> CreateScrollTranslation(
return TransformPaintPropertyNode::Create(parent, std::move(state)); return TransformPaintPropertyNode::Create(parent, std::move(state));
} }
inline scoped_refptr<TransformPaintPropertyNode> CreateScrollTranslation(
const TransformPaintPropertyNodeOrAlias& parent,
float offset_x,
float offset_y,
const IntRect& container_rect,
const IntSize& contents_size,
CompositingReasons compositing_reasons = CompositingReason::kNone) {
const auto* parent_scroll_translation = &parent.Unalias();
while (!parent_scroll_translation->ScrollNode())
parent_scroll_translation = parent_scroll_translation->UnaliasedParent();
ScrollPaintPropertyNode::State scroll_state;
scroll_state.container_rect = container_rect;
scroll_state.contents_size = contents_size;
TransformPaintPropertyNode::State translation_state{
FloatSize(offset_x, offset_y)};
translation_state.direct_compositing_reasons = compositing_reasons;
translation_state.scroll = ScrollPaintPropertyNode::Create(
*parent_scroll_translation->ScrollNode(), std::move(scroll_state));
return TransformPaintPropertyNode::Create(parent,
std::move(translation_state));
}
inline scoped_refptr<TransformPaintPropertyNode> inline scoped_refptr<TransformPaintPropertyNode>
CreateCompositedScrollTranslation( CreateCompositedScrollTranslation(
const TransformPaintPropertyNodeOrAlias& parent, const TransformPaintPropertyNodeOrAlias& parent,
...@@ -227,6 +253,46 @@ CreateCompositedScrollTranslation( ...@@ -227,6 +253,46 @@ CreateCompositedScrollTranslation(
CompositingReason::kOverflowScrolling); CompositingReason::kOverflowScrolling);
} }
inline scoped_refptr<TransformPaintPropertyNode>
CreateCompositedScrollTranslation(
const TransformPaintPropertyNodeOrAlias& parent,
float offset_x,
float offset_y,
const IntRect& container_rect,
const IntSize& contents_size) {
return CreateScrollTranslation(parent, offset_x, offset_y, container_rect,
contents_size,
CompositingReason::kOverflowScrolling);
}
inline RefCountedPropertyTreeState CreateScrollTranslationState(
const PropertyTreeState& parent_state,
float offset_x,
float offset_y,
const IntRect& container_rect,
const IntSize& contents_size,
CompositingReasons compositing_reasons = CompositingReason::kNone) {
return RefCountedPropertyTreeState(PropertyTreeState(
*CreateScrollTranslation(parent_state.Transform(), offset_x, offset_y,
container_rect, contents_size,
compositing_reasons),
*CreateClip(parent_state.Clip(), parent_state.Transform(),
FloatRoundedRect(container_rect)),
e0()));
}
inline RefCountedPropertyTreeState CreateCompositedScrollTranslationState(
const PropertyTreeState& parent_state,
float offset_x,
float offset_y,
const IntRect& container_rect,
const IntSize& contents_size,
CompositingReasons compositing_reasons = CompositingReason::kNone) {
return CreateScrollTranslationState(parent_state, offset_x, offset_y,
container_rect, contents_size,
CompositingReason::kOverflowScrolling);
}
inline PropertyTreeState DefaultPaintChunkProperties() { inline PropertyTreeState DefaultPaintChunkProperties() {
return PropertyTreeState::Root(); return PropertyTreeState::Root();
} }
......
...@@ -7,29 +7,11 @@ Layer tree when the fixed elements are out-of-view (should have just a root laye ...@@ -7,29 +7,11 @@ Layer tree when the fixed elements are out-of-view (should have just a root laye
"contentsOpaque": true, "contentsOpaque": true,
"backgroundColor": "#FFFFFF" "backgroundColor": "#FFFFFF"
}, },
{
"name": "LayoutNGBlockFlow (positioned) DIV id='fixed1'",
"bounds": [10, 10],
"contentsOpaque": true,
"backgroundColor": "#C0C0C0",
"transform": 1
},
{ {
"name": "VerticalScrollbar", "name": "VerticalScrollbar",
"position": [785, 0], "position": [785, 0],
"bounds": [15, 600] "bounds": [15, 600]
} }
],
"transforms": [
{
"id": 1,
"transform": [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[100, -100, 0, 1]
]
}
] ]
} }
......
...@@ -13,20 +13,6 @@ ...@@ -13,20 +13,6 @@
"backgroundColor": "#C0C0C0", "backgroundColor": "#C0C0C0",
"transform": 1 "transform": 1
}, },
{
"name": "LayoutNGBlockFlow (positioned) DIV class='fixed'",
"bounds": [10, 10],
"contentsOpaque": true,
"backgroundColor": "#C0C0C0",
"transform": 2
},
{
"name": "LayoutNGBlockFlow (positioned) DIV class='fixed'",
"bounds": [10, 10],
"contentsOpaque": true,
"backgroundColor": "#C0C0C0",
"transform": 3
},
{ {
"name": "LayoutNGBlockFlow (positioned) DIV class='fixed'", "name": "LayoutNGBlockFlow (positioned) DIV class='fixed'",
"bounds": [10, 10], "bounds": [10, 10],
...@@ -48,24 +34,6 @@ ...@@ -48,24 +34,6 @@
[0, 0, 1, 0], [0, 0, 1, 0],
[8, 1013, 0, 1] [8, 1013, 0, 1]
] ]
},
{
"id": 2,
"transform": [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[8, -100, 0, 1]
]
},
{
"id": 3,
"transform": [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[1000, 0, 0, 1]
]
} }
] ]
} }
......
...@@ -29,13 +29,6 @@ Not scaled: ...@@ -29,13 +29,6 @@ Not scaled:
"backgroundColor": "#C0C0C0", "backgroundColor": "#C0C0C0",
"transform": 4 "transform": 4
}, },
{
"name": "LayoutNGBlockFlow (positioned) DIV class='fixed'",
"bounds": [10, 10],
"contentsOpaque": true,
"backgroundColor": "#C0C0C0",
"transform": 5
},
{ {
"name": "LayoutNGBlockFlow (positioned) DIV class='fixed'", "name": "LayoutNGBlockFlow (positioned) DIV class='fixed'",
"bounds": [10, 10], "bounds": [10, 10],
...@@ -59,16 +52,6 @@ Not scaled: ...@@ -59,16 +52,6 @@ Not scaled:
{ {
"id": 2, "id": 2,
"parent": 1, "parent": 1,
"transform": [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[8, -100, 0, 1]
]
},
{
"id": 3,
"parent": 1,
"transform": [ "transform": [
[1, 0, 0, 0], [1, 0, 0, 0],
[0, 1, 0, 0], [0, 1, 0, 0],
...@@ -77,7 +60,7 @@ Not scaled: ...@@ -77,7 +60,7 @@ Not scaled:
] ]
}, },
{ {
"id": 4, "id": 3,
"parent": 1, "parent": 1,
"transform": [ "transform": [
[1, 0, 0, 0], [1, 0, 0, 0],
...@@ -87,7 +70,7 @@ Not scaled: ...@@ -87,7 +70,7 @@ Not scaled:
] ]
}, },
{ {
"id": 5, "id": 4,
"parent": 1, "parent": 1,
"transform": [ "transform": [
[1, 0, 0, 0], [1, 0, 0, 0],
...@@ -130,13 +113,6 @@ Scale=0.5: ...@@ -130,13 +113,6 @@ Scale=0.5:
"backgroundColor": "#C0C0C0", "backgroundColor": "#C0C0C0",
"transform": 4 "transform": 4
}, },
{
"name": "LayoutNGBlockFlow (positioned) DIV class='fixed'",
"bounds": [10, 10],
"contentsOpaque": true,
"backgroundColor": "#C0C0C0",
"transform": 5
},
{ {
"name": "LayoutNGBlockFlow (positioned) DIV class='fixed'", "name": "LayoutNGBlockFlow (positioned) DIV class='fixed'",
"bounds": [10, 10], "bounds": [10, 10],
...@@ -160,16 +136,6 @@ Scale=0.5: ...@@ -160,16 +136,6 @@ Scale=0.5:
{ {
"id": 2, "id": 2,
"parent": 1, "parent": 1,
"transform": [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[8, -100, 0, 1]
]
},
{
"id": 3,
"parent": 1,
"transform": [ "transform": [
[1, 0, 0, 0], [1, 0, 0, 0],
[0, 1, 0, 0], [0, 1, 0, 0],
...@@ -178,7 +144,7 @@ Scale=0.5: ...@@ -178,7 +144,7 @@ Scale=0.5:
] ]
}, },
{ {
"id": 4, "id": 3,
"parent": 1, "parent": 1,
"transform": [ "transform": [
[1, 0, 0, 0], [1, 0, 0, 0],
...@@ -188,7 +154,7 @@ Scale=0.5: ...@@ -188,7 +154,7 @@ Scale=0.5:
] ]
}, },
{ {
"id": 5, "id": 4,
"parent": 1, "parent": 1,
"transform": [ "transform": [
[1, 0, 0, 0], [1, 0, 0, 0],
...@@ -231,13 +197,6 @@ Scale=1.5: ...@@ -231,13 +197,6 @@ Scale=1.5:
"backgroundColor": "#C0C0C0", "backgroundColor": "#C0C0C0",
"transform": 4 "transform": 4
}, },
{
"name": "LayoutNGBlockFlow (positioned) DIV class='fixed'",
"bounds": [10, 10],
"contentsOpaque": true,
"backgroundColor": "#C0C0C0",
"transform": 5
},
{ {
"name": "LayoutNGBlockFlow (positioned) DIV class='fixed'", "name": "LayoutNGBlockFlow (positioned) DIV class='fixed'",
"bounds": [10, 10], "bounds": [10, 10],
...@@ -261,16 +220,6 @@ Scale=1.5: ...@@ -261,16 +220,6 @@ Scale=1.5:
{ {
"id": 2, "id": 2,
"parent": 1, "parent": 1,
"transform": [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[8, -100, 0, 1]
]
},
{
"id": 3,
"parent": 1,
"transform": [ "transform": [
[1, 0, 0, 0], [1, 0, 0, 0],
[0, 1, 0, 0], [0, 1, 0, 0],
...@@ -279,7 +228,7 @@ Scale=1.5: ...@@ -279,7 +228,7 @@ Scale=1.5:
] ]
}, },
{ {
"id": 4, "id": 3,
"parent": 1, "parent": 1,
"transform": [ "transform": [
[1, 0, 0, 0], [1, 0, 0, 0],
...@@ -289,7 +238,7 @@ Scale=1.5: ...@@ -289,7 +238,7 @@ Scale=1.5:
] ]
}, },
{ {
"id": 5, "id": 4,
"parent": 1, "parent": 1,
"transform": [ "transform": [
[1, 0, 0, 0], [1, 0, 0, 0],
......
...@@ -11,16 +11,6 @@ ...@@ -11,16 +11,6 @@
"bounds": [10, 10], "bounds": [10, 10],
"transform": 1 "transform": 1
}, },
{
"name": "LayoutNGBlockFlow (positioned) DIV class='fixed'",
"bounds": [10, 10],
"transform": 2
},
{
"name": "LayoutNGBlockFlow (positioned) DIV class='fixed'",
"bounds": [10, 10],
"transform": 3
},
{ {
"name": "LayoutNGBlockFlow (positioned) DIV class='fixed'", "name": "LayoutNGBlockFlow (positioned) DIV class='fixed'",
"bounds": [10, 10] "bounds": [10, 10]
...@@ -40,24 +30,6 @@ ...@@ -40,24 +30,6 @@
[0, 0, 1, 0], [0, 0, 1, 0],
[8, 1013, 0, 1] [8, 1013, 0, 1]
] ]
},
{
"id": 2,
"transform": [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[8, -100, 0, 1]
]
},
{
"id": 3,
"transform": [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[1000, 0, 0, 1]
]
} }
] ]
} }
......
...@@ -7,19 +7,12 @@ ...@@ -7,19 +7,12 @@
"backgroundColor": "#FFFFFF", "backgroundColor": "#FFFFFF",
"transform": 1 "transform": 1
}, },
{
"name": "LayoutNGBlockFlow (positioned) DIV",
"bounds": [88, 88],
"contentsOpaque": true,
"backgroundColor": "#C0C0C0",
"transform": 2
},
{ {
"name": "LayoutNGBlockFlow (positioned) DIV", "name": "LayoutNGBlockFlow (positioned) DIV",
"bounds": [99, 99], "bounds": [99, 99],
"contentsOpaque": true, "contentsOpaque": true,
"backgroundColor": "#C0C0C0", "backgroundColor": "#C0C0C0",
"transform": 3 "transform": 2
}, },
{ {
"name": "VerticalScrollbar", "name": "VerticalScrollbar",
...@@ -39,15 +32,6 @@ ...@@ -39,15 +32,6 @@
}, },
{ {
"id": 2, "id": 2,
"transform": [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[100, -300, 0, 1]
]
},
{
"id": 3,
"transform": [ "transform": [
[1, 0, 0, 0], [1, 0, 0, 0],
[0, 1, 0, 0], [0, 1, 0, 0],
......
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
"contentsOpaque": true, "contentsOpaque": true,
"backgroundColor": "#FFFFFF", "backgroundColor": "#FFFFFF",
"invalidations": [ "invalidations": [
[0, 0, 668, 236], [450, 0, 218, 236],
[704, 0, 214, 232], [704, 0, 214, 232],
[0, 0, 214, 232],
[700, 217, 4, 19] [700, 217, 4, 19]
] ]
}, },
......
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