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

Side by Side Diff: third_party/WebKit/Source/core/paint/SVGShapePainter.cpp

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: DrawingDisplayItem Created 3 years, 10 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/SVGShapePainter.h" 5 #include "core/paint/SVGShapePainter.h"
6 6
7 #include "core/layout/svg/LayoutSVGResourceMarker.h" 7 #include "core/layout/svg/LayoutSVGResourceMarker.h"
8 #include "core/layout/svg/LayoutSVGShape.h" 8 #include "core/layout/svg/LayoutSVGShape.h"
9 #include "core/layout/svg/SVGLayoutSupport.h" 9 #include "core/layout/svg/SVGLayoutSupport.h"
10 #include "core/layout/svg/SVGMarkerData.h" 10 #include "core/layout/svg/SVGMarkerData.h"
11 #include "core/layout/svg/SVGResources.h" 11 #include "core/layout/svg/SVGResources.h"
12 #include "core/layout/svg/SVGResourcesCache.h" 12 #include "core/layout/svg/SVGResourcesCache.h"
13 #include "core/paint/FloatClipRecorder.h" 13 #include "core/paint/FloatClipRecorder.h"
14 #include "core/paint/LayoutObjectDrawingRecorder.h" 14 #include "core/paint/LayoutObjectDrawingRecorder.h"
15 #include "core/paint/ObjectPainter.h" 15 #include "core/paint/ObjectPainter.h"
16 #include "core/paint/PaintInfo.h" 16 #include "core/paint/PaintInfo.h"
17 #include "core/paint/SVGContainerPainter.h" 17 #include "core/paint/SVGContainerPainter.h"
18 #include "core/paint/SVGPaintContext.h" 18 #include "core/paint/SVGPaintContext.h"
19 #include "core/paint/TransformRecorder.h" 19 #include "core/paint/TransformRecorder.h"
20 #include "platform/graphics/GraphicsContextStateSaver.h" 20 #include "platform/graphics/GraphicsContextStateSaver.h"
21 #include "platform/graphics/paint/PaintRecord.h"
21 #include "platform/graphics/paint/SkPictureBuilder.h" 22 #include "platform/graphics/paint/SkPictureBuilder.h"
22 #include "third_party/skia/include/core/SkPaint.h"
23 #include "third_party/skia/include/core/SkPicture.h"
24 #include "wtf/Optional.h" 23 #include "wtf/Optional.h"
25 24
26 namespace blink { 25 namespace blink {
27 26
28 static bool setupNonScalingStrokeContext( 27 static bool setupNonScalingStrokeContext(
29 AffineTransform& strokeTransform, 28 AffineTransform& strokeTransform,
30 GraphicsContextStateSaver& stateSaver) { 29 GraphicsContextStateSaver& stateSaver) {
31 if (!strokeTransform.isInvertible()) 30 if (!strokeTransform.isInvertible())
32 return false; 31 return false;
33 32
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 paintContext.paintInfo().context, m_layoutSVGShape, 68 paintContext.paintInfo().context, m_layoutSVGShape,
70 paintContext.paintInfo().phase, boundingBox); 69 paintContext.paintInfo().phase, boundingBox);
71 const SVGComputedStyle& svgStyle = m_layoutSVGShape.style()->svgStyle(); 70 const SVGComputedStyle& svgStyle = m_layoutSVGShape.style()->svgStyle();
72 71
73 bool shouldAntiAlias = svgStyle.shapeRendering() != SR_CRISPEDGES && 72 bool shouldAntiAlias = svgStyle.shapeRendering() != SR_CRISPEDGES &&
74 svgStyle.shapeRendering() != SR_OPTIMIZESPEED; 73 svgStyle.shapeRendering() != SR_OPTIMIZESPEED;
75 74
76 for (int i = 0; i < 3; i++) { 75 for (int i = 0; i < 3; i++) {
77 switch (svgStyle.paintOrderType(i)) { 76 switch (svgStyle.paintOrderType(i)) {
78 case PT_FILL: { 77 case PT_FILL: {
79 SkPaint fillPaint; 78 PaintFlags fillPaint;
80 if (!SVGPaintContext::paintForLayoutObject( 79 if (!SVGPaintContext::paintForLayoutObject(
81 paintContext.paintInfo(), m_layoutSVGShape.styleRef(), 80 paintContext.paintInfo(), m_layoutSVGShape.styleRef(),
82 m_layoutSVGShape, ApplyToFillMode, fillPaint)) 81 m_layoutSVGShape, ApplyToFillMode, fillPaint))
83 break; 82 break;
84 fillPaint.setAntiAlias(shouldAntiAlias); 83 fillPaint.setAntiAlias(shouldAntiAlias);
85 fillShape(paintContext.paintInfo().context, fillPaint, 84 fillShape(paintContext.paintInfo().context, fillPaint,
86 fillRuleFromStyle(paintContext.paintInfo(), svgStyle)); 85 fillRuleFromStyle(paintContext.paintInfo(), svgStyle));
87 break; 86 break;
88 } 87 }
89 case PT_STROKE: 88 case PT_STROKE:
90 if (svgStyle.hasVisibleStroke()) { 89 if (svgStyle.hasVisibleStroke()) {
91 GraphicsContextStateSaver stateSaver( 90 GraphicsContextStateSaver stateSaver(
92 paintContext.paintInfo().context, false); 91 paintContext.paintInfo().context, false);
93 AffineTransform nonScalingTransform; 92 AffineTransform nonScalingTransform;
94 const AffineTransform* additionalPaintServerTransform = 0; 93 const AffineTransform* additionalPaintServerTransform = 0;
95 94
96 if (m_layoutSVGShape.hasNonScalingStroke()) { 95 if (m_layoutSVGShape.hasNonScalingStroke()) {
97 nonScalingTransform = 96 nonScalingTransform =
98 m_layoutSVGShape.nonScalingStrokeTransform(); 97 m_layoutSVGShape.nonScalingStrokeTransform();
99 if (!setupNonScalingStrokeContext(nonScalingTransform, 98 if (!setupNonScalingStrokeContext(nonScalingTransform,
100 stateSaver)) 99 stateSaver))
101 return; 100 return;
102 101
103 // Non-scaling stroke needs to reset the transform back to the 102 // Non-scaling stroke needs to reset the transform back to the
104 // host transform. 103 // host transform.
105 additionalPaintServerTransform = &nonScalingTransform; 104 additionalPaintServerTransform = &nonScalingTransform;
106 } 105 }
107 106
108 SkPaint strokePaint; 107 PaintFlags strokePaint;
109 if (!SVGPaintContext::paintForLayoutObject( 108 if (!SVGPaintContext::paintForLayoutObject(
110 paintContext.paintInfo(), m_layoutSVGShape.styleRef(), 109 paintContext.paintInfo(), m_layoutSVGShape.styleRef(),
111 m_layoutSVGShape, ApplyToStrokeMode, strokePaint, 110 m_layoutSVGShape, ApplyToStrokeMode, strokePaint,
112 additionalPaintServerTransform)) 111 additionalPaintServerTransform))
113 break; 112 break;
114 strokePaint.setAntiAlias(shouldAntiAlias); 113 strokePaint.setAntiAlias(shouldAntiAlias);
115 114
116 StrokeData strokeData; 115 StrokeData strokeData;
117 SVGLayoutSupport::applyStrokeStyleToStrokeData( 116 SVGLayoutSupport::applyStrokeStyleToStrokeData(
118 strokeData, m_layoutSVGShape.styleRef(), m_layoutSVGShape, 117 strokeData, m_layoutSVGShape.styleRef(), m_layoutSVGShape,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 ~PathWithTemporaryWindingRule() { m_path.setFillType(m_savedFillType); } 150 ~PathWithTemporaryWindingRule() { m_path.setFillType(m_savedFillType); }
152 151
153 const SkPath& getSkPath() const { return m_path; } 152 const SkPath& getSkPath() const { return m_path; }
154 153
155 private: 154 private:
156 SkPath& m_path; 155 SkPath& m_path;
157 SkPath::FillType m_savedFillType; 156 SkPath::FillType m_savedFillType;
158 }; 157 };
159 158
160 void SVGShapePainter::fillShape(GraphicsContext& context, 159 void SVGShapePainter::fillShape(GraphicsContext& context,
161 const SkPaint& paint, 160 const PaintFlags& paint,
162 SkPath::FillType fillType) { 161 SkPath::FillType fillType) {
163 switch (m_layoutSVGShape.geometryCodePath()) { 162 switch (m_layoutSVGShape.geometryCodePath()) {
164 case RectGeometryFastPath: 163 case RectGeometryFastPath:
165 context.drawRect(m_layoutSVGShape.objectBoundingBox(), paint); 164 context.drawRect(m_layoutSVGShape.objectBoundingBox(), paint);
166 break; 165 break;
167 case EllipseGeometryFastPath: 166 case EllipseGeometryFastPath:
168 context.drawOval(m_layoutSVGShape.objectBoundingBox(), paint); 167 context.drawOval(m_layoutSVGShape.objectBoundingBox(), paint);
169 break; 168 break;
170 default: { 169 default: {
171 PathWithTemporaryWindingRule pathWithWinding(m_layoutSVGShape.path(), 170 PathWithTemporaryWindingRule pathWithWinding(m_layoutSVGShape.path(),
172 fillType); 171 fillType);
173 context.drawPath(pathWithWinding.getSkPath(), paint); 172 context.drawPath(pathWithWinding.getSkPath(), paint);
174 } 173 }
175 } 174 }
176 } 175 }
177 176
178 void SVGShapePainter::strokeShape(GraphicsContext& context, 177 void SVGShapePainter::strokeShape(GraphicsContext& context,
179 const SkPaint& paint) { 178 const PaintFlags& paint) {
180 if (!m_layoutSVGShape.style()->svgStyle().hasVisibleStroke()) 179 if (!m_layoutSVGShape.style()->svgStyle().hasVisibleStroke())
181 return; 180 return;
182 181
183 switch (m_layoutSVGShape.geometryCodePath()) { 182 switch (m_layoutSVGShape.geometryCodePath()) {
184 case RectGeometryFastPath: 183 case RectGeometryFastPath:
185 context.drawRect(m_layoutSVGShape.objectBoundingBox(), paint); 184 context.drawRect(m_layoutSVGShape.objectBoundingBox(), paint);
186 break; 185 break;
187 case EllipseGeometryFastPath: 186 case EllipseGeometryFastPath:
188 context.drawOval(m_layoutSVGShape.objectBoundingBox(), paint); 187 context.drawOval(m_layoutSVGShape.objectBoundingBox(), paint);
189 break; 188 break;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 marker.markerTransformation(position.origin, position.angle, 245 marker.markerTransformation(position.origin, position.angle,
247 strokeWidth)); 246 strokeWidth));
248 Optional<FloatClipRecorder> clipRecorder; 247 Optional<FloatClipRecorder> clipRecorder;
249 if (SVGLayoutSupport::isOverflowHidden(&marker)) 248 if (SVGLayoutSupport::isOverflowHidden(&marker))
250 clipRecorder.emplace(paintInfo.context, marker, paintInfo.phase, 249 clipRecorder.emplace(paintInfo.context, marker, paintInfo.phase,
251 marker.viewport()); 250 marker.viewport());
252 SVGContainerPainter(marker).paint(paintInfo); 251 SVGContainerPainter(marker).paint(paintInfo);
253 } 252 }
254 253
255 } // namespace blink 254 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/SVGShapePainter.h ('k') | third_party/WebKit/Source/core/paint/ThemePainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698