Commit bb9ca87d authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[rm-for-spv175] Fold the only function in LayerClipRecorder into the only caller

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ic96ed128f4925cf32c3028932dca369033eec300
Reviewed-on: https://chromium-review.googlesource.com/1112952
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570071}
parent 628bcf8f
...@@ -115,8 +115,6 @@ blink_core_sources("paint") { ...@@ -115,8 +115,6 @@ blink_core_sources("paint") {
"inline_painter.h", "inline_painter.h",
"inline_text_box_painter.cc", "inline_text_box_painter.cc",
"inline_text_box_painter.h", "inline_text_box_painter.h",
"layer_clip_recorder.cc",
"layer_clip_recorder.h",
"line_box_list_painter.cc", "line_box_list_painter.cc",
"line_box_list_painter.h", "line_box_list_painter.h",
"link_highlight_impl.cc", "link_highlight_impl.cc",
......
...@@ -59,7 +59,6 @@ ...@@ -59,7 +59,6 @@
#include "third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.h" #include "third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.h"
#include "third_party/blink/renderer/core/paint/css_mask_painter.h" #include "third_party/blink/renderer/core/paint/css_mask_painter.h"
#include "third_party/blink/renderer/core/paint/frame_paint_timing.h" #include "third_party/blink/renderer/core/paint/frame_paint_timing.h"
#include "third_party/blink/renderer/core/paint/layer_clip_recorder.h"
#include "third_party/blink/renderer/core/paint/object_paint_invalidator.h" #include "third_party/blink/renderer/core/paint/object_paint_invalidator.h"
#include "third_party/blink/renderer/core/paint/paint_info.h" #include "third_party/blink/renderer/core/paint/paint_info.h"
#include "third_party/blink/renderer/core/paint/paint_layer_painter.h" #include "third_party/blink/renderer/core/paint/paint_layer_painter.h"
...@@ -567,27 +566,63 @@ void CompositedLayerMapping::UpdateCompositingReasons() { ...@@ -567,27 +566,63 @@ void CompositedLayerMapping::UpdateCompositingReasons() {
owning_layer_.GetSquashingDisallowedReasons()); owning_layer_.GetSquashingDisallowedReasons());
} }
static bool InContainingBlockChain(const PaintLayer* start_layer,
const PaintLayer* end_layer) {
if (start_layer == end_layer)
return true;
LayoutView* view = start_layer->GetLayoutObject().View();
for (const LayoutBlock* current_block =
start_layer->GetLayoutObject().ContainingBlock();
current_block && current_block != view;
current_block = current_block->ContainingBlock()) {
if (current_block->Layer() == end_layer)
return true;
}
return false;
}
bool CompositedLayerMapping::AncestorRoundedCornersWillClip( bool CompositedLayerMapping::AncestorRoundedCornersWillClip(
const FloatRect& bounds_in_ancestor_space) const { const FloatRect& bounds_in_ancestor_space) const {
// Collect all border-radius clips between us and the state we inherited. // Check border-radius clips between us and the state we inherited.
LayoutPoint zero_offset; for (const PaintLayer* layer = owning_layer_.Parent(); layer;
Vector<FloatRoundedRect> rounded_rect_clips; layer = layer->Parent()) {
LayerClipRecorder::CollectRoundedRectClips( // Check clips for embedded content despite their lack of overflow,
owning_layer_, clip_inheritance_ancestor_, zero_offset, true, // because in practice they do need to clip. However, the clip is only
LayerClipRecorder::kDoNotIncludeSelfForBorderRadius, rounded_rect_clips); // used when painting child clipping masks to avoid clipping out border
// decorations.
for (auto clip_rect : rounded_rect_clips) { if ((layer->GetLayoutObject().HasOverflowClip() ||
FloatRect inner_clip_rect = clip_rect.RadiusCenterRect(); layer->GetLayoutObject().IsLayoutEmbeddedContent()) &&
// The first condition catches cases where the child is certainly inside layer->GetLayoutObject().Style()->HasBorderRadius() &&
// the rounded corner portion of the border, and cannot be clipped by InContainingBlockChain(&owning_layer_, layer)) {
// the rounded portion. The second catches cases where the child is LayoutPoint delta;
// entirely outside the rectangular border (ignoring rounded corners) so layer->ConvertToLayerCoords(clip_inheritance_ancestor_, delta);
// is also unaffected by the rounded corners. In both cases the existing
// rectangular clip is adequate and the mask is unnecessary. // The PaintLayer's size is pixel-snapped if it is a LayoutBox. We can't
if (!inner_clip_rect.Contains(bounds_in_ancestor_space) && // use a pre-snapped border rect for clipping, since
bounds_in_ancestor_space.Intersects(clip_rect.Rect())) { // getRoundedInnerBorderFor assumes it has not been snapped yet.
return true; LayoutSize size(layer->GetLayoutBox()
? ToLayoutBox(layer->GetLayoutObject()).Size()
: LayoutSize(layer->Size()));
auto clip_rect =
layer->GetLayoutObject().StyleRef().GetRoundedInnerBorderFor(
LayoutRect(delta, size));
auto inner_clip_rect = clip_rect.RadiusCenterRect();
// The first condition catches cases where the child is certainly inside
// the rounded corner portion of the border, and cannot be clipped by
// the rounded portion. The second catches cases where the child is
// entirely outside the rectangular border (ignoring rounded corners) so
// is also unaffected by the rounded corners. In both cases the existing
// rectangular clip is adequate and the mask is unnecessary.
if (!inner_clip_rect.Contains(bounds_in_ancestor_space) &&
bounds_in_ancestor_space.Intersects(clip_rect.Rect())) {
return true;
}
} }
if (layer == clip_inheritance_ancestor_)
break;
} }
return false; return false;
} }
...@@ -1099,7 +1134,7 @@ void CompositedLayerMapping::UpdateSquashingLayerGeometry( ...@@ -1099,7 +1134,7 @@ void CompositedLayerMapping::UpdateSquashingLayerGeometry(
// We can't squashing_layer_->SetOffsetFromLayoutObject(). // We can't squashing_layer_->SetOffsetFromLayoutObject().
// Squashing layer has special paint and invalidation logic that already // Squashing layer has special paint and invalidation logic that already
// compensated for compositing bounds, setting it here would end up // compensated for compositing bounds, setting it here would end up
// double adjustment. The value is stored to be used by SPv175. // double adjustment.
auto new_offset = squash_layer_bounds.Location() - auto new_offset = squash_layer_bounds.Location() -
snapped_offset_from_composited_ancestor + snapped_offset_from_composited_ancestor +
ToIntSize(graphics_layer_parent_location); ToIntSize(graphics_layer_parent_location);
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/paint/layer_clip_recorder.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/platform/geometry/int_rect.h"
namespace blink {
static bool InContainingBlockChain(const PaintLayer* start_layer,
const PaintLayer* end_layer) {
if (start_layer == end_layer)
return true;
LayoutView* view = start_layer->GetLayoutObject().View();
for (const LayoutBlock* current_block =
start_layer->GetLayoutObject().ContainingBlock();
current_block && current_block != view;
current_block = current_block->ContainingBlock()) {
if (current_block->Layer() == end_layer)
return true;
}
return false;
}
void LayerClipRecorder::CollectRoundedRectClips(
const PaintLayer& paint_layer,
const PaintLayer* clip_root,
const LayoutPoint& fragment_offset,
bool cross_composited_scrollers,
BorderRadiusClippingRule rule,
Vector<FloatRoundedRect>& rounded_rect_clips) {
// If the clip rect has been tainted by a border radius, then we have to walk
// up our layer chain applying the clips from any layers with overflow. The
// condition for being able to apply these clips is that the overflow object
// be in our containing block chain so we check that also.
for (const PaintLayer* layer = rule == kIncludeSelfForBorderRadius
? &paint_layer
: paint_layer.Parent();
layer; layer = layer->Parent()) {
// Composited scrolling layers handle border-radius clip in the compositor
// via a mask layer. We do not want to apply a border-radius clip to the
// layer contents itself, because that would require re-rastering every
// frame to update the clip. We only want to make sure that the mask layer
// is properly clipped so that it can in turn clip the scrolled contents in
// the compositor.
if (!cross_composited_scrollers && layer->NeedsCompositedScrolling())
break;
// Collect clips for embedded content despite their lack of overflow,
// because in practice they do need to clip. However, the clip is only
// used when painting child clipping masks to avoid clipping out border
// decorations.
if ((layer->GetLayoutObject().HasOverflowClip() ||
layer->GetLayoutObject().IsLayoutEmbeddedContent()) &&
layer->GetLayoutObject().Style()->HasBorderRadius() &&
InContainingBlockChain(&paint_layer, layer)) {
LayoutPoint delta;
if (layer->EnclosingPaginationLayer() ==
paint_layer.EnclosingPaginationLayer())
delta.MoveBy(fragment_offset);
layer->ConvertToLayerCoords(clip_root, delta);
// The PaintLayer's size is pixel-snapped if it is a LayoutBox. We can't
// use a pre-snapped border rect for clipping, since
// getRoundedInnerBorderFor assumes it has not been snapped yet.
LayoutSize size(layer->GetLayoutBox()
? ToLayoutBox(layer->GetLayoutObject()).Size()
: LayoutSize(layer->Size()));
rounded_rect_clips.push_back(
layer->GetLayoutObject().Style()->GetRoundedInnerBorderFor(
LayoutRect(delta, size)));
}
if (layer == clip_root)
break;
}
}
} // namespace blink
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_LAYER_CLIP_RECORDER_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_LAYER_CLIP_RECORDER_H_
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
class FloatRoundedRect;
class LayoutPoint;
class PaintLayer;
// TODO(wangxianzhu): Either rename the class, or merge the code into the only
// caller of LayerClipRecorder::CollectRoundedRectClips().
class CORE_EXPORT LayerClipRecorder {
public:
enum BorderRadiusClippingRule {
kIncludeSelfForBorderRadius,
kDoNotIncludeSelfForBorderRadius
};
// Build a vector of the border radius clips that should be applied to
// the given PaintLayer, walking up the paint layer tree to the clip_root.
// The fragment_offset is an offset to apply to the clip to position it
// in the required clipping coordinates (for cases when the painting
// coordinate system is offset from the layer coordinate system).
// cross_composited_scrollers should be true when the search for clips should
// continue even if the clipping layer is painting into a composited scrolling
// layer, as when painting a mask for a child of the scroller.
// The BorderRadiusClippingRule defines whether clips on the PaintLayer itself
// are included. Output is appended to rounded_rect_clips.
static void CollectRoundedRectClips(
const PaintLayer&,
const PaintLayer* clip_root,
const LayoutPoint& fragment_offset,
bool cross_composited_scrollers,
BorderRadiusClippingRule,
Vector<FloatRoundedRect>& rounded_rect_clips);
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_LAYER_CLIP_RECORDER_H_
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "third_party/blink/renderer/core/layout/layout_view.h" #include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/paint/clip_path_clipper.h" #include "third_party/blink/renderer/core/paint/clip_path_clipper.h"
#include "third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h" #include "third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h"
#include "third_party/blink/renderer/core/paint/layer_clip_recorder.h"
#include "third_party/blink/renderer/core/paint/object_paint_properties.h" #include "third_party/blink/renderer/core/paint/object_paint_properties.h"
#include "third_party/blink/renderer/core/paint/paint_info.h" #include "third_party/blink/renderer/core/paint/paint_info.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h" #include "third_party/blink/renderer/core/paint/paint_layer.h"
......
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