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

Side by Side Diff: Source/core/rendering/svg/RenderSVGShape.cpp

Issue 701433002: Lazily allocate svg shape transforms, shrink RenderSVGShape by 44B (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Refactor for cleanliness Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/svg/RenderSVGShape.h ('k') | Source/core/svg/SVGGraphicsElement.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, 2008 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org>
4 * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. 5 * Copyright (C) 2009 Google, Inc.
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
8 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com> 8 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com>
9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> 9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org>
10 * Copyright (C) 2011 University of Szeged 10 * Copyright (C) 2011 University of Szeged
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 { 103 {
104 if (!strokeBoundingBox().contains(point)) 104 if (!strokeBoundingBox().contains(point))
105 return false; 105 return false;
106 106
107 if (requiresStroke && !SVGPaintServer::existsForRenderer(*this, style(), App lyToStrokeMode)) 107 if (requiresStroke && !SVGPaintServer::existsForRenderer(*this, style(), App lyToStrokeMode))
108 return false; 108 return false;
109 109
110 return shapeDependentStrokeContains(point); 110 return shapeDependentStrokeContains(point);
111 } 111 }
112 112
113 void RenderSVGShape::updateLocalTransform()
114 {
115 SVGGraphicsElement* graphicsElement = toSVGGraphicsElement(element());
116 if (graphicsElement->hasAnimatedLocalTransform()) {
117 if (m_localTransform)
118 m_localTransform->setTransform(graphicsElement->calculateAnimatedLoc alTransform());
119 else
120 m_localTransform = adoptPtr(new AffineTransform(graphicsElement->cal culateAnimatedLocalTransform()));
121 } else {
122 m_localTransform = 0;
123 }
124 }
125
113 void RenderSVGShape::layout() 126 void RenderSVGShape::layout()
114 { 127 {
115 bool updateCachedBoundariesInParents = false; 128 bool updateCachedBoundariesInParents = false;
116 129
117 if (m_needsShapeUpdate || m_needsBoundariesUpdate) { 130 if (m_needsShapeUpdate || m_needsBoundariesUpdate) {
118 updateShapeFromElement(); 131 updateShapeFromElement();
119 m_needsShapeUpdate = false; 132 m_needsShapeUpdate = false;
120 updatePaintInvalidationBoundingBox(); 133 updatePaintInvalidationBoundingBox();
121 m_needsBoundariesUpdate = false; 134 m_needsBoundariesUpdate = false;
122 updateCachedBoundariesInParents = true; 135 updateCachedBoundariesInParents = true;
123 } 136 }
124 137
125 if (m_needsTransformUpdate) { 138 if (m_needsTransformUpdate) {
126 m_localTransform = toSVGGraphicsElement(element())->calculateAnimatedLo calTransform(); 139 updateLocalTransform();
127 m_needsTransformUpdate = false; 140 m_needsTransformUpdate = false;
128 updateCachedBoundariesInParents = true; 141 updateCachedBoundariesInParents = true;
129 } 142 }
130 143
131 // Invalidate all resources of this client if our layout changed. 144 // Invalidate all resources of this client if our layout changed.
132 if (everHadLayout() && selfNeedsLayout()) 145 if (everHadLayout() && selfNeedsLayout())
133 SVGResourcesCache::clientLayoutChanged(this); 146 SVGResourcesCache::clientLayoutChanged(this);
134 147
135 // If our bounds changed, notify the parents. 148 // If our bounds changed, notify the parents.
136 if (updateCachedBoundariesInParents) 149 if (updateCachedBoundariesInParents)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 rects.append(rect); 181 rects.append(rect);
169 } 182 }
170 183
171 bool RenderSVGShape::nodeAtFloatPoint(const HitTestRequest& request, HitTestResu lt& result, const FloatPoint& pointInParent, HitTestAction hitTestAction) 184 bool RenderSVGShape::nodeAtFloatPoint(const HitTestRequest& request, HitTestResu lt& result, const FloatPoint& pointInParent, HitTestAction hitTestAction)
172 { 185 {
173 // We only draw in the foreground phase, so we only hit-test then. 186 // We only draw in the foreground phase, so we only hit-test then.
174 if (hitTestAction != HitTestForeground) 187 if (hitTestAction != HitTestForeground)
175 return false; 188 return false;
176 189
177 FloatPoint localPoint; 190 FloatPoint localPoint;
178 if (!SVGRenderSupport::transformToUserSpaceAndCheckClipping(this, m_localTra nsform, pointInParent, localPoint)) 191 if (!SVGRenderSupport::transformToUserSpaceAndCheckClipping(this, localToPar entTransform(), pointInParent, localPoint))
179 return false; 192 return false;
180 193
181 PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_GEOMETRY_HITTESTIN G, request, style()->pointerEvents()); 194 PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_GEOMETRY_HITTESTIN G, request, style()->pointerEvents());
182 if (nodeAtFloatPointInternal(request, localPoint, hitRules)) { 195 if (nodeAtFloatPointInternal(request, localPoint, hitRules)) {
183 updateHitTestResult(result, roundedLayoutPoint(localPoint)); 196 updateHitTestResult(result, roundedLayoutPoint(localPoint));
184 return true; 197 return true;
185 } 198 }
186 199
187 return false; 200 return false;
188 } 201 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 bool RenderSVGShape::hasSmoothStroke() const 262 bool RenderSVGShape::hasSmoothStroke() const
250 { 263 {
251 const SVGRenderStyle& svgStyle = style()->svgStyle(); 264 const SVGRenderStyle& svgStyle = style()->svgStyle();
252 return svgStyle.strokeDashArray()->isEmpty() 265 return svgStyle.strokeDashArray()->isEmpty()
253 && svgStyle.strokeMiterLimit() == SVGRenderStyle::initialStrokeMiterLimi t() 266 && svgStyle.strokeMiterLimit() == SVGRenderStyle::initialStrokeMiterLimi t()
254 && svgStyle.joinStyle() == SVGRenderStyle::initialJoinStyle() 267 && svgStyle.joinStyle() == SVGRenderStyle::initialJoinStyle()
255 && svgStyle.capStyle() == SVGRenderStyle::initialCapStyle(); 268 && svgStyle.capStyle() == SVGRenderStyle::initialCapStyle();
256 } 269 }
257 270
258 } 271 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/RenderSVGShape.h ('k') | Source/core/svg/SVGGraphicsElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698