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

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

Issue 1915763002: CSS conic gradient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 /* 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 public: 50 public:
51 static PassRefPtr<Gradient> create(const FloatPoint& p0, const FloatPoint& p 1) 51 static PassRefPtr<Gradient> create(const FloatPoint& p0, const FloatPoint& p 1)
52 { 52 {
53 return adoptRef(new Gradient(p0, p1)); 53 return adoptRef(new Gradient(p0, p1));
54 } 54 }
55 static PassRefPtr<Gradient> create(const FloatPoint& p0, float startAngle)
56 {
57 return adoptRef(new Gradient(p0, startAngle));
58 }
55 static PassRefPtr<Gradient> create(const FloatPoint& p0, float r0, const Flo atPoint& p1, float r1, float aspectRatio = 1) 59 static PassRefPtr<Gradient> create(const FloatPoint& p0, float r0, const Flo atPoint& p1, float r1, float aspectRatio = 1)
56 { 60 {
57 return adoptRef(new Gradient(p0, r0, p1, r1, aspectRatio)); 61 return adoptRef(new Gradient(p0, r0, p1, r1, aspectRatio));
58 } 62 }
59 ~Gradient(); 63 ~Gradient();
60 64
61 struct ColorStop { 65 struct ColorStop {
62 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 66 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
63 float stop; 67 float stop;
64 Color color; 68 Color color;
65 69
66 ColorStop(float s, const Color& c) : stop(s), color(c) { } 70 ColorStop(float s, const Color& c) : stop(s), color(c) { }
67 }; 71 };
68 void addColorStop(const ColorStop&); 72 void addColorStop(const ColorStop&);
69 void addColorStop(float value, const Color& color) { addColorStop(ColorStop( value, color)); } 73 void addColorStop(float value, const Color& color) { addColorStop(ColorStop( value, color)); }
70 74
71 bool shaderChanged() const { return !m_gradient; } 75 bool shaderChanged() const { return !m_gradient; }
72 76
73 bool isRadial() const { return m_radial; } 77 bool isRadial() const { return m_class == RadialClass; }
74 bool isZeroSize() const { return m_p0.x() == m_p1.x() && m_p0.y() == m_p1.y( ) && (!m_radial || m_r0 == m_r1); } 78 bool isZeroSize() const { return m_p0.x() == m_p1.x() && m_p0.y() == m_p1.y( ) && (!isRadial() || m_r0 == m_r1); }
75 79
76 const FloatPoint& p0() const { return m_p0; } 80 const FloatPoint& p0() const { return m_p0; }
77 const FloatPoint& p1() const { return m_p1; } 81 const FloatPoint& p1() const { return m_p1; }
78 82
79 void setP0(const FloatPoint& p) 83 void setP0(const FloatPoint& p)
80 { 84 {
81 if (m_p0 == p) 85 if (m_p0 == p)
82 return; 86 return;
83 87
84 m_p0 = p; 88 m_p0 = p;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 121
118 void setDrawsInPMColorSpace(bool drawInPMColorSpace); 122 void setDrawsInPMColorSpace(bool drawInPMColorSpace);
119 123
120 void setSpreadMethod(GradientSpreadMethod); 124 void setSpreadMethod(GradientSpreadMethod);
121 GradientSpreadMethod spreadMethod() const { return m_spreadMethod; } 125 GradientSpreadMethod spreadMethod() const { return m_spreadMethod; }
122 void setGradientSpaceTransform(const AffineTransform& gradientSpaceTransform ation); 126 void setGradientSpaceTransform(const AffineTransform& gradientSpaceTransform ation);
123 AffineTransform gradientSpaceTransform() { return m_gradientSpaceTransformat ion; } 127 AffineTransform gradientSpaceTransform() { return m_gradientSpaceTransformat ion; }
124 128
125 private: 129 private:
126 Gradient(const FloatPoint& p0, const FloatPoint& p1); 130 Gradient(const FloatPoint& p0, const FloatPoint& p1);
131 Gradient(const FloatPoint& p0, float starAngle);
127 Gradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1, flo at aspectRatio); 132 Gradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1, flo at aspectRatio);
128 133
129 sk_sp<SkShader> createShader(); 134 sk_sp<SkShader> createShader();
130 135
131 void sortStopsIfNecessary(); 136 void sortStopsIfNecessary();
132 137
138 enum GradientClass {
139 LinearClass,
140 RadialClass,
141 ConicClass,
142 };
143
133 FloatPoint m_p0; 144 FloatPoint m_p0;
134 FloatPoint m_p1; 145 FloatPoint m_p1;
135 float m_r0; 146 float m_r0;
136 float m_r1; 147 float m_r1;
137 float m_aspectRatio; // For elliptical gradient, width / height. 148 float m_aspectRatio; // For elliptical gradient, width / height.
138 Vector<ColorStop, 2> m_stops; 149 Vector<ColorStop, 2> m_stops;
139 bool m_radial; 150 GradientClass m_class;
140 bool m_stopsSorted; 151 bool m_stopsSorted;
141 bool m_drawInPMColorSpace; 152 bool m_drawInPMColorSpace;
142 GradientSpreadMethod m_spreadMethod; 153 GradientSpreadMethod m_spreadMethod;
143 AffineTransform m_gradientSpaceTransformation; 154 AffineTransform m_gradientSpaceTransformation;
144 155
145 sk_sp<SkShader> m_gradient; 156 sk_sp<SkShader> m_gradient;
146 }; 157 };
147 158
148 } // namespace blink 159 } // namespace blink
149 160
150 #endif 161 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698