OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
4 * Copyright (C) 2008 Torch Mobile, Inc. | 4 * Copyright (C) 2008 Torch Mobile, Inc. |
5 * Copyright (C) 2013 Google Inc. All rights reserved. | 5 * Copyright (C) 2013 Google Inc. All rights reserved. |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 15 matching lines...) Expand all Loading... |
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #ifndef Gradient_h | 29 #ifndef Gradient_h |
30 #define Gradient_h | 30 #define Gradient_h |
31 | 31 |
32 #include "platform/PlatformExport.h" | 32 #include "platform/PlatformExport.h" |
33 #include "platform/geometry/FloatPoint.h" | 33 #include "platform/geometry/FloatPoint.h" |
34 #include "platform/graphics/Color.h" | 34 #include "platform/graphics/Color.h" |
35 #include "platform/graphics/GraphicsTypes.h" | 35 #include "platform/graphics/GraphicsTypes.h" |
| 36 #include "platform/graphics/paint/PaintFlags.h" |
| 37 #include "platform/graphics/paint/PaintShader.h" |
36 #include "third_party/skia/include/core/SkRefCnt.h" | 38 #include "third_party/skia/include/core/SkRefCnt.h" |
37 #include "wtf/Noncopyable.h" | 39 #include "wtf/Noncopyable.h" |
38 #include "wtf/PassRefPtr.h" | 40 #include "wtf/PassRefPtr.h" |
39 #include "wtf/RefCounted.h" | 41 #include "wtf/RefCounted.h" |
40 #include "wtf/Vector.h" | 42 #include "wtf/Vector.h" |
41 | 43 |
42 class SkMatrix; | 44 class SkMatrix; |
43 class SkPaint; | |
44 class SkShader; | |
45 | 45 |
46 namespace blink { | 46 namespace blink { |
47 | 47 |
48 class PLATFORM_EXPORT Gradient : public RefCounted<Gradient> { | 48 class PLATFORM_EXPORT Gradient : public RefCounted<Gradient> { |
49 WTF_MAKE_NONCOPYABLE(Gradient); | 49 WTF_MAKE_NONCOPYABLE(Gradient); |
50 | 50 |
51 public: | 51 public: |
52 static PassRefPtr<Gradient> create(const FloatPoint& p0, | 52 static PassRefPtr<Gradient> create(const FloatPoint& p0, |
53 const FloatPoint& p1) { | 53 const FloatPoint& p1) { |
54 return adoptRef(new Gradient(p0, p1)); | 54 return adoptRef(new Gradient(p0, p1)); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 m_r0 = r; | 107 m_r0 = r; |
108 } | 108 } |
109 | 109 |
110 void setEndRadius(float r) { | 110 void setEndRadius(float r) { |
111 if (m_r1 == r) | 111 if (m_r1 == r) |
112 return; | 112 return; |
113 | 113 |
114 m_r1 = r; | 114 m_r1 = r; |
115 } | 115 } |
116 | 116 |
117 void applyToPaint(SkPaint&, const SkMatrix& localMatrix); | 117 void applyToPaint(PaintFlags&, const SkMatrix& localMatrix); |
118 | 118 |
119 void setDrawsInPMColorSpace(bool drawInPMColorSpace); | 119 void setDrawsInPMColorSpace(bool drawInPMColorSpace); |
120 | 120 |
121 void setSpreadMethod(GradientSpreadMethod); | 121 void setSpreadMethod(GradientSpreadMethod); |
122 GradientSpreadMethod spreadMethod() const { return m_spreadMethod; } | 122 GradientSpreadMethod spreadMethod() const { return m_spreadMethod; } |
123 | 123 |
124 private: | 124 private: |
125 Gradient(const FloatPoint& p0, const FloatPoint& p1); | 125 Gradient(const FloatPoint& p0, const FloatPoint& p1); |
126 Gradient(const FloatPoint& p0, | 126 Gradient(const FloatPoint& p0, |
127 float r0, | 127 float r0, |
128 const FloatPoint& p1, | 128 const FloatPoint& p1, |
129 float r1, | 129 float r1, |
130 float aspectRatio); | 130 float aspectRatio); |
131 | 131 |
132 sk_sp<SkShader> createShader(const SkMatrix& localMatrix); | 132 sk_sp<PaintShader> createShader(const SkMatrix& localMatrix); |
133 | 133 |
134 void sortStopsIfNecessary(); | 134 void sortStopsIfNecessary(); |
135 | 135 |
136 FloatPoint m_p0; | 136 FloatPoint m_p0; |
137 FloatPoint m_p1; | 137 FloatPoint m_p1; |
138 float m_r0; | 138 float m_r0; |
139 float m_r1; | 139 float m_r1; |
140 float m_aspectRatio; // For elliptical gradient, width / height. | 140 float m_aspectRatio; // For elliptical gradient, width / height. |
141 Vector<ColorStop, 2> m_stops; | 141 Vector<ColorStop, 2> m_stops; |
142 bool m_radial; | 142 bool m_radial; |
143 bool m_stopsSorted; | 143 bool m_stopsSorted; |
144 bool m_drawInPMColorSpace; | 144 bool m_drawInPMColorSpace; |
145 GradientSpreadMethod m_spreadMethod; | 145 GradientSpreadMethod m_spreadMethod; |
146 | 146 |
147 mutable sk_sp<SkShader> m_cachedShader; | 147 mutable sk_sp<PaintShader> m_cachedShader; |
148 }; | 148 }; |
149 | 149 |
150 } // namespace blink | 150 } // namespace blink |
151 | 151 |
152 #endif | 152 #endif |
OLD | NEW |