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

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

Issue 678863002: Move SVG shape painting code to SVGShapePainter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update per reviewer comments 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
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 18 matching lines...) Expand all
29 #include "core/rendering/svg/RenderSVGModelObject.h" 29 #include "core/rendering/svg/RenderSVGModelObject.h"
30 #include "core/rendering/svg/SVGMarkerData.h" 30 #include "core/rendering/svg/SVGMarkerData.h"
31 #include "platform/geometry/FloatRect.h" 31 #include "platform/geometry/FloatRect.h"
32 #include "platform/transforms/AffineTransform.h" 32 #include "platform/transforms/AffineTransform.h"
33 #include "wtf/OwnPtr.h" 33 #include "wtf/OwnPtr.h"
34 #include "wtf/Vector.h" 34 #include "wtf/Vector.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 class FloatPoint; 38 class FloatPoint;
39 class GraphicsContextStateSaver;
40 class PointerEventsHitRules; 39 class PointerEventsHitRules;
41 class SVGGraphicsElement; 40 class SVGGraphicsElement;
42 41
42 enum ShapeGeometryCodePath {
43 PathGeometry,
44 RectGeometryFastPath,
45 EllipseGeometryFastPath
46 };
47
43 class RenderSVGShape : public RenderSVGModelObject { 48 class RenderSVGShape : public RenderSVGModelObject {
44 public: 49 public:
45 explicit RenderSVGShape(SVGGraphicsElement*); 50 explicit RenderSVGShape(SVGGraphicsElement*);
46 virtual ~RenderSVGShape(); 51 virtual ~RenderSVGShape();
47 52
48 void setNeedsShapeUpdate() { m_needsShapeUpdate = true; } 53 void setNeedsShapeUpdate() { m_needsShapeUpdate = true; }
49 virtual void setNeedsBoundariesUpdate() override final { m_needsBoundariesUp date = true; } 54 virtual void setNeedsBoundariesUpdate() override final { m_needsBoundariesUp date = true; }
50 virtual void setNeedsTransformUpdate() override final { m_needsTransformUpda te = true; } 55 virtual void setNeedsTransformUpdate() override final { m_needsTransformUpda te = true; }
51 virtual void fillShape(GraphicsContext*) const;
52 virtual void strokeShape(GraphicsContext*) const;
53 56
54 bool nodeAtFloatPointInternal(const HitTestRequest&, const FloatPoint&, Poin terEventsHitRules); 57 bool nodeAtFloatPointInternal(const HitTestRequest&, const FloatPoint&, Poin terEventsHitRules);
55 58
56 Path& path() const 59 Path& path() const
57 { 60 {
58 ASSERT(m_path); 61 ASSERT(m_path);
59 return *m_path; 62 return *m_path;
60 } 63 }
64 bool hasPath() const { return m_path.get(); }
61 65
62 virtual bool isShapeEmpty() const { return path().isEmpty(); } 66 virtual bool isShapeEmpty() const { return path().isEmpty(); }
63 67
68 virtual FloatRect paintInvalidationRectInLocalCoordinates() const override f inal { return m_paintInvalidationBoundingBox; }
69
70 bool hasNonScalingStroke() const { return style()->svgStyle().vectorEffect() == VE_NON_SCALING_STROKE; }
71 Path* nonScalingStrokePath(const Path*, const AffineTransform&) const;
72 AffineTransform nonScalingStrokeTransform() const;
73 virtual AffineTransform localTransform() const override final { return m_loc alTransform; }
74
75 virtual const Vector<MarkerPosition>* markerPositions() const { return 0; }
76
77 float strokeWidth() const;
78
79 virtual ShapeGeometryCodePath geometryCodePath() const { return PathGeometry ; }
80 virtual const Vector<FloatPoint>* zeroLengthLineCaps() const { return 0; }
81
82 virtual FloatRect objectBoundingBox() const override final { return m_fillBo undingBox; }
83
64 protected: 84 protected:
65 virtual void updateShapeFromElement(); 85 virtual void updateShapeFromElement();
66 virtual bool shapeDependentStrokeContains(const FloatPoint&); 86 virtual bool shapeDependentStrokeContains(const FloatPoint&);
67 virtual bool shapeDependentFillContains(const FloatPoint&, const WindRule) c onst; 87 virtual bool shapeDependentFillContains(const FloatPoint&, const WindRule) c onst;
68 float strokeWidth() const;
69 bool hasPath() const { return m_path.get(); }
70 bool hasSmoothStroke() const; 88 bool hasSmoothStroke() const;
71 89
72 bool hasNonScalingStroke() const { return style()->svgStyle().vectorEffect() == VE_NON_SCALING_STROKE; } 90 // Give RenderSVGPath a hook for updating markers in updateShapeFromElement.
73 AffineTransform nonScalingStrokeTransform() const; 91 virtual void processMarkerPositions() { };
74 Path* nonScalingStrokePath(const Path*, const AffineTransform&) const;
75 92
76 FloatRect m_fillBoundingBox; 93 FloatRect m_fillBoundingBox;
77 FloatRect m_strokeBoundingBox; 94 FloatRect m_strokeBoundingBox;
78 95
79 private: 96 private:
80 // Hit-detection separated for the fill and the stroke 97 // Hit-detection separated for the fill and the stroke
81 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);
82 bool strokeContains(const FloatPoint&, bool requiresStroke = true); 99 bool strokeContains(const FloatPoint&, bool requiresStroke = true);
83 100
84 virtual FloatRect paintInvalidationRectInLocalCoordinates() const override f inal { return m_paintInvalidationBoundingBox; }
85 virtual const AffineTransform& localToParentTransform() const override final { return m_localTransform; } 101 virtual const AffineTransform& localToParentTransform() const override final { return m_localTransform; }
86 virtual AffineTransform localTransform() const override final { return m_loc alTransform; }
87 102
88 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); }
89 virtual const char* renderName() const override { return "RenderSVGShape"; } 104 virtual const char* renderName() const override { return "RenderSVGShape"; }
90 105
91 virtual void layout() override final; 106 virtual void layout() override final;
92 virtual void paint(PaintInfo&, const LayoutPoint&) override final; 107 virtual void paint(PaintInfo&, const LayoutPoint&) override final;
93 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;
94 109
95 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;
96 111
97 virtual FloatRect objectBoundingBox() const override final { return m_fillBo undingBox; }
98 virtual FloatRect strokeBoundingBox() const override final { return m_stroke BoundingBox; } 112 virtual FloatRect strokeBoundingBox() const override final { return m_stroke BoundingBox; }
99 FloatRect calculateObjectBoundingBox() const; 113 FloatRect calculateObjectBoundingBox() const;
100 FloatRect calculateStrokeBoundingBox() const; 114 FloatRect calculateStrokeBoundingBox() const;
101 void updatePaintInvalidationBoundingBox(); 115 void updatePaintInvalidationBoundingBox();
102 116
103 bool setupNonScalingStrokeContext(AffineTransform&, GraphicsContextStateSave r&);
104
105 bool shouldGenerateMarkerPositions() const;
106 FloatRect markerRect(float strokeWidth) const;
107 void processMarkerPositions();
108
109 void paintMarkers(PaintInfo&);
110
111 private: 117 private:
112 FloatRect m_paintInvalidationBoundingBox; 118 FloatRect m_paintInvalidationBoundingBox;
113 AffineTransform m_localTransform; 119 AffineTransform m_localTransform;
114 OwnPtr<Path> m_path; 120 OwnPtr<Path> m_path;
115 Vector<MarkerPosition> m_markerPositions;
116 121
117 bool m_needsBoundariesUpdate : 1; 122 bool m_needsBoundariesUpdate : 1;
118 bool m_needsShapeUpdate : 1; 123 bool m_needsShapeUpdate : 1;
119 bool m_needsTransformUpdate : 1; 124 bool m_needsTransformUpdate : 1;
120 }; 125 };
121 126
122 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderSVGShape, isSVGShape()); 127 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderSVGShape, isSVGShape());
123 128
124 } 129 }
125 130
126 #endif 131 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/RenderSVGRect.cpp ('k') | Source/core/rendering/svg/RenderSVGShape.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698