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

Side by Side Diff: Source/platform/graphics/StrokeData.h

Issue 597053003: Move color/gradient/pattern out of StrokeData (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/graphics/GraphicsContextState.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (C) 2013 Google Inc. All rights reserved. 1 // Copyright (C) 2013 Google Inc. All rights reserved.
2 // 2 //
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are 4 // modification, are permitted provided that the following conditions are
5 // met: 5 // met:
6 // 6 //
7 // * Redistributions of source code must retain the above copyright 7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above 9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer 10 // copyright notice, this list of conditions and the following disclaimer
(...skipping 23 matching lines...) Expand all
34 #include "platform/graphics/Gradient.h" 34 #include "platform/graphics/Gradient.h"
35 #include "platform/graphics/GraphicsTypes.h" 35 #include "platform/graphics/GraphicsTypes.h"
36 #include "platform/graphics/Pattern.h" 36 #include "platform/graphics/Pattern.h"
37 #include "third_party/skia/include/core/SkColorPriv.h" 37 #include "third_party/skia/include/core/SkColorPriv.h"
38 #include "third_party/skia/include/effects/SkDashPathEffect.h" 38 #include "third_party/skia/include/effects/SkDashPathEffect.h"
39 #include "wtf/PassRefPtr.h" 39 #include "wtf/PassRefPtr.h"
40 #include "wtf/RefPtr.h" 40 #include "wtf/RefPtr.h"
41 41
42 namespace blink { 42 namespace blink {
43 43
44 // Encapsulates stroke painting information. 44 // Encapsulates stroke geometry information.
45 // It is pulled out of GraphicsContextState to enable other methods to use it. 45 // It is pulled out of GraphicsContextState to enable other methods to use it.
46 class PLATFORM_EXPORT StrokeData { 46 class PLATFORM_EXPORT StrokeData {
47 public: 47 public:
48 StrokeData() 48 StrokeData()
49 : m_style(SolidStroke) 49 : m_style(SolidStroke)
50 , m_thickness(0) 50 , m_thickness(0)
51 , m_color(Color::black)
52 , m_lineCap(SkPaint::kDefault_Cap) 51 , m_lineCap(SkPaint::kDefault_Cap)
53 , m_lineJoin(SkPaint::kDefault_Join) 52 , m_lineJoin(SkPaint::kDefault_Join)
54 , m_miterLimit(4) 53 , m_miterLimit(4)
55 { 54 {
56 } 55 }
57 56
58 StrokeStyle style() const { return m_style; } 57 StrokeStyle style() const { return m_style; }
59 void setStyle(StrokeStyle style) { m_style = style; } 58 void setStyle(StrokeStyle style) { m_style = style; }
60 59
61 float thickness() const { return m_thickness; } 60 float thickness() const { return m_thickness; }
62 void setThickness(float thickness) { m_thickness = thickness; } 61 void setThickness(float thickness) { m_thickness = thickness; }
63 62
64 Color color() const { return m_color; }
65 void setColor(const Color& color) { m_color = color; }
66
67 Gradient* gradient() const { return m_gradient.get(); }
68 void setGradient(const PassRefPtr<Gradient> gradient) { m_gradient = gradien t; }
69 void clearGradient() { m_gradient.clear(); }
70
71 Pattern* pattern() const { return m_pattern.get(); }
72 void setPattern(const PassRefPtr<Pattern> pattern) { m_pattern = pattern; }
73 void clearPattern() { m_pattern.clear(); }
74
75 LineCap lineCap() const { return (LineCap)m_lineCap; } 63 LineCap lineCap() const { return (LineCap)m_lineCap; }
76 void setLineCap(LineCap cap) { m_lineCap = (SkPaint::Cap)cap; } 64 void setLineCap(LineCap cap) { m_lineCap = (SkPaint::Cap)cap; }
77 65
78 LineJoin lineJoin() const { return (LineJoin)m_lineJoin; } 66 LineJoin lineJoin() const { return (LineJoin)m_lineJoin; }
79 void setLineJoin(LineJoin join) { m_lineJoin = (SkPaint::Join)join; } 67 void setLineJoin(LineJoin join) { m_lineJoin = (SkPaint::Join)join; }
80 68
81 float miterLimit() const { return m_miterLimit; } 69 float miterLimit() const { return m_miterLimit; }
82 void setMiterLimit(float miterLimit) { m_miterLimit = miterLimit; } 70 void setMiterLimit(float miterLimit) { m_miterLimit = miterLimit; }
83 71
84 void setLineDash(const DashArray&, float); 72 void setLineDash(const DashArray&, float);
85 73
86 // Sets everything on the paint except the pattern, gradient and color. 74 // Sets everything on the paint except the pattern, gradient and color.
87 // If a non-zero length is provided, the number of dashes/dots on a 75 // If a non-zero length is provided, the number of dashes/dots on a
88 // dashed/dotted line will be adjusted to start and end that length with a 76 // dashed/dotted line will be adjusted to start and end that length with a
89 // dash/dot. 77 // dash/dot.
90 void setupPaint(SkPaint*, int length = 0) const; 78 void setupPaint(SkPaint*, int length = 0) const;
91 79
92 // Setup any DashPathEffect on the paint. If a non-zero length is provided, 80 // Setup any DashPathEffect on the paint. If a non-zero length is provided,
93 // and no line dash has been set, the number of dashes/dots on a dashed/dott ed 81 // and no line dash has been set, the number of dashes/dots on a dashed/dott ed
94 // line will be adjusted to start and end that length with a dash/dot. 82 // line will be adjusted to start and end that length with a dash/dot.
95 void setupPaintDashPathEffect(SkPaint*, int) const; 83 void setupPaintDashPathEffect(SkPaint*, int) const;
96 84
97 private: 85 private:
98 StrokeStyle m_style; 86 StrokeStyle m_style;
99 float m_thickness; 87 float m_thickness;
100 Color m_color;
101 RefPtr<Gradient> m_gradient;
102 RefPtr<Pattern> m_pattern;
103 SkPaint::Cap m_lineCap; 88 SkPaint::Cap m_lineCap;
104 SkPaint::Join m_lineJoin; 89 SkPaint::Join m_lineJoin;
105 float m_miterLimit; 90 float m_miterLimit;
106 RefPtr<SkDashPathEffect> m_dash; 91 RefPtr<SkDashPathEffect> m_dash;
107 }; 92 };
108 93
109 } // namespace blink 94 } // namespace blink
110 95
111 #endif // StrokeData_h 96 #endif // StrokeData_h
OLDNEW
« no previous file with comments | « Source/platform/graphics/GraphicsContextState.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698