Commit 20b8daba authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

Clipping and fragmentation code cleanup.

1. Remove an unused method from PaintLayerClipper.
2. Don't conditionally set cache slots which are ignored anyway for PaintLayerClipper
use-cases that use GeometryMapper.
3. Remove unnecessary pagination_clip parameter in PaintLayerFragment.

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I6cd7b8646ac68873a245c76813ec3723d48858c9
Reviewed-on: https://chromium-review.googlesource.com/595109
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarWalter Korman <wkorman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491162}
parent 75a8d05e
...@@ -24,7 +24,7 @@ enum ClipRectsCacheSlot { ...@@ -24,7 +24,7 @@ enum ClipRectsCacheSlot {
// Relative to the LayoutView's layer. Used for compositing overlap testing. // Relative to the LayoutView's layer. Used for compositing overlap testing.
kAbsoluteClipRects, kAbsoluteClipRects,
// Relative to painting ancestor. Used for painting. // Relative to painting ancestor. Used for SPv1 compositing.
kPaintingClipRects, kPaintingClipRects,
kPaintingClipRectsIgnoringOverflowClip, kPaintingClipRectsIgnoringOverflowClip,
......
...@@ -1745,7 +1745,7 @@ void PaintLayer::CollectFragments( ...@@ -1745,7 +1745,7 @@ void PaintLayer::CollectFragments(
for (; !iterator.AtEnd(); iterator.Advance()) { for (; !iterator.AtEnd(); iterator.Advance()) {
PaintLayerFragment fragment; PaintLayerFragment fragment;
fragment.pagination_offset = ToLayoutPoint(iterator.PaginationOffset()); fragment.pagination_offset = ToLayoutPoint(iterator.PaginationOffset());
fragment.pagination_clip = iterator.ClipRectInFlowThread(); LayoutRect pagination_clip = iterator.ClipRectInFlowThread();
// Set our four rects with all clipping applied that was internal to the // Set our four rects with all clipping applied that was internal to the
// flow thread. // flow thread.
...@@ -1755,9 +1755,11 @@ void PaintLayer::CollectFragments( ...@@ -1755,9 +1755,11 @@ void PaintLayer::CollectFragments(
// Shift to the root-relative physical position used when painting the flow // Shift to the root-relative physical position used when painting the flow
// thread in this fragment. // thread in this fragment.
fragment.MoveBy(fragment.pagination_offset + LayoutPoint offset = fragment.pagination_offset +
offset_of_pagination_layer_from_root + offset_of_pagination_layer_from_root +
sub_pixel_accumulation_if_needed); sub_pixel_accumulation_if_needed;
fragment.MoveBy(offset);
pagination_clip.MoveBy(offset);
// Intersect the fragment with our ancestor's background clip so that e.g., // Intersect the fragment with our ancestor's background clip so that e.g.,
// columns in an overflow:hidden block are properly clipped by the overflow. // columns in an overflow:hidden block are properly clipped by the overflow.
...@@ -1766,7 +1768,7 @@ void PaintLayer::CollectFragments( ...@@ -1766,7 +1768,7 @@ void PaintLayer::CollectFragments(
// Now intersect with our pagination clip. This will typically mean we're // Now intersect with our pagination clip. This will typically mean we're
// just intersecting the dirty rect with the column clip, so the column clip // just intersecting the dirty rect with the column clip, so the column clip
// ends up being all we apply. // ends up being all we apply.
fragment.Intersect(fragment.pagination_clip); fragment.Intersect(pagination_clip);
// TODO(mstensho): Don't add empty fragments. We've always done that in some // TODO(mstensho): Don't add empty fragments. We've always done that in some
// cases, but there should be no reason to do so. Either filter them out // cases, but there should be no reason to do so. Either filter them out
...@@ -2199,8 +2201,8 @@ bool PaintLayer::HitTestContentsForFragments( ...@@ -2199,8 +2201,8 @@ bool PaintLayer::HitTestContentsForFragments(
!fragment.foreground_rect.Intersects(hit_test_location))) !fragment.foreground_rect.Intersects(hit_test_location)))
continue; continue;
inside_clip_rect = true; inside_clip_rect = true;
if (HitTestContents(result, fragment.layer_bounds, hit_test_location, if (HitTestContents(result, fragment.layer_bounds.Location(),
hit_test_filter)) hit_test_location, hit_test_filter))
return true; return true;
} }
...@@ -2308,14 +2310,14 @@ PaintLayer* PaintLayer::HitTestLayerByApplyingTransform( ...@@ -2308,14 +2310,14 @@ PaintLayer* PaintLayer::HitTestLayerByApplyingTransform(
} }
bool PaintLayer::HitTestContents(HitTestResult& result, bool PaintLayer::HitTestContents(HitTestResult& result,
const LayoutRect& layer_bounds, const LayoutPoint& fragment_offset,
const HitTestLocation& hit_test_location, const HitTestLocation& hit_test_location,
HitTestFilter hit_test_filter) const { HitTestFilter hit_test_filter) const {
DCHECK(IsSelfPaintingLayer() || HasSelfPaintingLayerDescendant()); DCHECK(IsSelfPaintingLayer() || HasSelfPaintingLayerDescendant());
if (!GetLayoutObject().HitTest( if (!GetLayoutObject().HitTest(
result, hit_test_location, result, hit_test_location,
ToLayoutPoint(layer_bounds.Location() - LayoutBoxLocation()), ToLayoutPoint(fragment_offset - LayoutBoxLocation()),
hit_test_filter)) { hit_test_filter)) {
// It's wrong to set innerNode, but then claim that you didn't hit anything, // It's wrong to set innerNode, but then claim that you didn't hit anything,
// unless it is a rect-based test. // unless it is a rect-based test.
......
...@@ -1078,7 +1078,7 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient { ...@@ -1078,7 +1078,7 @@ class CORE_EXPORT PaintLayer : public DisplayItemClient {
const LayoutPoint& translation_offset = LayoutPoint()) const; const LayoutPoint& translation_offset = LayoutPoint()) const;
bool HitTestContents(HitTestResult&, bool HitTestContents(HitTestResult&,
const LayoutRect& layer_bounds, const LayoutPoint& fragment_offset,
const HitTestLocation&, const HitTestLocation&,
HitTestFilter) const; HitTestFilter) const;
bool HitTestContentsForFragments(const PaintLayerFragments&, bool HitTestContentsForFragments(const PaintLayerFragments&,
......
...@@ -585,17 +585,4 @@ bool PaintLayerClipper::ShouldClipOverflow( ...@@ -585,17 +585,4 @@ bool PaintLayerClipper::ShouldClipOverflow(
return HasOverflowClip(layer_); return HasOverflowClip(layer_);
} }
ClipRects& PaintLayerClipper::PaintingClipRects(
const PaintLayer* root_layer,
ShouldRespectOverflowClipType respect_overflow_clip,
const LayoutSize& subpixel_accumulation) const {
DCHECK(!use_geometry_mapper_);
ClipRectsContext context(root_layer, kPaintingClipRects,
kIgnorePlatformOverlayScrollbarSize,
subpixel_accumulation);
if (respect_overflow_clip == kIgnoreOverflowClip)
context.SetIgnoreOverflowClip();
return GetClipRects(context);
}
} // namespace blink } // namespace blink
...@@ -205,10 +205,6 @@ class CORE_EXPORT PaintLayerClipper { ...@@ -205,10 +205,6 @@ class CORE_EXPORT PaintLayerClipper {
ClipRect& foreground_rect, ClipRect& foreground_rect,
const LayoutPoint* offset_from_root = 0) const; const LayoutPoint* offset_from_root = 0) const;
ClipRects& PaintingClipRects(const PaintLayer* root_layer,
ShouldRespectOverflowClipType,
const LayoutSize& subpixel_accumulation) const;
private: private:
void ClearCache(ClipRectsCacheSlot); void ClearCache(ClipRectsCacheSlot);
ClipRects& GetClipRects(const ClipRectsContext&) const; ClipRects& GetClipRects(const ClipRectsContext&) const;
......
...@@ -271,7 +271,7 @@ TEST_F(PaintLayerClipperTest, ContainPaintClip) { ...@@ -271,7 +271,7 @@ TEST_F(PaintLayerClipperTest, ContainPaintClip) {
EXPECT_EQ(background_rect.Rect(), foreground_rect.Rect()); EXPECT_EQ(background_rect.Rect(), foreground_rect.Rect());
EXPECT_EQ(LayoutRect(0, 0, 200, 200), layer_bounds); EXPECT_EQ(LayoutRect(0, 0, 200, 200), layer_bounds);
ClipRectsContext context_clip(layer, kPaintingClipRects); ClipRectsContext context_clip(layer, kUncachedClipRects);
layer->Clipper(PaintLayer::kUseGeometryMapper) layer->Clipper(PaintLayer::kUseGeometryMapper)
.CalculateRects(context_clip, infinite_rect, layer_bounds, .CalculateRects(context_clip, infinite_rect, layer_bounds,
...@@ -304,7 +304,7 @@ TEST_F(PaintLayerClipperTest, NestedContainPaintClip) { ...@@ -304,7 +304,7 @@ TEST_F(PaintLayerClipperTest, NestedContainPaintClip) {
EXPECT_EQ(LayoutRect(0, 0, 200, 400), foreground_rect.Rect()); EXPECT_EQ(LayoutRect(0, 0, 200, 400), foreground_rect.Rect());
EXPECT_EQ(LayoutRect(0, 0, 200, 400), layer_bounds); EXPECT_EQ(LayoutRect(0, 0, 200, 400), layer_bounds);
ClipRectsContext context_clip(layer->Parent(), kPaintingClipRects); ClipRectsContext context_clip(layer->Parent(), kUncachedClipRects);
layer->Clipper(PaintLayer::kUseGeometryMapper) layer->Clipper(PaintLayer::kUseGeometryMapper)
.CalculateRects(context_clip, infinite_rect, layer_bounds, .CalculateRects(context_clip, infinite_rect, layer_bounds,
......
...@@ -59,7 +59,6 @@ struct PaintLayerFragment { ...@@ -59,7 +59,6 @@ struct PaintLayerFragment {
layer_bounds.MoveBy(offset); layer_bounds.MoveBy(offset);
background_rect.MoveBy(offset); background_rect.MoveBy(offset);
foreground_rect.MoveBy(offset); foreground_rect.MoveBy(offset);
pagination_clip.MoveBy(offset);
} }
void Intersect(const LayoutRect& rect) { void Intersect(const LayoutRect& rect) {
...@@ -108,15 +107,6 @@ struct PaintLayerFragment { ...@@ -108,15 +107,6 @@ struct PaintLayerFragment {
// The physical translation to apply to shift the layer when // The physical translation to apply to shift the layer when
// painting/hit-testing. // painting/hit-testing.
LayoutPoint pagination_offset; LayoutPoint pagination_offset;
// Only set on paginated fragments.
//
// This is the additional clip from the fragmentainer (i.e. column or
// page) that applies to the layer. |backgroundRect| and |foregroundRect|
// are intersected with it (see collectFragments).
//
// It is in layer-local (physical) coordinates.
LayoutRect pagination_clip;
}; };
typedef Vector<PaintLayerFragment, 1> PaintLayerFragments; typedef Vector<PaintLayerFragment, 1> PaintLayerFragments;
......
...@@ -409,9 +409,6 @@ PaintResult PaintLayerPainter::PaintLayerContents( ...@@ -409,9 +409,6 @@ PaintResult PaintLayerPainter::PaintLayerContents(
!is_painting_overlay_scrollbars; !is_painting_overlay_scrollbars;
PaintLayerFragments layer_fragments; PaintLayerFragments layer_fragments;
ClipRectsCacheSlot cache_slot = (paint_flags & kPaintLayerUncachedClipRects)
? kUncachedClipRects
: kPaintingClipRects;
if (should_paint_content || should_paint_self_outline || if (should_paint_content || should_paint_self_outline ||
is_painting_overlay_scrollbars) { is_painting_overlay_scrollbars) {
...@@ -445,7 +442,7 @@ PaintResult PaintLayerPainter::PaintLayerContents( ...@@ -445,7 +442,7 @@ PaintResult PaintLayerPainter::PaintLayerContents(
RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) { RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) {
paint_layer_for_fragments->AppendSingleFragmentIgnoringPagination( paint_layer_for_fragments->AppendSingleFragmentIgnoringPagination(
layer_fragments, local_painting_info.root_layer, layer_fragments, local_painting_info.root_layer,
local_painting_info.paint_dirty_rect, cache_slot, local_painting_info.paint_dirty_rect, kUncachedClipRects,
PaintLayer::kUseGeometryMapper, kIgnorePlatformOverlayScrollbarSize, PaintLayer::kUseGeometryMapper, kIgnorePlatformOverlayScrollbarSize,
respect_overflow_clip, &offset_from_root, respect_overflow_clip, &offset_from_root,
local_painting_info.sub_pixel_accumulation); local_painting_info.sub_pixel_accumulation);
...@@ -453,7 +450,7 @@ PaintResult PaintLayerPainter::PaintLayerContents( ...@@ -453,7 +450,7 @@ PaintResult PaintLayerPainter::PaintLayerContents(
PaintLayerFragments single_fragment; PaintLayerFragments single_fragment;
paint_layer_for_fragments->AppendSingleFragmentIgnoringPagination( paint_layer_for_fragments->AppendSingleFragmentIgnoringPagination(
single_fragment, local_painting_info.root_layer, single_fragment, local_painting_info.root_layer,
local_painting_info.paint_dirty_rect, cache_slot, local_painting_info.paint_dirty_rect, kUncachedClipRects,
PaintLayer::kUseGeometryMapper, kIgnorePlatformOverlayScrollbarSize, PaintLayer::kUseGeometryMapper, kIgnorePlatformOverlayScrollbarSize,
respect_overflow_clip, &offset_from_root, respect_overflow_clip, &offset_from_root,
local_painting_info.sub_pixel_accumulation); local_painting_info.sub_pixel_accumulation);
...@@ -487,7 +484,7 @@ PaintResult PaintLayerPainter::PaintLayerContents( ...@@ -487,7 +484,7 @@ PaintResult PaintLayerPainter::PaintLayerContents(
} else { } else {
paint_layer_for_fragments->CollectFragments( paint_layer_for_fragments->CollectFragments(
layer_fragments, local_painting_info.root_layer, layer_fragments, local_painting_info.root_layer,
local_painting_info.paint_dirty_rect, cache_slot, local_painting_info.paint_dirty_rect, kUncachedClipRects,
PaintLayer::kUseGeometryMapper, kIgnorePlatformOverlayScrollbarSize, PaintLayer::kUseGeometryMapper, kIgnorePlatformOverlayScrollbarSize,
respect_overflow_clip, &offset_from_root, respect_overflow_clip, &offset_from_root,
local_painting_info.sub_pixel_accumulation); local_painting_info.sub_pixel_accumulation);
...@@ -551,7 +548,7 @@ PaintResult PaintLayerPainter::PaintLayerContents( ...@@ -551,7 +548,7 @@ PaintResult PaintLayerPainter::PaintLayerContents(
PaintLayerFragments filter_fragments; PaintLayerFragments filter_fragments;
paint_layer_.AppendSingleFragmentIgnoringPagination( paint_layer_.AppendSingleFragmentIgnoringPagination(
filter_fragments, local_painting_info.root_layer, filter_fragments, local_painting_info.root_layer,
local_painting_info.paint_dirty_rect, cache_slot, local_painting_info.paint_dirty_rect, kUncachedClipRects,
PaintLayer::kUseGeometryMapper, kIgnorePlatformOverlayScrollbarSize, PaintLayer::kUseGeometryMapper, kIgnorePlatformOverlayScrollbarSize,
respect_overflow_clip, &offset_from_root, respect_overflow_clip, &offset_from_root,
local_painting_info.sub_pixel_accumulation); local_painting_info.sub_pixel_accumulation);
...@@ -748,12 +745,6 @@ PaintResult PaintLayerPainter::PaintLayerWithTransform( ...@@ -748,12 +745,6 @@ PaintResult PaintLayerPainter::PaintLayerWithTransform(
else else
layer_fragments.push_back(fragment); layer_fragments.push_back(fragment);
} else { } else {
// FIXME: This is a mess. Look closely at this code and the code in Layer
// and fix any issues in it & refactor to make it obvious from code
// structure what it does and that it's correct.
ClipRectsCacheSlot cache_slot = (paint_flags & kPaintLayerUncachedClipRects)
? kUncachedClipRects
: kPaintingClipRects;
ShouldRespectOverflowClipType respect_overflow_clip = ShouldRespectOverflowClipType respect_overflow_clip =
ShouldRespectOverflowClip(paint_flags, paint_layer_.GetLayoutObject()); ShouldRespectOverflowClip(paint_flags, paint_layer_.GetLayoutObject());
// Calculate the transformed bounding box in the current coordinate space, // Calculate the transformed bounding box in the current coordinate space,
...@@ -770,7 +761,7 @@ PaintResult PaintLayerPainter::PaintLayerWithTransform( ...@@ -770,7 +761,7 @@ PaintResult PaintLayerPainter::PaintLayerWithTransform(
// here. // here.
pagination_layer->CollectFragments( pagination_layer->CollectFragments(
layer_fragments, painting_info.root_layer, layer_fragments, painting_info.root_layer,
painting_info.paint_dirty_rect, cache_slot, painting_info.paint_dirty_rect, kUncachedClipRects,
PaintLayer::kUseGeometryMapper, kIgnorePlatformOverlayScrollbarSize, PaintLayer::kUseGeometryMapper, kIgnorePlatformOverlayScrollbarSize,
respect_overflow_clip, nullptr, painting_info.sub_pixel_accumulation, respect_overflow_clip, nullptr, painting_info.sub_pixel_accumulation,
&transformed_extent); &transformed_extent);
...@@ -799,12 +790,10 @@ PaintResult PaintLayerPainter::PaintLayerWithTransform( ...@@ -799,12 +790,10 @@ PaintResult PaintLayerPainter::PaintLayerWithTransform(
ancestor_background_clip_rect.SetRect(FloatClipRect()); ancestor_background_clip_rect.SetRect(FloatClipRect());
} else if (parent_layer) { } else if (parent_layer) {
// Calculate the clip rectangle that the ancestors establish. // Calculate the clip rectangle that the ancestors establish.
ClipRectsContext clip_rects_context( ClipRectsContext clip_rects_context(painting_info.root_layer,
painting_info.root_layer, kUncachedClipRects,
(paint_flags & kPaintLayerUncachedClipRects) ? kUncachedClipRects kIgnorePlatformOverlayScrollbarSize,
: kPaintingClipRects, painting_info.sub_pixel_accumulation);
kIgnorePlatformOverlayScrollbarSize,
painting_info.sub_pixel_accumulation);
if (ShouldRespectOverflowClip(paint_flags, if (ShouldRespectOverflowClip(paint_flags,
paint_layer_.GetLayoutObject()) == paint_layer_.GetLayoutObject()) ==
kIgnoreOverflowClip) kIgnoreOverflowClip)
......
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