Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Unified Diff: third_party/WebKit/Source/core/paint/SVGPaintContext.h

Issue 2059433002: Use transform paint property nodes in SVG [spv2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@svgTransformProps2
Patch Set: Post-blinkon rebase, add some dchecks, add some fixmes Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/SVGPaintContext.h
diff --git a/third_party/WebKit/Source/core/paint/SVGPaintContext.h b/third_party/WebKit/Source/core/paint/SVGPaintContext.h
index b493dde83d2fca7ac3e595d0b44747a15d0f7f9d..f3c84dd5e6b4dcfa6d3a5ceb4edfb17ea8edc88e 100644
--- a/third_party/WebKit/Source/core/paint/SVGPaintContext.h
+++ b/third_party/WebKit/Source/core/paint/SVGPaintContext.h
@@ -27,11 +27,14 @@
#include "core/layout/svg/LayoutSVGResourceClipper.h"
#include "core/layout/svg/LayoutSVGResourcePaintServer.h"
+#include "core/paint/ObjectPaintProperties.h"
#include "core/paint/PaintInfo.h"
#include "core/paint/SVGClipPainter.h"
#include "core/paint/SVGFilterPainter.h"
+#include "core/paint/TransformRecorder.h"
#include "platform/graphics/paint/ClipPathRecorder.h"
#include "platform/graphics/paint/CompositingRecorder.h"
+#include "platform/graphics/paint/ScopedPaintChunkProperties.h"
#include "platform/transforms/AffineTransform.h"
#include <memory>
@@ -42,6 +45,49 @@ class LayoutSVGResourceFilter;
class LayoutSVGResourceMasker;
class SVGResources;
+// This class hooks up the correct paint property transform node when spv2 is enabled, and otherwise
+// works like a TransformRecorder which emits Transform display items for spv1.
+class SVGTransformContext : public TransformRecorder {
+ STACK_ALLOCATED();
+public:
+ SVGTransformContext(GraphicsContext& context, const LayoutObject& object, const AffineTransform& transform)
+ : TransformRecorder(context, object, transform)
+ {
+ if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
+ const auto* objectProperties = object.objectPaintProperties();
+ if (!objectProperties)
+ return;
+ if (object.isSVGRoot()) {
+ // If a transform exists, we can rely on a layer existing to apply it.
+ DCHECK(!objectProperties || !objectProperties->transform() || object.hasLayer());
+ if (objectProperties->svgLocalToBorderBoxTransform()) {
+ // FIXME(pdr): Enable the following DCHECK once the pixel snapping logic has
+ // been included in svgLocalToBorderBox.
+ // DCHECK(objectProperties->svgLocalToBorderBoxTransform()->matrix() == transform.toTransformationMatrix());
+ auto& paintController = context.getPaintController();
+ PaintChunkProperties properties(paintController.currentPaintChunkProperties());
+ properties.transform = objectProperties->svgLocalToBorderBoxTransform();
+ m_transformPropertyScope.emplace(paintController, properties);
+ }
+ } else {
+ DCHECK(object.isSVG());
+ // Should only be used by LayoutSVGRoot.
+ DCHECK(!objectProperties->svgLocalToBorderBoxTransform());
+
+ if (objectProperties->transform()) {
+ DCHECK(objectProperties->transform()->matrix() == transform.toTransformationMatrix());
+ auto& paintController = context.getPaintController();
+ PaintChunkProperties properties(paintController.currentPaintChunkProperties());
+ properties.transform = objectProperties->transform();
+ m_transformPropertyScope.emplace(paintController, properties);
+ }
+ }
+ }
+ }
+private:
+ Optional<ScopedPaintChunkProperties> m_transformPropertyScope;
+};
+
class SVGPaintContext {
STACK_ALLOCATED();
public:
« no previous file with comments | « third_party/WebKit/Source/core/paint/SVGImagePainter.cpp ('k') | third_party/WebKit/Source/core/paint/SVGRootPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698