Commit f62169af authored by Tien-Ren Chen's avatar Tien-Ren Chen Committed by Commit Bot

[SPv2] Apply non-composited effects in group

This CL reworks PaintChunksToCcLayer to handle effect grouping properly.

Prior to this CL each paint chunk applies its property state all the way from the
layer state then pop all the way back. This CL implemented an algorithm to lazily
pop states so that contiguous paint chunks enclosed by the same effect will apply
the effect atomically.

As an optimization, clip region is also popped lazily. Note that this doesn't mean
AA-clips are applied as a group but still apply to individual draw commands
separately. It does improve performance by reusing previously generated clip region
when a complex clip region applies to multiple chunks repeatedly. Rounded clip
support is also added as a side change.

Transforms are always applied on the spot. This is because we can compute the
matrix between arbitrary nodes in O(1). Also this automatically handles "transform
inversion" cases as we don't even need to detect the relationship between nodes.

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I64657b657fad3e19132b9eb0d64db494955f2139
Reviewed-on: https://chromium-review.googlesource.com/540737
Commit-Queue: Tien-Ren Chen <trchen@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485109}
parent e1603262
......@@ -520,11 +520,9 @@ Bug(none) fast/canvas/OffscreenCanvas-strokeRect-in-worker.html [ Failure ]
Bug(none) fast/canvas/OffscreenCanvas-transform-shadow-in-worker.html [ Failure ]
Bug(none) fast/canvas/webgl/pixelated.html [ Failure ]
Bug(none) fast/clip/nestedTransparencyClip.html [ Failure ]
Bug(none) fast/clip/overflow-border-radius-clip.html [ Failure ]
Bug(none) fast/clip/overflow-border-radius-combinations.html [ Failure ]
Bug(none) fast/clip/overflow-border-radius-composited-parent.html [ Failure ]
Bug(none) fast/clip/overflow-border-radius-composited.html [ Failure ]
Bug(none) fast/clip/overflow-border-radius-fixed-position.html [ Failure ]
Bug(none) fast/clip/overflow-border-radius-transformed.html [ Failure ]
Bug(none) fast/css-generated-content/014.html [ Failure ]
Bug(none) fast/css-generated-content/table-parts-before-and-after.html [ Failure ]
......@@ -637,7 +635,6 @@ Bug(none) fast/inline/inline-borders-with-bidi-override.html [ Failure ]
Bug(none) fast/inline/inline-continuation-borders.html [ Failure ]
Bug(none) fast/layers/normal-flow-hit-test.html [ Crash Failure ]
Bug(none) fast/layers/opacity-outline.html [ Failure ]
Bug(none) fast/layers/overflow-hidden-rounded-corners-occlusion.html [ Failure ]
Bug(none) fast/layers/remove-layer-with-nested-stacking.html [ Skip ]
Bug(none) fast/layers/scroll-rect-to-visible.html [ Failure ]
Bug(none) fast/lists/008.html [ Failure ]
......@@ -1006,7 +1003,6 @@ Bug(none) paint/invalidation/single-line-cells-repeating-thead-break-inside-on-t
Bug(none) paint/invalidation/svg/deep-nested-embedded-svg-size-changes-no-layout-triggers-1.html [ Failure ]
Bug(none) paint/invalidation/svg/deep-nested-embedded-svg-size-changes-no-layout-triggers-2.html [ Failure ]
Bug(none) paint/invalidation/svg/use-detach.svg [ Failure ]
Bug(none) paint/background/rounded-clip-fractional-offset.html [ Failure ]
Bug(none) paint/clipath/clip-path-with-background-and-box-behind.html [ Failure ]
Bug(none) paint/frames/frameset-with-stacking-context-and-not-stacking-context-children.html [ Failure ]
Bug(none) paint/frames/frameset-with-stacking-contexts.html [ Failure ]
......@@ -1252,7 +1248,6 @@ Bug(none) paint/selection/text-selection-newline-rtl-double-linebreak.html [ Fai
# Mask does not work correctly
crbug.com/707444 svg/W3C-SVG-1.1/masking-intro-01-f.svg [ Failure ]
crbug.com/707444 svg/as-background-image/svg-as-background-6.html [ Failure ]
crbug.com/707444 svg/batik/masking/maskRegions.svg [ Failure ]
crbug.com/707444 svg/custom/clamped-masking-clipping.svg [ Failure ]
crbug.com/707444 svg/custom/clip-mask-negative-scale.svg [ Failure ]
......@@ -1568,9 +1563,16 @@ crbug.com/589265 css3/blending/mix-blend-mode-isolated-group-2.html [ Failure ]
crbug.com/589265 css3/blending/mix-blend-mode-isolated-group-3.html [ Failure ]
crbug.com/589265 css3/blending/svg-blend-exclusion.html [ Failure ]
crbug.com/589265 css3/blending/svg-blend-screen.html [ Failure ]
crbug.com/589265 fast/backgrounds/size/contain-and-cover-zoomed.html [ Failure ]
crbug.com/589265 fast/css/ZeroOpacityLayers.html [ Failure ]
crbug.com/589265 fast/css/ZeroOpacityLayers2.html [ Failure ]
crbug.com/589265 fast/forms/datalist/input-appearance-range-with-transform.html [ Failure ]
crbug.com/589265 fast/forms/indeterminate.html [ Failure ]
crbug.com/589265 images/color-profile-filter.html [ Failure ]
crbug.com/589265 paint/invalidation/svg/repaint-paintorder.svg [ Failure ]
crbug.com/589265 paint/invalidation/svg/tabgroup.svg [ Failure ]
crbug.com/589265 svg/W3C-SVG-1.1/animate-elem-33-t.svg [ Failure ]
crbug.com/589265 svg/as-background-image/background-image-preserveaspectRatio-support.html [ Failure ]
crbug.com/589265 svg/custom/small-rect-scale.svg [ Failure ]
crbug.com/589265 svg/dynamic-updates/SVGFEBlendElement-dom-in-attr.html [ Failure ]
crbug.com/589265 svg/dynamic-updates/SVGFEBlendElement-dom-in2-attr.html [ Failure ]
......@@ -1578,6 +1580,9 @@ crbug.com/589265 svg/dynamic-updates/SVGFEBlendElement-dom-mode-attr.html [ Fail
crbug.com/589265 svg/dynamic-updates/SVGFEBlendElement-svgdom-in-prop.html [ Failure ]
crbug.com/589265 svg/dynamic-updates/SVGFEBlendElement-svgdom-in2-prop.html [ Failure ]
crbug.com/589265 svg/dynamic-updates/SVGFEBlendElement-svgdom-mode-prop.html [ Failure ]
crbug.com/589265 svg/text/text-selection-align-01-b.svg [ Failure ]
crbug.com/589265 svg/text/text-selection-align-05-b.svg [ Failure ]
crbug.com/589265 svg/zoom/page/zoom-svg-as-background-with-relative-size.html [ Failure ]
# Failures due to SPv2 using SkBlendMode::kDstIn to implement masks.
# Some rounding differences is expected but none of them should be apparent.
......@@ -1620,7 +1625,6 @@ crbug.com/157218 compositing/overflow/border-radius-on-two-ancestors-composited-
# Subpixel adjustments due to differences in compositing
crbug.com/589265 animations/animated-filter-svg-element.html [ Failure Crash ]
crbug.com/589265 compositing/overflow/do-not-paint-outline-into-composited-scrolling-contents.html [ Failure ]
crbug.com/589265 fast/css/all-shorthand-first-letter.html [ Failure ]
crbug.com/589265 fast/forms/number/number-appearance-spinbutton-layer.html [ Failure ]
crbug.com/589265 fast/layers/add-layer-with-nested-stacking.html [ Failure ]
crbug.com/589265 fast/layers/opacity-transforms.html [ Failure ]
......@@ -1673,7 +1677,6 @@ Bug(700530) compositing/geometry/abs-position-inside-opacity.html [ Failure ]
Bug(700530) fast/css3-text/css3-text-decoration/text-underline-position/text-underline-position-cjk.html [ Failure ]
# The following debug crashes have not been triaged.
crbug.com/702805 css3/blending/svg-blend-layer-filter.html [ Crash ]
crbug.com/702805 virtual/threaded/compositing/visibility/overlays-persist-on-navigation.html [ Crash ]
crbug.com/702805 svg/filters/feImage-self-referencing.html [ Crash ]
crbug.com/702805 svg/filters/feImage-self-and-other-referencing.html [ Crash ]
......@@ -1745,3 +1748,5 @@ Bug(none) fast/block/float/float-change-composited-scrolling.html [ Failure ]
# reasons, in particular that the composited layerization algorithm provides
# different results.
Bug(none) paint/invalidation/compositing/subpixel-offset-scaled-transform-composited.html [ Failure ]
crbug.com/737275 svg/as-background-image/svg-as-background-6.html [ Crash Failure ]
......@@ -1876,6 +1876,7 @@ test("blink_platform_unittests") {
"graphics/RecordingImageBufferSurfaceTest.cpp",
"graphics/compositing/ContentLayerClientImplTest.cpp",
"graphics/compositing/PaintArtifactCompositorTest.cpp",
"graphics/compositing/PaintChunksToCcLayerTest.cpp",
"graphics/filters/ImageFilterBuilderTest.cpp",
"graphics/gpu/DrawingBufferTest.cpp",
"graphics/gpu/SharedGpuContextTest.cpp",
......
......@@ -1478,7 +1478,7 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TwoTransformsClipBetween) {
rects_with_color.push_back(
RectWithColor(FloatRect(0, 0, 100, 100), Color::kWhite));
rects_with_color.push_back(
RectWithColor(FloatRect(40, 50, 50, 60), Color(Color::kBlack)));
RectWithColor(FloatRect(40, 50, 10, 10), Color(Color::kBlack)));
rects_with_color.push_back(
RectWithColor(FloatRect(0, 0, 200, 300), Color::kGray));
const cc::Layer* layer = ContentLayerAt(0);
......
......@@ -17,11 +17,6 @@ namespace blink {
namespace {
struct QuadWithColor {
FloatQuad quad;
Color color;
};
class DrawsRectangleCanvas : public SkCanvas {
public:
DrawsRectangleCanvas()
......@@ -29,26 +24,27 @@ class DrawsRectangleCanvas : public SkCanvas {
save_count_(0),
alpha_(255),
alpha_save_layer_count_(-1) {}
const Vector<QuadWithColor>& QuadsWithColor() const { return quads_; }
const Vector<RectWithColor>& RectsWithColor() const { return rects_; }
void onDrawRect(const SkRect& rect, const SkPaint& paint) override {
SkRect clipped_rect(rect);
for (Vector<ClipAndIndex>::const_reverse_iterator clip = clips_.rbegin();
clip != clips_.rend(); clip++) {
if (SkRect::Intersects(rect, clip->rect))
CHECK(clipped_rect.intersect(clip->rect));
}
SkPoint quad[4];
getTotalMatrix().mapRectToQuad(quad, clipped_rect);
QuadWithColor quad_with_color;
quad_with_color.quad = FloatQuad(quad);
getTotalMatrix().mapRectToQuad(quad, rect);
SkRect device_rect;
device_rect.set(quad, 4);
SkIRect device_clip_bounds;
FloatRect clipped_rect;
if (getDeviceClipBounds(&device_clip_bounds) &&
device_rect.intersect(SkRect::Make(device_clip_bounds)))
clipped_rect = device_rect;
unsigned paint_alpha = static_cast<unsigned>(paint.getAlpha());
SkPaint paint_with_alpha(paint);
paint_with_alpha.setAlpha(static_cast<U8CPU>(alpha_ * paint_alpha / 255));
quad_with_color.color = Color(paint_with_alpha.getColor());
quads_.push_back(quad_with_color);
SkCanvas::onDrawRect(clipped_rect, paint);
Color color = Color(paint_with_alpha.getColor());
rects_.emplace_back(clipped_rect, color);
SkCanvas::onDrawRect(rect, paint);
}
SkCanvas::SaveLayerStrategy getSaveLayerStrategy(
......@@ -70,8 +66,6 @@ class DrawsRectangleCanvas : public SkCanvas {
void willRestore() override {
DCHECK_GT(save_count_, 0);
if (clips_.size() && save_count_ == clips_.back().save_count)
clips_.pop_back();
if (alpha_save_layer_count_ == save_count_) {
alpha_ = 255;
alpha_save_layer_count_ = -1;
......@@ -80,24 +74,8 @@ class DrawsRectangleCanvas : public SkCanvas {
SkCanvas::willRestore();
}
void onClipRect(const SkRect& rect,
SkClipOp op,
ClipEdgeStyle style) override {
ClipAndIndex clip_struct;
clip_struct.rect = rect;
clip_struct.save_count = save_count_;
clips_.push_back(clip_struct);
SkCanvas::onClipRect(rect, op, style);
}
struct ClipAndIndex {
SkRect rect;
int save_count;
};
private:
Vector<QuadWithColor> quads_;
Vector<ClipAndIndex> clips_;
Vector<RectWithColor> rects_;
int save_count_;
unsigned alpha_;
int alpha_save_layer_count_;
......@@ -114,24 +92,24 @@ class DrawsRectanglesMatcher
::testing::MatchResultListener* listener) const override {
DrawsRectangleCanvas canvas;
picture.playback(&canvas);
const auto& quads = canvas.QuadsWithColor();
if (quads.size() != rects_with_color_.size()) {
*listener << "which draws " << quads.size() << " quads";
const auto& actual_rects = canvas.RectsWithColor();
if (actual_rects.size() != rects_with_color_.size()) {
*listener << "which draws " << actual_rects.size() << " rects";
return false;
}
for (unsigned index = 0; index < quads.size(); index++) {
const auto& quad_with_color = quads[index];
const auto& rect_with_color = rects_with_color_[index];
for (unsigned index = 0; index < actual_rects.size(); index++) {
const auto& actual_rect_with_color = actual_rects[index];
const auto& expect_rect_with_color = rects_with_color_[index];
const FloatRect& rect = quad_with_color.quad.BoundingBox();
if (EnclosingIntRect(rect) != EnclosingIntRect(rect_with_color.rect) ||
quad_with_color.color != rect_with_color.color) {
if (EnclosingIntRect(actual_rect_with_color.rect) !=
EnclosingIntRect(expect_rect_with_color.rect) ||
actual_rect_with_color.color != expect_rect_with_color.color) {
if (listener->IsInterested()) {
*listener << "at index " << index << " which draws ";
PrintTo(rect, listener->stream());
PrintTo(actual_rect_with_color.rect, listener->stream());
*listener << " with color "
<< quad_with_color.color.Serialized().Ascii().data()
<< actual_rect_with_color.color.Serialized().Ascii().data()
<< "\n";
}
return false;
......
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