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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGViewportContainer.cpp

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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. 5 * Copyright (C) 2009 Google, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 setNeedsTransformUpdate(); 63 setNeedsTransformUpdate();
64 } 64 }
65 } 65 }
66 66
67 void LayoutSVGViewportContainer::setNeedsTransformUpdate() 67 void LayoutSVGViewportContainer::setNeedsTransformUpdate()
68 { 68 {
69 setMayNeedPaintInvalidationSubtree(); 69 setMayNeedPaintInvalidationSubtree();
70 m_needsTransformUpdate = true; 70 m_needsTransformUpdate = true;
71 } 71 }
72 72
73 static std::pair<double, double> scaleReference(const AffineTransform& transform ) 73 SVGTransformChange LayoutSVGViewportContainer::calculateLocalTransform()
74 {
75 return std::make_pair(transform.xScaleSquared(), transform.yScaleSquared());
76 }
77
78 LayoutSVGContainer::TransformChange LayoutSVGViewportContainer::calculateLocalTr ansform()
79 { 74 {
80 if (!m_needsTransformUpdate) 75 if (!m_needsTransformUpdate)
81 return TransformChange::None; 76 return SVGTransformChange::None;
82 77
83 std::pair<double, double> oldScale = scaleReference(m_localToParentTransform ); 78 SVGTransformChangeDetector changeDetector(m_localToParentTransform);
84 m_localToParentTransform = AffineTransform::translation(m_viewport.x(), m_vi ewport.y()) * viewportTransform(); 79 m_localToParentTransform = AffineTransform::translation(m_viewport.x(), m_vi ewport.y()) * viewportTransform();
85 m_needsTransformUpdate = false; 80 m_needsTransformUpdate = false;
86 return scaleReference(m_localToParentTransform) != oldScale 81 return changeDetector.computeChange(m_localToParentTransform);
87 ? TransformChange::Full : TransformChange::ScaleInvariant;
88 } 82 }
89 83
90 AffineTransform LayoutSVGViewportContainer::viewportTransform() const 84 AffineTransform LayoutSVGViewportContainer::viewportTransform() const
91 { 85 {
92 ASSERT(element()); 86 ASSERT(element());
93 if (isSVGSVGElement(*element())) { 87 if (isSVGSVGElement(*element())) {
94 SVGSVGElement* svg = toSVGSVGElement(element()); 88 SVGSVGElement* svg = toSVGSVGElement(element());
95 return svg->viewBoxToViewTransform(m_viewport.width(), m_viewport.height ()); 89 return svg->viewBoxToViewTransform(m_viewport.width(), m_viewport.height ());
96 } 90 }
97 91
98 return AffineTransform(); 92 return AffineTransform();
99 } 93 }
100 94
101 bool LayoutSVGViewportContainer::pointIsInsideViewportClip(const FloatPoint& poi ntInParent) 95 bool LayoutSVGViewportContainer::pointIsInsideViewportClip(const FloatPoint& poi ntInParent)
102 { 96 {
103 // Respect the viewport clip (which is in parent coords) 97 // Respect the viewport clip (which is in parent coords)
104 if (!SVGLayoutSupport::isOverflowHidden(this)) 98 if (!SVGLayoutSupport::isOverflowHidden(this))
105 return true; 99 return true;
106 100
107 return m_viewport.contains(pointInParent); 101 return m_viewport.contains(pointInParent);
108 } 102 }
109 103
110 void LayoutSVGViewportContainer::paint(const PaintInfo& paintInfo, const LayoutP oint& paintOffset) const 104 void LayoutSVGViewportContainer::paint(const PaintInfo& paintInfo, const LayoutP oint& paintOffset) const
111 { 105 {
112 SVGContainerPainter(*this).paint(paintInfo); 106 SVGContainerPainter(*this).paint(paintInfo);
113 } 107 }
114 108
115 } // namespace blink 109 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698