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

Unified Diff: third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.h

Issue 2086583004: Common up SVG transform "change detection" (classification) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/LayoutSVGViewportContainer.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.h
diff --git a/third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.h b/third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.h
index 9097278a4aae2b30118a8dc070a20c826b9f6d1a..43b7ddb4ea31193fc79ba4d8fd5965f5768e7625 100644
--- a/third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.h
+++ b/third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.h
@@ -130,6 +130,43 @@ private:
AffineTransform m_savedContentTransformation;
};
+// The following enumeration is used to optimize cases where the scale is known
+// to be invariant (see: LayoutSVGContainer::layout and LayoutSVGroot). The
+// value 'Full' can be used in the general case when the scale change is
+// unknown, or known to change.
+enum class SVGTransformChange {
+ None,
+ ScaleInvariant,
+ Full,
+};
+
+// Helper for computing ("classifying") a change to a transform using the
+// categoies defined above.
+class SVGTransformChangeDetector {
+ STACK_ALLOCATED();
+public:
+ explicit SVGTransformChangeDetector(const AffineTransform& previous)
+ : m_previousTransform(previous)
+ {
+ }
+
+ SVGTransformChange computeChange(const AffineTransform& current)
+ {
+ if (m_previousTransform == current)
+ return SVGTransformChange::None;
+ if (scaleReference(m_previousTransform) == scaleReference(current))
+ return SVGTransformChange::ScaleInvariant;
+ return SVGTransformChange::Full;
+ }
+
+private:
+ static std::pair<double, double> scaleReference(const AffineTransform& transform)
+ {
+ return std::make_pair(transform.xScaleSquared(), transform.yScaleSquared());
+ }
+ AffineTransform m_previousTransform;
+};
+
template <typename LayoutObjectType>
bool SVGLayoutSupport::computeHasNonIsolatedBlendingDescendants(const LayoutObjectType* object)
{
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/LayoutSVGViewportContainer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698