OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkTwoPointRadialGradient.h" | 9 #include "SkTwoPointRadialGradient.h" |
10 | 10 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 info->fRadius[0] = fRadius1; | 217 info->fRadius[0] = fRadius1; |
218 info->fRadius[1] = fRadius2; | 218 info->fRadius[1] = fRadius2; |
219 } | 219 } |
220 return kRadial2_GradientType; | 220 return kRadial2_GradientType; |
221 } | 221 } |
222 | 222 |
223 size_t SkTwoPointRadialGradient::contextSize() const { | 223 size_t SkTwoPointRadialGradient::contextSize() const { |
224 return sizeof(TwoPointRadialGradientContext); | 224 return sizeof(TwoPointRadialGradientContext); |
225 } | 225 } |
226 | 226 |
227 bool SkTwoPointRadialGradient::validContext(const SkBitmap& device, const SkPain
t& paint, | 227 bool SkTwoPointRadialGradient::validContext(const ContextRec& rec, SkMatrix* tot
alInverse) const { |
228 const SkMatrix& matrix, SkMatrix* to
talInverse) const { | |
229 // For now, we might have divided by zero, so detect that. | 228 // For now, we might have divided by zero, so detect that. |
230 if (0 == fDiffRadius) { | 229 if (0 == fDiffRadius) { |
231 return false; | 230 return false; |
232 } | 231 } |
233 | 232 |
234 return this->INHERITED::validContext(device, paint, matrix, totalInverse); | 233 return this->INHERITED::validContext(rec, totalInverse); |
235 } | 234 } |
236 | 235 |
237 SkShader::Context* SkTwoPointRadialGradient::createContext( | 236 SkShader::Context* SkTwoPointRadialGradient::createContext(const ContextRec& rec
, |
238 const SkBitmap& device, const SkPaint& paint, | 237 void* storage) const
{ |
239 const SkMatrix& matrix, void* storage) const { | 238 if (!this->validContext(rec, NULL)) { |
240 if (!this->validContext(device, paint, matrix)) { | |
241 return NULL; | 239 return NULL; |
242 } | 240 } |
243 | 241 |
244 return SkNEW_PLACEMENT_ARGS(storage, TwoPointRadialGradientContext, | 242 return SkNEW_PLACEMENT_ARGS(storage, TwoPointRadialGradientContext, (*this,
rec)); |
245 (*this, device, paint, matrix)); | |
246 } | 243 } |
247 | 244 |
248 SkTwoPointRadialGradient::TwoPointRadialGradientContext::TwoPointRadialGradientC
ontext( | 245 SkTwoPointRadialGradient::TwoPointRadialGradientContext::TwoPointRadialGradientC
ontext( |
249 const SkTwoPointRadialGradient& shader, const SkBitmap& device, | 246 const SkTwoPointRadialGradient& shader, const ContextRec& rec) |
250 const SkPaint& paint, const SkMatrix& matrix) | 247 : INHERITED(shader, rec) |
251 : INHERITED(shader, device, paint, matrix) | |
252 { | 248 { |
253 // we don't have a span16 proc | 249 // we don't have a span16 proc |
254 fFlags &= ~kHasSpan16_Flag; | 250 fFlags &= ~kHasSpan16_Flag; |
255 } | 251 } |
256 | 252 |
257 void SkTwoPointRadialGradient::TwoPointRadialGradientContext::shadeSpan( | 253 void SkTwoPointRadialGradient::TwoPointRadialGradientContext::shadeSpan( |
258 int x, int y, SkPMColor* dstCParam, int count) { | 254 int x, int y, SkPMColor* dstCParam, int count) { |
259 SkASSERT(count > 0); | 255 SkASSERT(count > 0); |
260 | 256 |
261 const SkTwoPointRadialGradient& twoPointRadialGradient = | 257 const SkTwoPointRadialGradient& twoPointRadialGradient = |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 } | 701 } |
706 | 702 |
707 #else | 703 #else |
708 | 704 |
709 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext*, const SkPaint&) c
onst { | 705 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext*, const SkPaint&) c
onst { |
710 SkDEBUGFAIL("Should not call in GPU-less build"); | 706 SkDEBUGFAIL("Should not call in GPU-less build"); |
711 return NULL; | 707 return NULL; |
712 } | 708 } |
713 | 709 |
714 #endif | 710 #endif |
OLD | NEW |