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

Unified Diff: Source/core/layout/svg/LayoutSVGShape.cpp

Issue 1158583003: Reduce how often LayoutSVGShape::updateShapeFromElement is called (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Put selfHasRelativeLengths back Created 5 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 | « Source/core/layout/svg/LayoutSVGShape.h ('k') | Source/core/paint/SVGShapePainter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/svg/LayoutSVGShape.cpp
diff --git a/Source/core/layout/svg/LayoutSVGShape.cpp b/Source/core/layout/svg/LayoutSVGShape.cpp
index f5f47a848267768566bd24f9858ad452e8490d10..64423083c10202ca9322ddfa1e15978f9a79f5b3 100644
--- a/Source/core/layout/svg/LayoutSVGShape.cpp
+++ b/Source/core/layout/svg/LayoutSVGShape.cpp
@@ -56,19 +56,33 @@ LayoutSVGShape::~LayoutSVGShape()
{
}
-void LayoutSVGShape::createPath()
+void LayoutSVGShape::updateShapeFromElement()
{
if (!m_path)
m_path = adoptPtr(new Path());
*m_path = toSVGGeometryElement(element())->asPath();
}
-void LayoutSVGShape::updateShapeFromElement()
+void LayoutSVGShape::updateStrokeAndFillBoundingBoxes()
{
- createPath();
+ m_fillBoundingBox = path().boundingRect();
- m_fillBoundingBox = calculateObjectBoundingBox();
- m_strokeBoundingBox = calculateStrokeBoundingBox();
+ m_strokeBoundingBox = m_fillBoundingBox;
+ if (style()->svgStyle().hasStroke()) {
+ StrokeData strokeData;
+ SVGLayoutSupport::applyStrokeStyleToStrokeData(strokeData, styleRef(), *this);
+ if (hasNonScalingStroke()) {
+ AffineTransform nonScalingTransform = nonScalingStrokeTransform();
+ if (nonScalingTransform.isInvertible()) {
+ Path* usePath = nonScalingStrokePath(m_path.get(), nonScalingTransform);
+ FloatRect strokeBoundingRect = usePath->strokeBoundingRect(strokeData);
+ strokeBoundingRect = nonScalingTransform.inverse().mapRect(strokeBoundingRect);
+ m_strokeBoundingBox.unite(strokeBoundingRect);
+ }
+ } else {
+ m_strokeBoundingBox.unite(path().strokeBoundingRect(strokeData));
+ }
+ }
}
FloatRect LayoutSVGShape::hitTestStrokeBoundingBox() const
@@ -152,11 +166,14 @@ void LayoutSVGShape::layout()
bool updateCachedBoundariesInParents = false;
LayoutAnalyzer::Scope analyzer(*this);
- if (m_needsShapeUpdate || m_needsBoundariesUpdate) {
+ if (m_needsShapeUpdate)
updateShapeFromElement();
- m_needsShapeUpdate = false;
+
+ if (m_needsBoundariesUpdate || m_needsShapeUpdate) {
+ updateStrokeAndFillBoundingBoxes();
updatePaintInvalidationBoundingBox();
m_needsBoundariesUpdate = false;
+ m_needsShapeUpdate = false;
updateCachedBoundariesInParents = true;
}
@@ -241,35 +258,6 @@ bool LayoutSVGShape::nodeAtFloatPointInternal(const HitTestRequest& request, con
return false;
}
-FloatRect LayoutSVGShape::calculateObjectBoundingBox() const
-{
- return path().boundingRect();
-}
-
-FloatRect LayoutSVGShape::calculateStrokeBoundingBox() const
-{
- ASSERT(m_path);
- FloatRect strokeBoundingBox = m_fillBoundingBox;
-
- if (style()->svgStyle().hasStroke()) {
- StrokeData strokeData;
- SVGLayoutSupport::applyStrokeStyleToStrokeData(strokeData, styleRef(), *this);
- if (hasNonScalingStroke()) {
- AffineTransform nonScalingTransform = nonScalingStrokeTransform();
- if (nonScalingTransform.isInvertible()) {
- Path* usePath = nonScalingStrokePath(m_path.get(), nonScalingTransform);
- FloatRect strokeBoundingRect = usePath->strokeBoundingRect(strokeData);
- strokeBoundingRect = nonScalingTransform.inverse().mapRect(strokeBoundingRect);
- strokeBoundingBox.unite(strokeBoundingRect);
- }
- } else {
- strokeBoundingBox.unite(path().strokeBoundingRect(strokeData));
- }
- }
-
- return strokeBoundingBox;
-}
-
void LayoutSVGShape::updatePaintInvalidationBoundingBox()
{
m_paintInvalidationBoundingBox = strokeBoundingBox();
« no previous file with comments | « Source/core/layout/svg/LayoutSVGShape.h ('k') | Source/core/paint/SVGShapePainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698