Commit aa29446a authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Clean up PaintInfo usage in/around ScopedSVGPaintState

Since ScopedSVGPaintState no longer creates/sets up a new PaintInfo
there's no need for GetPaintInfo() an more. Replace usage of it with a
local PaintInfo reference where ScopedSVGPaintState is used.
Also drop the return value from ScopedSVGPaintState::ApplyEffects since
it always return true anyway.

Bug: 109224
Change-Id: I9f6448f3c0bedb731ea899d336f7b3ef318b951a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2440526Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#812762}
parent f29eb108
......@@ -34,13 +34,12 @@ namespace blink {
ScopedSVGPaintState::~ScopedSVGPaintState() {
if (should_paint_clip_path_as_mask_image_) {
ClipPathClipper::PaintClipPathAsMaskImage(GetPaintInfo().context, object_,
display_item_client_,
PhysicalOffset());
ClipPathClipper::PaintClipPathAsMaskImage(
paint_info_.context, object_, display_item_client_, PhysicalOffset());
}
}
bool ScopedSVGPaintState::ApplyEffects() {
void ScopedSVGPaintState::ApplyEffects() {
#if DCHECK_IS_ON()
DCHECK(!apply_effects_called_);
apply_effects_called_ = true;
......@@ -57,7 +56,7 @@ bool ScopedSVGPaintState::ApplyEffects() {
DCHECK(!object_.IsSVGRoot());
if (properties && properties->ClipPathMask())
should_paint_clip_path_as_mask_image_ = true;
return true;
return;
}
// LayoutSVGRoot and LayoutSVGForeignObject always have a self-painting
......@@ -72,8 +71,6 @@ bool ScopedSVGPaintState::ApplyEffects() {
}
ApplyMaskIfNecessary();
// TODO(fs): Change return value to void.
return true;
}
void ScopedSVGPaintState::ApplyPaintPropertyState(
......@@ -82,7 +79,6 @@ void ScopedSVGPaintState::ApplyPaintPropertyState(
// applied as stacking context effect by PaintLayerPainter.
if (object_.IsSVGRoot())
return;
auto& paint_controller = paint_info_.context.GetPaintController();
auto state = paint_controller.CurrentPaintChunkProperties();
if (const auto* filter = properties.Filter())
......
......@@ -80,23 +80,19 @@ class ScopedSVGPaintState {
public:
ScopedSVGPaintState(const LayoutObject& object, const PaintInfo& paint_info)
: ScopedSVGPaintState(object, paint_info, object) {}
ScopedSVGPaintState(const LayoutObject& object,
const PaintInfo& paint_info,
const DisplayItemClient& display_item_client)
: object_(object),
paint_info_(paint_info),
display_item_client_(display_item_client) {}
display_item_client_(display_item_client) {
if (paint_info.phase == PaintPhase::kForeground)
ApplyEffects();
}
~ScopedSVGPaintState();
const PaintInfo& GetPaintInfo() const { return paint_info_; }
// Return true if these operations aren't necessary or if they are
// successfully applied.
bool ApplyEffects();
private:
void ApplyEffects();
void ApplyPaintPropertyState(const ObjectPaintProperties&);
void ApplyMaskIfNecessary();
......
......@@ -81,25 +81,19 @@ void SVGContainerPainter::Paint(const PaintInfo& paint_info) {
ScopedSVGPaintState paint_state(layout_svg_container_,
paint_info_before_filtering);
bool continue_rendering = true;
if (paint_state.GetPaintInfo().phase == PaintPhase::kForeground)
continue_rendering = paint_state.ApplyEffects();
if (continue_rendering) {
// When a filter applies to the container we need to make sure
// that it is applied even if nothing is painted.
if (paint_state.GetPaintInfo().phase == PaintPhase::kForeground &&
properties && HasReferenceFilterEffect(*properties))
paint_state.GetPaintInfo().context.GetPaintController().EnsureChunk();
for (LayoutObject* child = layout_svg_container_.FirstChild(); child;
child = child->NextSibling()) {
if (auto* foreign_object = DynamicTo<LayoutSVGForeignObject>(*child)) {
SVGForeignObjectPainter(*foreign_object)
.PaintLayer(paint_state.GetPaintInfo());
} else {
child->Paint(paint_state.GetPaintInfo());
}
// When a filter applies to the container we need to make sure
// that it is applied even if nothing is painted.
if (paint_info_before_filtering.phase == PaintPhase::kForeground &&
properties && HasReferenceFilterEffect(*properties))
paint_info_before_filtering.context.GetPaintController().EnsureChunk();
for (LayoutObject* child = layout_svg_container_.FirstChild(); child;
child = child->NextSibling()) {
if (auto* foreign_object = DynamicTo<LayoutSVGForeignObject>(*child)) {
SVGForeignObjectPainter(*foreign_object)
.PaintLayer(paint_info_before_filtering);
} else {
child->Paint(paint_info_before_filtering);
}
}
}
......
......@@ -51,13 +51,8 @@ void SVGForeignObjectPainter::PaintLayer(const PaintInfo& paint_info) {
}
void SVGForeignObjectPainter::Paint(const PaintInfo& paint_info) {
// ScopedSVGPaintState only applies masks (and clips-within-clips) here.
ScopedSVGPaintState paint_state(layout_svg_foreign_object_, paint_info);
// ScopedSVGPaintState only applies masks (and clips-within-clips)
// here and thus does not mutate PaintInfo, so we can use the passed
// in PaintInfo below.
if (paint_info.phase == PaintPhase::kForeground &&
!paint_state.ApplyEffects())
return;
PaintTiming& timing = PaintTiming::From(
layout_svg_foreign_object_.GetElement()->GetDocument().TopDocument());
......
......@@ -43,16 +43,12 @@ void SVGImagePainter::Paint(const PaintInfo& paint_info) {
paint_info, layout_svg_image_, layout_svg_image_.LocalSVGTransform());
{
ScopedSVGPaintState paint_state(layout_svg_image_, paint_info);
if (paint_state.ApplyEffects() &&
!DrawingRecorder::UseCachedDrawingIfPossible(
paint_state.GetPaintInfo().context, layout_svg_image_,
paint_state.GetPaintInfo().phase)) {
SVGModelObjectPainter::RecordHitTestData(layout_svg_image_,
paint_state.GetPaintInfo());
SVGDrawingRecorder recorder(paint_state.GetPaintInfo().context,
layout_svg_image_,
paint_state.GetPaintInfo().phase);
PaintForeground(paint_state.GetPaintInfo());
if (!DrawingRecorder::UseCachedDrawingIfPossible(
paint_info.context, layout_svg_image_, paint_info.phase)) {
SVGModelObjectPainter::RecordHitTestData(layout_svg_image_, paint_info);
SVGDrawingRecorder recorder(paint_info.context, layout_svg_image_,
paint_info.phase);
PaintForeground(paint_info);
}
}
......
......@@ -38,13 +38,9 @@ void SVGInlineFlowBoxPainter::Paint(const PaintInfo& paint_info,
ScopedSVGPaintState paint_state(*LineLayoutAPIShim::ConstLayoutObjectFrom(
svg_inline_flow_box_.GetLineLayoutItem()),
paint_info, svg_inline_flow_box_);
if (!paint_state.ApplyEffects())
return;
for (InlineBox* child = svg_inline_flow_box_.FirstChild(); child;
child = child->NextOnLine()) {
child->Paint(paint_state.GetPaintInfo(), paint_offset, LayoutUnit(),
LayoutUnit());
}
child = child->NextOnLine())
child->Paint(paint_info, paint_offset, LayoutUnit(), LayoutUnit());
}
} // namespace blink
......@@ -46,13 +46,9 @@ void SVGRootInlineBoxPainter::Paint(const PaintInfo& paint_info,
}
ScopedSVGPaintState paint_state(layout_object, paint_info);
if (!paint_state.ApplyEffects())
return;
for (InlineBox* child = svg_root_inline_box_.FirstChild(); child;
child = child->NextOnLine()) {
child->Paint(paint_state.GetPaintInfo(), paint_offset, LayoutUnit(),
LayoutUnit());
}
child = child->NextOnLine())
child->Paint(paint_info, paint_offset, LayoutUnit(), LayoutUnit());
}
} // namespace blink
......@@ -51,11 +51,7 @@ void SVGRootPainter::PaintReplaced(const PaintInfo& paint_info,
return;
ScopedSVGPaintState paint_state(layout_svg_root_, paint_info);
if (paint_state.GetPaintInfo().phase == PaintPhase::kForeground &&
!paint_state.ApplyEffects())
return;
BoxPainter(layout_svg_root_).PaintChildren(paint_state.GetPaintInfo());
BoxPainter(layout_svg_root_).PaintChildren(paint_info);
}
} // namespace blink
......@@ -59,15 +59,11 @@ void SVGShapePainter::Paint(const PaintInfo& paint_info) {
paint_info, layout_svg_shape_, layout_svg_shape_.LocalSVGTransform());
{
ScopedSVGPaintState paint_state(layout_svg_shape_, paint_info);
if (paint_state.ApplyEffects() &&
!DrawingRecorder::UseCachedDrawingIfPossible(
paint_state.GetPaintInfo().context, layout_svg_shape_,
paint_state.GetPaintInfo().phase)) {
SVGModelObjectPainter::RecordHitTestData(layout_svg_shape_,
paint_state.GetPaintInfo());
SVGDrawingRecorder recorder(paint_state.GetPaintInfo().context,
layout_svg_shape_,
paint_state.GetPaintInfo().phase);
if (!DrawingRecorder::UseCachedDrawingIfPossible(
paint_info.context, layout_svg_shape_, paint_info.phase)) {
SVGModelObjectPainter::RecordHitTestData(layout_svg_shape_, paint_info);
SVGDrawingRecorder recorder(paint_info.context, layout_svg_shape_,
paint_info.phase);
const SVGComputedStyle& svg_style =
layout_svg_shape_.StyleRef().SvgStyle();
......@@ -79,19 +75,17 @@ void SVGShapePainter::Paint(const PaintInfo& paint_info) {
case PT_FILL: {
PaintFlags fill_flags;
if (!SVGObjectPainter(layout_svg_shape_)
.PreparePaint(paint_state.GetPaintInfo(),
layout_svg_shape_.StyleRef(),
.PreparePaint(paint_info, layout_svg_shape_.StyleRef(),
kApplyToFillMode, fill_flags))
break;
fill_flags.setAntiAlias(should_anti_alias);
FillShape(paint_state.GetPaintInfo().context, fill_flags,
FillRuleFromStyle(paint_state.GetPaintInfo(), svg_style));
FillShape(paint_info.context, fill_flags,
FillRuleFromStyle(paint_info, svg_style));
break;
}
case PT_STROKE:
if (svg_style.HasVisibleStroke()) {
GraphicsContextStateSaver state_saver(
paint_state.GetPaintInfo().context, false);
GraphicsContextStateSaver state_saver(paint_info.context, false);
AffineTransform non_scaling_transform;
const AffineTransform* additional_paint_server_transform =
nullptr;
......@@ -110,8 +104,7 @@ void SVGShapePainter::Paint(const PaintInfo& paint_info) {
PaintFlags stroke_flags;
if (!SVGObjectPainter(layout_svg_shape_)
.PreparePaint(paint_state.GetPaintInfo(),
layout_svg_shape_.StyleRef(),
.PreparePaint(paint_info, layout_svg_shape_.StyleRef(),
kApplyToStrokeMode, stroke_flags,
additional_paint_server_transform))
break;
......@@ -123,11 +116,11 @@ void SVGShapePainter::Paint(const PaintInfo& paint_info) {
layout_svg_shape_.DashScaleFactor());
stroke_data.SetupPaint(&stroke_flags);
StrokeShape(paint_state.GetPaintInfo().context, stroke_flags);
StrokeShape(paint_info.context, stroke_flags);
}
break;
case PT_MARKERS:
PaintMarkers(paint_state.GetPaintInfo());
PaintMarkers(paint_info);
break;
default:
NOTREACHED();
......
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