OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "platform/graphics/GraphicsContextState.h" | 6 #include "platform/graphics/GraphicsContextState.h" |
7 | 7 |
8 namespace blink { | 8 namespace blink { |
9 | 9 |
10 GraphicsContextState::GraphicsContextState() | 10 GraphicsContextState::GraphicsContextState() |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 void GraphicsContextState::setStrokeGradient(const PassRefPtr<Gradient> gradient
, float alpha) | 98 void GraphicsContextState::setStrokeGradient(const PassRefPtr<Gradient> gradient
, float alpha) |
99 { | 99 { |
100 m_strokeColor = Color::black; | 100 m_strokeColor = Color::black; |
101 m_strokePattern.clear(); | 101 m_strokePattern.clear(); |
102 m_strokeGradient = gradient; | 102 m_strokeGradient = gradient; |
103 m_strokePaint.setColor(scaleAlpha(applyAlpha(SK_ColorBLACK), alpha)); | 103 m_strokePaint.setColor(scaleAlpha(applyAlpha(SK_ColorBLACK), alpha)); |
104 m_strokePaint.setShader(m_strokeGradient->shader()); | 104 m_strokePaint.setShader(m_strokeGradient->shader()); |
105 } | 105 } |
106 | 106 |
107 void GraphicsContextState::clearStrokeGradient() | |
108 { | |
109 m_strokeGradient.clear(); | |
110 ASSERT(!m_strokePattern); | |
111 m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb())); | |
112 } | |
113 | |
114 void GraphicsContextState::setStrokePattern(const PassRefPtr<Pattern> pattern, f
loat alpha) | 107 void GraphicsContextState::setStrokePattern(const PassRefPtr<Pattern> pattern, f
loat alpha) |
115 { | 108 { |
116 m_strokeColor = Color::black; | 109 m_strokeColor = Color::black; |
117 m_strokeGradient.clear(); | 110 m_strokeGradient.clear(); |
118 m_strokePattern = pattern; | 111 m_strokePattern = pattern; |
119 m_strokePaint.setColor(scaleAlpha(applyAlpha(SK_ColorBLACK), alpha)); | 112 m_strokePaint.setColor(scaleAlpha(applyAlpha(SK_ColorBLACK), alpha)); |
120 m_strokePaint.setShader(m_strokePattern->shader()); | 113 m_strokePaint.setShader(m_strokePattern->shader()); |
121 } | 114 } |
122 | 115 |
123 void GraphicsContextState::clearStrokePattern() | |
124 { | |
125 m_strokePattern.clear(); | |
126 ASSERT(!m_strokeGradient); | |
127 m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb())); | |
128 } | |
129 | |
130 void GraphicsContextState::setLineCap(LineCap cap) | 116 void GraphicsContextState::setLineCap(LineCap cap) |
131 { | 117 { |
132 m_strokeData.setLineCap(cap); | 118 m_strokeData.setLineCap(cap); |
133 m_strokePaint.setStrokeCap((SkPaint::Cap)cap); | 119 m_strokePaint.setStrokeCap((SkPaint::Cap)cap); |
134 } | 120 } |
135 | 121 |
136 void GraphicsContextState::setLineJoin(LineJoin join) | 122 void GraphicsContextState::setLineJoin(LineJoin join) |
137 { | 123 { |
138 m_strokeData.setLineJoin(join); | 124 m_strokeData.setLineJoin(join); |
139 m_strokePaint.setStrokeJoin((SkPaint::Join)join); | 125 m_strokePaint.setStrokeJoin((SkPaint::Join)join); |
(...skipping 16 matching lines...) Expand all Loading... |
156 | 142 |
157 void GraphicsContextState::setFillGradient(const PassRefPtr<Gradient> gradient,
float alpha) | 143 void GraphicsContextState::setFillGradient(const PassRefPtr<Gradient> gradient,
float alpha) |
158 { | 144 { |
159 m_fillColor = Color::black; | 145 m_fillColor = Color::black; |
160 m_fillPattern.clear(); | 146 m_fillPattern.clear(); |
161 m_fillGradient = gradient; | 147 m_fillGradient = gradient; |
162 m_fillPaint.setColor(scaleAlpha(applyAlpha(SK_ColorBLACK), alpha)); | 148 m_fillPaint.setColor(scaleAlpha(applyAlpha(SK_ColorBLACK), alpha)); |
163 m_fillPaint.setShader(m_fillGradient->shader()); | 149 m_fillPaint.setShader(m_fillGradient->shader()); |
164 } | 150 } |
165 | 151 |
166 void GraphicsContextState::clearFillGradient() | |
167 { | |
168 m_fillGradient.clear(); | |
169 ASSERT(!m_fillPattern); | |
170 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); | |
171 } | |
172 | |
173 void GraphicsContextState::setFillPattern(const PassRefPtr<Pattern> pattern, flo
at alpha) | 152 void GraphicsContextState::setFillPattern(const PassRefPtr<Pattern> pattern, flo
at alpha) |
174 { | 153 { |
175 m_fillColor = Color::black; | 154 m_fillColor = Color::black; |
176 m_fillGradient.clear(); | 155 m_fillGradient.clear(); |
177 m_fillPattern = pattern; | 156 m_fillPattern = pattern; |
178 m_fillPaint.setColor(scaleAlpha(applyAlpha(SK_ColorBLACK), alpha)); | 157 m_fillPaint.setColor(scaleAlpha(applyAlpha(SK_ColorBLACK), alpha)); |
179 m_fillPaint.setShader(m_fillPattern->shader()); | 158 m_fillPaint.setShader(m_fillPattern->shader()); |
180 } | 159 } |
181 | 160 |
182 void GraphicsContextState::clearFillPattern() | |
183 { | |
184 m_fillPattern.clear(); | |
185 ASSERT(!m_fillGradient); | |
186 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); | |
187 } | |
188 | |
189 // Shadow. (This will need tweaking if we use draw loopers for other things.) | 161 // Shadow. (This will need tweaking if we use draw loopers for other things.) |
190 void GraphicsContextState::setDrawLooper(PassRefPtr<SkDrawLooper> drawLooper) | 162 void GraphicsContextState::setDrawLooper(PassRefPtr<SkDrawLooper> drawLooper) |
191 { | 163 { |
192 m_looper = drawLooper; | 164 m_looper = drawLooper; |
193 m_strokePaint.setLooper(m_looper.get()); | 165 m_strokePaint.setLooper(m_looper.get()); |
194 m_fillPaint.setLooper(m_looper.get()); | 166 m_fillPaint.setLooper(m_looper.get()); |
195 } | 167 } |
196 | 168 |
197 void GraphicsContextState::clearDrawLooper() | 169 void GraphicsContextState::clearDrawLooper() |
198 { | 170 { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 } | 217 } |
246 | 218 |
247 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) | 219 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) |
248 { | 220 { |
249 m_shouldAntialias = shouldAntialias; | 221 m_shouldAntialias = shouldAntialias; |
250 m_strokePaint.setAntiAlias(shouldAntialias); | 222 m_strokePaint.setAntiAlias(shouldAntialias); |
251 m_fillPaint.setAntiAlias(shouldAntialias); | 223 m_fillPaint.setAntiAlias(shouldAntialias); |
252 } | 224 } |
253 | 225 |
254 } // namespace blink | 226 } // namespace blink |
OLD | NEW |