Commit 4e267b10 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

[SPv175] Pixel-snap clips in PaintPropertyTreeBuilder.

In SPv175 mode, we know the precise subpixel positions of every object
relative to its composited backing. Therefore we can apply pixel
snapping during pre-paint. This is also necessary because the paint
code can no longer do this pixel-snapping in SPv175 mode, as the
paired display item serialization happens in PaintChunksToCcLayer,
which by design knows nothing about paint offsets or snapping.

To support testing this in SPv1 mode, also add testing of that mode
to PaintPropertyTreeBuilderTest.cpp, and adjust test results accordingly.

Bug: 804010
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I9f2dbc13237c9aa6919faa6835f59ec465a06508
Reviewed-on: https://chromium-review.googlesource.com/896602
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533853}
parent 9b60ddbd
......@@ -30,6 +30,11 @@ LayerClipRecorder::LayerClipRecorder(GraphicsContext& graphics_context,
if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled())
return;
IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect());
#if DCHECK_IS_ON
// In SPv175+ mode, clip rects are pre-snapped.
if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled())
DCHECK(FloatRect(snapped_clip_rect) == clip_rect.Rect());
#endif
bool painting_masks =
(paint_flags & kPaintLayerPaintingChildClippingMaskPhase ||
paint_flags & kPaintLayerPaintingAncestorClippingMaskPhase);
......
......@@ -859,6 +859,12 @@ static bool NeedsCssClip(const LayoutObject& object) {
return object.HasClip();
}
static FloatRoundedRect ToClipRect(const LayoutRect& rect) {
if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled())
return FloatRoundedRect(FloatRect(PixelSnappedIntRect(rect)));
return FloatRoundedRect(FloatRect(rect));
}
void FragmentPaintPropertyTreeBuilder::UpdateCssClip() {
DCHECK(properties_);
......@@ -869,11 +875,10 @@ void FragmentPaintPropertyTreeBuilder::UpdateCssClip() {
// object must be a container for absolute position descendants, and will
// copy from in-flow context later at updateOutOfFlowContext() step.
DCHECK(object_.CanContainAbsolutePositionObjects());
LayoutRect clip_rect =
ToLayoutBox(object_).ClipRect(context_.current.paint_offset);
OnUpdateClip(properties_->UpdateCssClip(
context_.current.clip, context_.current.transform,
FloatRoundedRect(FloatRect(clip_rect))));
ToClipRect(
ToLayoutBox(object_).ClipRect(context_.current.paint_offset))));
} else {
OnClearClip(properties_->ClearCssClip());
}
......@@ -973,8 +978,8 @@ void FragmentPaintPropertyTreeBuilder::UpdateOverflowControlsClip() {
// Clip overflow controls to the border box rect.
properties_->UpdateOverflowControlsClip(
context_.current.clip, context_.current.transform,
FloatRoundedRect(FloatRect(LayoutRect(context_.current.paint_offset,
ToLayoutBox(object_).Size()))));
ToClipRect(LayoutRect(context_.current.paint_offset,
ToLayoutBox(object_).Size())));
} else {
properties_->ClearOverflowControlsClip();
}
......@@ -1023,17 +1028,15 @@ void FragmentPaintPropertyTreeBuilder::UpdateOverflowClip() {
FloatRoundedRect clip_rect;
FloatRoundedRect clip_rect_excluding_overlay_scrollbars;
if (object_.IsSVGForeignObject()) {
clip_rect =
FloatRoundedRect(FloatRect(ToLayoutBox(object_).FrameRect()));
clip_rect = ToClipRect(ToLayoutBox(object_).FrameRect());
clip_rect_excluding_overlay_scrollbars = clip_rect;
} else if (object_.IsBox()) {
clip_rect =
FloatRoundedRect(FloatRect(ToLayoutBox(object_).OverflowClipRect(
context_.current.paint_offset)));
clip_rect = ToClipRect(ToLayoutBox(object_).OverflowClipRect(
context_.current.paint_offset));
clip_rect_excluding_overlay_scrollbars =
FloatRoundedRect(FloatRect(ToLayoutBox(object_).OverflowClipRect(
ToClipRect(ToLayoutBox(object_).OverflowClipRect(
context_.current.paint_offset,
kExcludeOverlayScrollbarSizeForHitTesting)));
kExcludeOverlayScrollbarSizeForHitTesting));
} else {
DCHECK(object_.IsSVGViewportContainer());
const auto& viewport_container = ToLayoutSVGViewportContainer(object_);
......
......@@ -46,6 +46,14 @@ static constexpr unsigned kSlimmingPaintNonV1TestConfigurations[] = {
kSlimmingPaintV2, kSlimmingPaintV2 | kRootLayerScrolling,
};
static constexpr unsigned kAllSlimmingPaintTestConfigurations[] = {
0,
kSlimmingPaintV175,
kSlimmingPaintV175 | kRootLayerScrolling,
kSlimmingPaintV2,
kSlimmingPaintV2 | kRootLayerScrolling,
};
static constexpr unsigned kSlimmingPaintV2TestConfigurations[] = {
kSlimmingPaintV2, kSlimmingPaintV2 | kRootLayerScrolling,
};
......
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