diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-07-16 11:45:35 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-07-17 08:59:23 +0000 |
commit | 552906b0f222c5d5dd11b9fd73829d510980461a (patch) | |
tree | 3a11e6ed0538a81dd83b20cf3a4783e297f26d91 /chromium/third_party/blink/renderer/core/layout/svg/layout_svg_resource_gradient.cc | |
parent | 1b05827804eaf047779b597718c03e7d38344261 (diff) | |
download | qtwebengine-chromium-552906b0f222c5d5dd11b9fd73829d510980461a.tar.gz |
BASELINE: Update Chromium to 83.0.4103.122
Change-Id: Ie3a82f5bb0076eec2a7c6a6162326b4301ee291e
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/core/layout/svg/layout_svg_resource_gradient.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/layout/svg/layout_svg_resource_gradient.cc | 79 |
1 files changed, 44 insertions, 35 deletions
diff --git a/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_resource_gradient.cc b/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_resource_gradient.cc index 62d1617857a..2461347012a 100644 --- a/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_resource_gradient.cc +++ b/chromium/third_party/blink/renderer/core/layout/svg/layout_svg_resource_gradient.cc @@ -24,21 +24,28 @@ #include <memory> +#include "third_party/blink/renderer/platform/graphics/gradient.h" + namespace blink { +struct GradientData { + USING_FAST_MALLOC(GradientData); + + public: + scoped_refptr<Gradient> gradient; + AffineTransform userspace_transform; +}; + LayoutSVGResourceGradient::LayoutSVGResourceGradient(SVGGradientElement* node) : LayoutSVGResourcePaintServer(node), should_collect_gradient_attributes_(true), gradient_map_(MakeGarbageCollected<GradientMap>()) {} -void LayoutSVGResourceGradient::RemoveAllClientsFromCache( - bool mark_for_invalidation) { +void LayoutSVGResourceGradient::RemoveAllClientsFromCache() { gradient_map_->clear(); should_collect_gradient_attributes_ = true; To<SVGGradientElement>(*GetElement()).InvalidateDependentGradients(); - MarkAllClientsForInvalidation( - mark_for_invalidation ? SVGResourceClient::kPaintInvalidation - : SVGResourceClient::kParentOnlyInvalidation); + MarkAllClientsForInvalidation(SVGResourceClient::kPaintInvalidation); } bool LayoutSVGResourceGradient::RemoveClientFromCache( @@ -50,50 +57,52 @@ bool LayoutSVGResourceGradient::RemoveClientFromCache( return true; } -SVGPaintServer LayoutSVGResourceGradient::PreparePaintServer( - const SVGResourceClient& client, +std::unique_ptr<GradientData> LayoutSVGResourceGradient::BuildGradientData( const FloatRect& object_bounding_box) { - ClearInvalidationMask(); + // Create gradient object + auto gradient_data = std::make_unique<GradientData>(); // Validate gradient DOM state before building the actual // gradient. This should avoid tearing down the gradient we're // currently working on. Preferably the state validation should have // no side-effects though. if (should_collect_gradient_attributes_) { - if (!CollectGradientAttributes()) - return SVGPaintServer::Invalid(); + CollectGradientAttributes(); should_collect_gradient_attributes_ = false; } - // Spec: When the geometry of the applicable element has no width or height - // and objectBoundingBox is specified, then the given effect (e.g. a gradient - // or a filter) will be ignored. - if (GradientUnits() == SVGUnitTypes::kSvgUnitTypeObjectboundingbox && - object_bounding_box.IsEmpty()) - return SVGPaintServer::Invalid(); + // We want the text bounding box applied to the gradient space transform + // now, so the gradient shader can use it. + if (GradientUnits() == SVGUnitTypes::kSvgUnitTypeObjectboundingbox) { + // Spec: When the geometry of the applicable element has no width or height + // and objectBoundingBox is specified, then the given effect (e.g. a + // gradient or a filter) will be ignored. + if (object_bounding_box.IsEmpty()) + return gradient_data; + gradient_data->userspace_transform.Translate(object_bounding_box.X(), + object_bounding_box.Y()); + gradient_data->userspace_transform.ScaleNonUniform( + object_bounding_box.Width(), object_bounding_box.Height()); + } + + // Create gradient object + gradient_data->gradient = BuildGradient(); + + AffineTransform gradient_transform = CalculateGradientTransform(); + gradient_data->userspace_transform *= gradient_transform; + + return gradient_data; +} + +SVGPaintServer LayoutSVGResourceGradient::PreparePaintServer( + const SVGResourceClient& client, + const FloatRect& object_bounding_box) { + ClearInvalidationMask(); std::unique_ptr<GradientData>& gradient_data = gradient_map_->insert(&client, nullptr).stored_value->value; if (!gradient_data) - gradient_data = std::make_unique<GradientData>(); - - // Create gradient object - if (!gradient_data->gradient) { - gradient_data->gradient = BuildGradient(); - - // We want the text bounding box applied to the gradient space transform - // now, so the gradient shader can use it. - if (GradientUnits() == SVGUnitTypes::kSvgUnitTypeObjectboundingbox && - !object_bounding_box.IsEmpty()) { - gradient_data->userspace_transform.Translate(object_bounding_box.X(), - object_bounding_box.Y()); - gradient_data->userspace_transform.ScaleNonUniform( - object_bounding_box.Width(), object_bounding_box.Height()); - } - - AffineTransform gradient_transform = CalculateGradientTransform(); - gradient_data->userspace_transform *= gradient_transform; - } + gradient_data = BuildGradientData(object_bounding_box); if (!gradient_data->gradient) return SVGPaintServer::Invalid(); |