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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Gradient.h

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 years 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 /* 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
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 "skia/ext/cdl_common.h"
36 #include "third_party/skia/include/core/SkRefCnt.h" 37 #include "third_party/skia/include/core/SkRefCnt.h"
37 #include "wtf/Noncopyable.h" 38 #include "wtf/Noncopyable.h"
38 #include "wtf/PassRefPtr.h" 39 #include "wtf/PassRefPtr.h"
39 #include "wtf/RefCounted.h" 40 #include "wtf/RefCounted.h"
40 #include "wtf/Vector.h" 41 #include "wtf/Vector.h"
41 42
42 class SkMatrix; 43 class SkMatrix;
43 class SkPaint;
44 class SkShader;
45 44
46 namespace blink { 45 namespace blink {
47 46
48 class PLATFORM_EXPORT Gradient : public RefCounted<Gradient> { 47 class PLATFORM_EXPORT Gradient : public RefCounted<Gradient> {
49 WTF_MAKE_NONCOPYABLE(Gradient); 48 WTF_MAKE_NONCOPYABLE(Gradient);
50 49
51 public: 50 public:
52 static PassRefPtr<Gradient> create(const FloatPoint& p0, 51 static PassRefPtr<Gradient> create(const FloatPoint& p0,
53 const FloatPoint& p1) { 52 const FloatPoint& p1) {
54 return adoptRef(new Gradient(p0, p1)); 53 return adoptRef(new Gradient(p0, p1));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 m_r0 = r; 106 m_r0 = r;
108 } 107 }
109 108
110 void setEndRadius(float r) { 109 void setEndRadius(float r) {
111 if (m_r1 == r) 110 if (m_r1 == r)
112 return; 111 return;
113 112
114 m_r1 = r; 113 m_r1 = r;
115 } 114 }
116 115
117 void applyToPaint(SkPaint&, const SkMatrix& localMatrix); 116 void applyToPaint(CdlPaint&, const SkMatrix& localMatrix);
118 117
119 void setDrawsInPMColorSpace(bool drawInPMColorSpace); 118 void setDrawsInPMColorSpace(bool drawInPMColorSpace);
120 119
121 void setSpreadMethod(GradientSpreadMethod); 120 void setSpreadMethod(GradientSpreadMethod);
122 GradientSpreadMethod spreadMethod() const { return m_spreadMethod; } 121 GradientSpreadMethod spreadMethod() const { return m_spreadMethod; }
123 122
124 private: 123 private:
125 Gradient(const FloatPoint& p0, const FloatPoint& p1); 124 Gradient(const FloatPoint& p0, const FloatPoint& p1);
126 Gradient(const FloatPoint& p0, 125 Gradient(const FloatPoint& p0,
127 float r0, 126 float r0,
128 const FloatPoint& p1, 127 const FloatPoint& p1,
129 float r1, 128 float r1,
130 float aspectRatio); 129 float aspectRatio);
131 130
132 sk_sp<SkShader> createShader(const SkMatrix& localMatrix); 131 sk_sp<CdlShader> createShader(const SkMatrix& localMatrix);
133 132
134 void sortStopsIfNecessary(); 133 void sortStopsIfNecessary();
135 134
136 FloatPoint m_p0; 135 FloatPoint m_p0;
137 FloatPoint m_p1; 136 FloatPoint m_p1;
138 float m_r0; 137 float m_r0;
139 float m_r1; 138 float m_r1;
140 float m_aspectRatio; // For elliptical gradient, width / height. 139 float m_aspectRatio; // For elliptical gradient, width / height.
141 Vector<ColorStop, 2> m_stops; 140 Vector<ColorStop, 2> m_stops;
142 bool m_radial; 141 bool m_radial;
143 bool m_stopsSorted; 142 bool m_stopsSorted;
144 bool m_drawInPMColorSpace; 143 bool m_drawInPMColorSpace;
145 GradientSpreadMethod m_spreadMethod; 144 GradientSpreadMethod m_spreadMethod;
146 145
147 mutable sk_sp<SkShader> m_cachedShader; 146 mutable sk_sp<CdlShader> m_cachedShader;
148 }; 147 };
149 148
150 } // namespace blink 149 } // namespace blink
151 150
152 #endif 151 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698