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 #include "platform/graphics/skia/SkiaUtils.h" | 8 #include "platform/graphics/skia/SkiaUtils.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 | 92 |
93 void GraphicsContextState::setStrokeColor(const Color& color) | 93 void GraphicsContextState::setStrokeColor(const Color& color) |
94 { | 94 { |
95 m_strokeGradient.clear(); | 95 m_strokeGradient.clear(); |
96 m_strokePattern.clear(); | 96 m_strokePattern.clear(); |
97 m_strokeColor = color; | 97 m_strokeColor = color; |
98 m_strokePaint.setColor(applyAlpha(color.rgb())); | 98 m_strokePaint.setColor(applyAlpha(color.rgb())); |
99 m_strokePaint.setShader(0); | 99 m_strokePaint.setShader(0); |
100 } | 100 } |
101 | 101 |
102 void GraphicsContextState::setStrokeGradient(const PassRefPtr<Gradient> gradient ) | 102 void GraphicsContextState::setStrokeGradient(const PassRefPtr<Gradient> gradient , float additionalAlpha) |
103 { | 103 { |
104 m_strokeColor = Color::black; | 104 m_strokeColor = Color::black; |
105 m_strokePattern.clear(); | 105 m_strokePattern.clear(); |
106 m_strokeGradient = gradient; | 106 m_strokeGradient = gradient; |
107 m_strokePaint.setColor(applyAlpha(SK_ColorBLACK)); | 107 m_strokePaint.setColor(combineWithAlpha(applyAlpha(SK_ColorBLACK), additiona lAlpha)); |
108 m_strokePaint.setShader(m_strokeGradient->shader()); | 108 m_strokePaint.setShader(m_strokeGradient->shader()); |
109 } | 109 } |
110 | 110 |
111 void GraphicsContextState::clearStrokeGradient() | 111 void GraphicsContextState::clearStrokeGradient() |
112 { | 112 { |
113 m_strokeGradient.clear(); | 113 m_strokeGradient.clear(); |
114 ASSERT(!m_strokePattern); | 114 ASSERT(!m_strokePattern); |
115 m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb())); | 115 m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb())); |
116 } | 116 } |
117 | 117 |
118 void GraphicsContextState::setStrokePattern(const PassRefPtr<Pattern> pattern) | 118 void GraphicsContextState::setStrokePattern(const PassRefPtr<Pattern> pattern, f loat additionalAlpha) |
119 { | 119 { |
120 m_strokeColor = Color::black; | 120 m_strokeColor = Color::black; |
121 m_strokeGradient.clear(); | 121 m_strokeGradient.clear(); |
122 m_strokePattern = pattern; | 122 m_strokePattern = pattern; |
123 m_strokePaint.setColor(applyAlpha(SK_ColorBLACK)); | 123 m_strokePaint.setColor(combineWithAlpha(applyAlpha(SK_ColorBLACK), additiona lAlpha)); |
124 m_strokePaint.setShader(m_strokePattern->shader()); | 124 m_strokePaint.setShader(m_strokePattern->shader()); |
125 } | 125 } |
126 | 126 |
127 void GraphicsContextState::clearStrokePattern() | 127 void GraphicsContextState::clearStrokePattern() |
128 { | 128 { |
129 m_strokePattern.clear(); | 129 m_strokePattern.clear(); |
130 ASSERT(!m_strokeGradient); | 130 ASSERT(!m_strokeGradient); |
131 m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb())); | 131 m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb())); |
132 } | 132 } |
133 | 133 |
(...skipping 17 matching lines...) Expand all Loading... | |
151 | 151 |
152 void GraphicsContextState::setFillColor(const Color& color) | 152 void GraphicsContextState::setFillColor(const Color& color) |
153 { | 153 { |
154 m_fillColor = color; | 154 m_fillColor = color; |
155 m_fillGradient.clear(); | 155 m_fillGradient.clear(); |
156 m_fillPattern.clear(); | 156 m_fillPattern.clear(); |
157 m_fillPaint.setColor(applyAlpha(color.rgb())); | 157 m_fillPaint.setColor(applyAlpha(color.rgb())); |
158 m_fillPaint.setShader(0); | 158 m_fillPaint.setShader(0); |
159 } | 159 } |
160 | 160 |
161 void GraphicsContextState::setFillGradient(const PassRefPtr<Gradient> gradient) | 161 void GraphicsContextState::setFillGradient(const PassRefPtr<Gradient> gradient, float additionalAlpha) |
162 { | 162 { |
163 m_fillColor = Color::black; | 163 m_fillColor = Color::black; |
164 m_fillPattern.clear(); | 164 m_fillPattern.clear(); |
165 m_fillGradient = gradient; | 165 m_fillGradient = gradient; |
166 m_fillPaint.setColor(applyAlpha(SK_ColorBLACK)); | 166 m_fillPaint.setColor(combineWithAlpha(applyAlpha(SK_ColorBLACK), additionalA lpha)); |
167 m_fillPaint.setShader(m_fillGradient->shader()); | 167 m_fillPaint.setShader(m_fillGradient->shader()); |
168 } | 168 } |
169 | 169 |
170 void GraphicsContextState::clearFillGradient() | 170 void GraphicsContextState::clearFillGradient() |
171 { | 171 { |
172 m_fillGradient.clear(); | 172 m_fillGradient.clear(); |
173 ASSERT(!m_fillPattern); | 173 ASSERT(!m_fillPattern); |
174 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); | 174 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); |
175 } | 175 } |
176 | 176 |
177 void GraphicsContextState::setFillPattern(const PassRefPtr<Pattern> pattern) | 177 void GraphicsContextState::setFillPattern(const PassRefPtr<Pattern> pattern, flo at additionalAlpha) |
178 { | 178 { |
179 m_fillColor = Color::black; | 179 m_fillColor = Color::black; |
180 m_fillGradient.clear(); | 180 m_fillGradient.clear(); |
181 m_fillPattern = pattern; | 181 m_fillPattern = pattern; |
182 m_fillPaint.setColor(applyAlpha(SK_ColorBLACK)); | 182 m_fillPaint.setColor(combineWithAlpha(applyAlpha(SK_ColorBLACK), additionalA lpha)); |
183 m_fillPaint.setShader(m_fillPattern->shader()); | 183 m_fillPaint.setShader(m_fillPattern->shader()); |
184 } | 184 } |
185 | 185 |
186 void GraphicsContextState::clearFillPattern() | 186 void GraphicsContextState::clearFillPattern() |
187 { | 187 { |
188 m_fillPattern.clear(); | 188 m_fillPattern.clear(); |
189 ASSERT(!m_fillGradient); | 189 ASSERT(!m_fillGradient); |
190 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); | 190 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); |
191 } | 191 } |
192 | 192 |
(...skipping 17 matching lines...) Expand all Loading... | |
210 m_dropShadowImageFilter = dropShadowImageFilter; | 210 m_dropShadowImageFilter = dropShadowImageFilter; |
211 } | 211 } |
212 | 212 |
213 void GraphicsContextState::clearDropShadowImageFilter() | 213 void GraphicsContextState::clearDropShadowImageFilter() |
214 { | 214 { |
215 m_dropShadowImageFilter.clear(); | 215 m_dropShadowImageFilter.clear(); |
216 } | 216 } |
217 | 217 |
218 void GraphicsContextState::setAlphaAsFloat(float alpha) | 218 void GraphicsContextState::setAlphaAsFloat(float alpha) |
219 { | 219 { |
220 if (alpha < 0) { | 220 m_alpha = clampedAlphaForBlending(alpha); |
chrishtr
2015/02/02 23:14:54
This is the one place that reads m_alpha it seems:
pdr.
2015/02/03 00:09:48
GraphicsContext::preparePaintForDrawRectToRect is
| |
221 m_alpha = 0; | |
222 } else { | |
223 m_alpha = roundf(alpha * 256); | |
224 if (m_alpha > 256) | |
225 m_alpha = 256; | |
226 } | |
227 m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb())); | 221 m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb())); |
228 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); | 222 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); |
229 } | 223 } |
230 | 224 |
231 void GraphicsContextState::setLineDash(const DashArray& dashes, float dashOffset ) | 225 void GraphicsContextState::setLineDash(const DashArray& dashes, float dashOffset ) |
232 { | 226 { |
233 m_strokeData.setLineDash(dashes, dashOffset); | 227 m_strokeData.setLineDash(dashes, dashOffset); |
234 } | 228 } |
235 | 229 |
236 void GraphicsContextState::setColorFilter(PassRefPtr<SkColorFilter> colorFilter) | 230 void GraphicsContextState::setColorFilter(PassRefPtr<SkColorFilter> colorFilter) |
(...skipping 29 matching lines...) Expand all Loading... | |
266 return m_hasComplexClip; | 260 return m_hasComplexClip; |
267 } | 261 } |
268 | 262 |
269 void GraphicsContextState::setHasComplexClip() | 263 void GraphicsContextState::setHasComplexClip() |
270 { | 264 { |
271 m_hasComplexClip = true; | 265 m_hasComplexClip = true; |
272 } | 266 } |
273 | 267 |
274 | 268 |
275 } // namespace blink | 269 } // namespace blink |
OLD | NEW |