OLD | NEW |
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 16 matching lines...) Expand all Loading... |
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | 28 |
29 #ifndef StrokeData_h | 29 #ifndef StrokeData_h |
30 #define StrokeData_h | 30 #define StrokeData_h |
31 | 31 |
32 #include "platform/PlatformExport.h" | 32 #include "platform/PlatformExport.h" |
33 #include "platform/graphics/DashArray.h" | 33 #include "platform/graphics/DashArray.h" |
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 "platform/graphics/paint/PaintFlags.h" |
37 #include "third_party/skia/include/core/SkPaint.h" | 38 #include "third_party/skia/include/core/SkPaint.h" |
38 #include "third_party/skia/include/core/SkPathEffect.h" | 39 #include "third_party/skia/include/core/SkPathEffect.h" |
39 #include "wtf/Allocator.h" | 40 #include "wtf/Allocator.h" |
40 #include "wtf/PassRefPtr.h" | 41 #include "wtf/PassRefPtr.h" |
41 #include "wtf/RefPtr.h" | 42 #include "wtf/RefPtr.h" |
42 | 43 |
43 namespace blink { | 44 namespace blink { |
44 | 45 |
45 // Encapsulates stroke geometry information. | 46 // Encapsulates stroke geometry information. |
46 // It is pulled out of GraphicsContextState to enable other methods to use it. | 47 // It is pulled out of GraphicsContextState to enable other methods to use it. |
47 class PLATFORM_EXPORT StrokeData final { | 48 class PLATFORM_EXPORT StrokeData final { |
48 DISALLOW_NEW(); | 49 DISALLOW_NEW(); |
49 | 50 |
50 public: | 51 public: |
51 StrokeData() | 52 StrokeData() |
52 : m_style(SolidStroke), | 53 : m_style(SolidStroke), |
53 m_thickness(0), | 54 m_thickness(0), |
54 m_lineCap(SkPaint::kDefault_Cap), | 55 m_lineCap(PaintFlags::kDefault_Cap), |
55 m_lineJoin(SkPaint::kDefault_Join), | 56 m_lineJoin(PaintFlags::kDefault_Join), |
56 m_miterLimit(4) {} | 57 m_miterLimit(4) {} |
57 | 58 |
58 StrokeStyle style() const { return m_style; } | 59 StrokeStyle style() const { return m_style; } |
59 void setStyle(StrokeStyle style) { m_style = style; } | 60 void setStyle(StrokeStyle style) { m_style = style; } |
60 | 61 |
61 float thickness() const { return m_thickness; } | 62 float thickness() const { return m_thickness; } |
62 void setThickness(float thickness) { m_thickness = thickness; } | 63 void setThickness(float thickness) { m_thickness = thickness; } |
63 | 64 |
64 void setLineCap(LineCap cap) { m_lineCap = (SkPaint::Cap)cap; } | 65 void setLineCap(LineCap cap) { m_lineCap = (PaintFlags::Cap)cap; } |
65 | 66 |
66 void setLineJoin(LineJoin join) { m_lineJoin = (SkPaint::Join)join; } | 67 void setLineJoin(LineJoin join) { m_lineJoin = (PaintFlags::Join)join; } |
67 | 68 |
68 float miterLimit() const { return m_miterLimit; } | 69 float miterLimit() const { return m_miterLimit; } |
69 void setMiterLimit(float miterLimit) { m_miterLimit = miterLimit; } | 70 void setMiterLimit(float miterLimit) { m_miterLimit = miterLimit; } |
70 | 71 |
71 void setLineDash(const DashArray&, float); | 72 void setLineDash(const DashArray&, float); |
72 | 73 |
73 // Sets everything on the paint except the pattern, gradient and color. | 74 // Sets everything on the paint except the pattern, gradient and color. |
74 // 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 |
75 // 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 |
76 // dash/dot. | 77 // dash/dot. |
77 void setupPaint(SkPaint*, int length = 0) const; | 78 void setupPaint(PaintFlags*, int length = 0) const; |
78 | 79 |
79 // 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, |
80 // and no line dash has been set, the number of dashes/dots on a dashed/dotted | 81 // and no line dash has been set, the number of dashes/dots on a dashed/dotted |
81 // 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. |
82 void setupPaintDashPathEffect(SkPaint*, int) const; | 83 void setupPaintDashPathEffect(PaintFlags*, int) const; |
83 | 84 |
84 private: | 85 private: |
85 StrokeStyle m_style; | 86 StrokeStyle m_style; |
86 float m_thickness; | 87 float m_thickness; |
87 SkPaint::Cap m_lineCap; | 88 PaintFlags::Cap m_lineCap; |
88 SkPaint::Join m_lineJoin; | 89 PaintFlags::Join m_lineJoin; |
89 float m_miterLimit; | 90 float m_miterLimit; |
90 sk_sp<SkPathEffect> m_dash; | 91 sk_sp<SkPathEffect> m_dash; |
91 }; | 92 }; |
92 | 93 |
93 } // namespace blink | 94 } // namespace blink |
94 | 95 |
95 #endif // StrokeData_h | 96 #endif // StrokeData_h |
OLD | NEW |