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

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

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 | « no previous file | Source/core/rendering/svg/RenderSVGShape.cpp » ('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 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2006 Apple Computer, Inc 5 * Copyright (C) 2006 Apple Computer, Inc
6 * Copyright (C) 2009 Google, Inc. 6 * Copyright (C) 2009 Google, Inc.
7 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> 7 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org>
8 * Copyright (C) 2011 University of Szeged 8 * Copyright (C) 2011 University of Szeged
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 bool hasPath() const { return m_path.get(); } 64 bool hasPath() const { return m_path.get(); }
65 65
66 virtual bool isShapeEmpty() const { return path().isEmpty(); } 66 virtual bool isShapeEmpty() const { return path().isEmpty(); }
67 67
68 virtual FloatRect paintInvalidationRectInLocalCoordinates() const override f inal { return m_paintInvalidationBoundingBox; } 68 virtual FloatRect paintInvalidationRectInLocalCoordinates() const override f inal { return m_paintInvalidationBoundingBox; }
69 69
70 bool hasNonScalingStroke() const { return style()->svgStyle().vectorEffect() == VE_NON_SCALING_STROKE; } 70 bool hasNonScalingStroke() const { return style()->svgStyle().vectorEffect() == VE_NON_SCALING_STROKE; }
71 Path* nonScalingStrokePath(const Path*, const AffineTransform&) const; 71 Path* nonScalingStrokePath(const Path*, const AffineTransform&) const;
72 AffineTransform nonScalingStrokeTransform() const; 72 AffineTransform nonScalingStrokeTransform() const;
73 virtual AffineTransform localTransform() const override final { return m_loc alTransform; } 73 virtual AffineTransform localTransform() const override final { return m_loc alTransform ? *m_localTransform : RenderSVGModelObject::localTransform(); }
74 74
75 virtual const Vector<MarkerPosition>* markerPositions() const { return 0; } 75 virtual const Vector<MarkerPosition>* markerPositions() const { return 0; }
76 76
77 float strokeWidth() const; 77 float strokeWidth() const;
78 78
79 virtual ShapeGeometryCodePath geometryCodePath() const { return PathGeometry ; } 79 virtual ShapeGeometryCodePath geometryCodePath() const { return PathGeometry ; }
80 virtual const Vector<FloatPoint>* zeroLengthLineCaps() const { return 0; } 80 virtual const Vector<FloatPoint>* zeroLengthLineCaps() const { return 0; }
81 81
82 virtual FloatRect objectBoundingBox() const override final { return m_fillBo undingBox; } 82 virtual FloatRect objectBoundingBox() const override final { return m_fillBo undingBox; }
83 83
84 protected: 84 protected:
85 virtual void updateShapeFromElement(); 85 virtual void updateShapeFromElement();
86 virtual bool shapeDependentStrokeContains(const FloatPoint&); 86 virtual bool shapeDependentStrokeContains(const FloatPoint&);
87 virtual bool shapeDependentFillContains(const FloatPoint&, const WindRule) c onst; 87 virtual bool shapeDependentFillContains(const FloatPoint&, const WindRule) c onst;
88 bool hasSmoothStroke() const; 88 bool hasSmoothStroke() const;
89 89
90 // Give RenderSVGPath a hook for updating markers in updateShapeFromElement. 90 // Give RenderSVGPath a hook for updating markers in updateShapeFromElement.
91 virtual void processMarkerPositions() { }; 91 virtual void processMarkerPositions() { };
92 92
93 FloatRect m_fillBoundingBox; 93 FloatRect m_fillBoundingBox;
94 FloatRect m_strokeBoundingBox; 94 FloatRect m_strokeBoundingBox;
95 95
96 private: 96 private:
97 // Hit-detection separated for the fill and the stroke 97 // Hit-detection separated for the fill and the stroke
98 bool fillContains(const FloatPoint&, bool requiresFill = true, const WindRul e fillRule = RULE_NONZERO); 98 bool fillContains(const FloatPoint&, bool requiresFill = true, const WindRul e fillRule = RULE_NONZERO);
99 bool strokeContains(const FloatPoint&, bool requiresStroke = true); 99 bool strokeContains(const FloatPoint&, bool requiresStroke = true);
100 100
101 virtual const AffineTransform& localToParentTransform() const override final { return m_localTransform; } 101 virtual const AffineTransform& localToParentTransform() const override final { return m_localTransform ? *m_localTransform : RenderSVGModelObject::localToPa rentTransform(); }
102 102
103 virtual bool isOfType(RenderObjectType type) const override { return type == RenderObjectSVGShape || RenderSVGModelObject::isOfType(type); } 103 virtual bool isOfType(RenderObjectType type) const override { return type == RenderObjectSVGShape || RenderSVGModelObject::isOfType(type); }
104 virtual const char* renderName() const override { return "RenderSVGShape"; } 104 virtual const char* renderName() const override { return "RenderSVGShape"; }
105 105
106 virtual void layout() override final; 106 virtual void layout() override final;
107 virtual void paint(PaintInfo&, const LayoutPoint&) override final; 107 virtual void paint(PaintInfo&, const LayoutPoint&) override final;
108 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& addit ionalOffset, const RenderLayerModelObject* paintContainer) const override final; 108 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& addit ionalOffset, const RenderLayerModelObject* paintContainer) const override final;
109 109
110 virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const F loatPoint& pointInParent, HitTestAction) override final; 110 virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const F loatPoint& pointInParent, HitTestAction) override final;
111 111
112 virtual FloatRect strokeBoundingBox() const override final { return m_stroke BoundingBox; } 112 virtual FloatRect strokeBoundingBox() const override final { return m_stroke BoundingBox; }
113 FloatRect calculateObjectBoundingBox() const; 113 FloatRect calculateObjectBoundingBox() const;
114 FloatRect calculateStrokeBoundingBox() const; 114 FloatRect calculateStrokeBoundingBox() const;
115 void updatePaintInvalidationBoundingBox(); 115 void updatePaintInvalidationBoundingBox();
116 void updateLocalTransform();
116 117
117 private: 118 private:
118 FloatRect m_paintInvalidationBoundingBox; 119 FloatRect m_paintInvalidationBoundingBox;
119 AffineTransform m_localTransform; 120 OwnPtr<AffineTransform> m_localTransform;
120 OwnPtr<Path> m_path; 121 OwnPtr<Path> m_path;
121 122
122 bool m_needsBoundariesUpdate : 1; 123 bool m_needsBoundariesUpdate : 1;
123 bool m_needsShapeUpdate : 1; 124 bool m_needsShapeUpdate : 1;
124 bool m_needsTransformUpdate : 1; 125 bool m_needsTransformUpdate : 1;
125 }; 126 };
126 127
127 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderSVGShape, isSVGShape()); 128 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderSVGShape, isSVGShape());
128 129
129 } 130 }
130 131
131 #endif 132 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/rendering/svg/RenderSVGShape.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698