diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/core/paint/svg_mask_painter.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/paint/svg_mask_painter.cc | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/chromium/third_party/blink/renderer/core/paint/svg_mask_painter.cc b/chromium/third_party/blink/renderer/core/paint/svg_mask_painter.cc index fbac7c37aa4..b579318ec3b 100644 --- a/chromium/third_party/blink/renderer/core/paint/svg_mask_painter.cc +++ b/chromium/third_party/blink/renderer/core/paint/svg_mask_painter.cc @@ -5,8 +5,8 @@ #include "third_party/blink/renderer/core/paint/svg_mask_painter.h" #include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_masker.h" +#include "third_party/blink/renderer/core/layout/svg/svg_resources.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/platform/graphics/paint/drawing_display_item.h" #include "third_party/blink/renderer/platform/graphics/paint/drawing_recorder.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_controller.h" @@ -14,44 +14,48 @@ namespace blink { -bool SVGMaskPainter::PrepareEffect(const LayoutObject& object, - GraphicsContext& context) { - DCHECK(mask_.Style()); - SECURITY_DCHECK(!mask_.NeedsLayout()); - - mask_.ClearInvalidationMask(); - return mask_.GetElement()->HasChildren(); +SVGMaskPainter::SVGMaskPainter(GraphicsContext& context, + const LayoutObject& layout_object, + const DisplayItemClient& display_item_client) + : context_(context), + layout_object_(layout_object), + display_item_client_(display_item_client) { + DCHECK(layout_object_.StyleRef().SvgStyle().MaskerResource()); } -void SVGMaskPainter::FinishEffect(const LayoutObject& object, - GraphicsContext& context) { - DCHECK(mask_.Style()); - SECURITY_DCHECK(!mask_.NeedsLayout()); - - base::Optional<ScopedPaintChunkProperties> scoped_paint_chunk_properties; - const auto* properties = object.FirstFragment().PaintProperties(); +SVGMaskPainter::~SVGMaskPainter() { + const auto* properties = layout_object_.FirstFragment().PaintProperties(); // TODO(crbug.com/814815): This condition should be a DCHECK, but for now // we may paint the object for filters during PrePaint before the // properties are ready. - if (properties && properties->Mask()) { - scoped_paint_chunk_properties.emplace(context.GetPaintController(), - *properties->Mask(), object, - DisplayItem::kSVGMask); - } - - AffineTransform content_transformation; - sk_sp<const PaintRecord> record = mask_.CreatePaintRecord( - content_transformation, object.ObjectBoundingBox(), context); + if (!properties || !properties->Mask()) + return; + ScopedPaintChunkProperties scoped_paint_chunk_properties( + context_.GetPaintController(), *properties->Mask(), display_item_client_, + DisplayItem::kSVGMask); - if (DrawingRecorder::UseCachedDrawingIfPossible(context, object, - DisplayItem::kSVGMask)) + if (DrawingRecorder::UseCachedDrawingIfPossible( + context_, display_item_client_, DisplayItem::kSVGMask)) return; + DrawingRecorder recorder(context_, display_item_client_, + DisplayItem::kSVGMask); + + const SVGComputedStyle& svg_style = layout_object_.StyleRef().SvgStyle(); + auto* masker = + GetSVGResourceAsType<LayoutSVGResourceMasker>(svg_style.MaskerResource()); + DCHECK(masker); + SECURITY_DCHECK(!masker->NeedsLayout()); + masker->ClearInvalidationMask(); - DrawingRecorder recorder(context, object, DisplayItem::kSVGMask); - context.Save(); - context.ConcatCTM(content_transformation); - context.DrawRecord(std::move(record)); - context.Restore(); + AffineTransform content_transformation; + sk_sp<const PaintRecord> record = masker->CreatePaintRecord( + content_transformation, + SVGResources::ReferenceBoxForEffects(layout_object_), context_); + + context_.Save(); + context_.ConcatCTM(content_transformation); + context_.DrawRecord(std::move(record)); + context_.Restore(); } } // namespace blink |