OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkTwoPointConicalGradient.h" | 8 #include "SkTwoPointConicalGradient.h" |
9 | |
10 #include "SkTwoPointConicalGradient_gpu.h" | 9 #include "SkTwoPointConicalGradient_gpu.h" |
11 | 10 |
12 struct TwoPtRadialContext { | 11 struct TwoPtRadialContext { |
13 const TwoPtRadial& fRec; | 12 const TwoPtRadial& fRec; |
14 float fRelX, fRelY; | 13 float fRelX, fRelY; |
15 const float fIncX, fIncY; | 14 const float fIncX, fIncY; |
16 float fB; | 15 float fB; |
17 const float fDB; | 16 const float fDB; |
18 | 17 |
19 TwoPtRadialContext(const TwoPtRadial& rec, SkScalar fx, SkScalar fy, | 18 TwoPtRadialContext(const TwoPtRadial& rec, SkScalar fx, SkScalar fy, |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 this->INHERITED::flatten(buffer); | 372 this->INHERITED::flatten(buffer); |
374 buffer.writePoint(fCenter1); | 373 buffer.writePoint(fCenter1); |
375 buffer.writePoint(fCenter2); | 374 buffer.writePoint(fCenter2); |
376 buffer.writeScalar(fRadius1); | 375 buffer.writeScalar(fRadius1); |
377 buffer.writeScalar(fRadius2); | 376 buffer.writeScalar(fRadius2); |
378 buffer.writeBool(fFlippedGrad); | 377 buffer.writeBool(fFlippedGrad); |
379 } | 378 } |
380 | 379 |
381 #if SK_SUPPORT_GPU | 380 #if SK_SUPPORT_GPU |
382 | 381 |
383 GrEffectRef* SkTwoPointConicalGradient::asNewEffect(GrContext* context, const Sk
Paint&, | 382 #include "SkGr.h" |
384 const SkMatrix* localMatrix)
const { | 383 |
| 384 bool SkTwoPointConicalGradient::asNewEffect(GrContext* context, const SkPaint& p
aint, |
| 385 const SkMatrix* localMatrix, GrColo
r* grColor, |
| 386 GrEffectRef** grEffect) const { |
385 SkASSERT(NULL != context); | 387 SkASSERT(NULL != context); |
386 SkASSERT(fPtsToUnit.isIdentity()); | 388 SkASSERT(fPtsToUnit.isIdentity()); |
387 | 389 |
388 return Gr2PtConicalGradientEffect::Create(context, *this, fTileMode, localMa
trix); | 390 *grEffect = Gr2PtConicalGradientEffect::Create(context, *this, fTileMode, lo
calMatrix); |
| 391 *grColor = SkColor2GrColorJustAlpha(paint.getColor()); |
| 392 return true; |
389 } | 393 } |
390 | 394 |
391 #else | 395 #else |
392 | 396 |
393 GrEffectRef* SkTwoPointConicalGradient::asNewEffect(GrContext*, const SkPaint&, | 397 bool SkTwoPointConicalGradient::asNewEffect(GrContext* context, const SkPaint& p
aint, |
394 const SkMatrix*) const { | 398 const SkMatrix* localMatrix, GrColor
* grColor, |
| 399 GrEffectRef** grEffect) const { |
395 SkDEBUGFAIL("Should not call in GPU-less build"); | 400 SkDEBUGFAIL("Should not call in GPU-less build"); |
396 return NULL; | 401 return false; |
397 } | 402 } |
398 | 403 |
399 #endif | 404 #endif |
400 | 405 |
401 #ifndef SK_IGNORE_TO_STRING | 406 #ifndef SK_IGNORE_TO_STRING |
402 void SkTwoPointConicalGradient::toString(SkString* str) const { | 407 void SkTwoPointConicalGradient::toString(SkString* str) const { |
403 str->append("SkTwoPointConicalGradient: ("); | 408 str->append("SkTwoPointConicalGradient: ("); |
404 | 409 |
405 str->append("center1: ("); | 410 str->append("center1: ("); |
406 str->appendScalar(fCenter1.fX); | 411 str->appendScalar(fCenter1.fX); |
407 str->append(", "); | 412 str->append(", "); |
408 str->appendScalar(fCenter1.fY); | 413 str->appendScalar(fCenter1.fY); |
409 str->append(") radius1: "); | 414 str->append(") radius1: "); |
410 str->appendScalar(fRadius1); | 415 str->appendScalar(fRadius1); |
411 str->append(" "); | 416 str->append(" "); |
412 | 417 |
413 str->append("center2: ("); | 418 str->append("center2: ("); |
414 str->appendScalar(fCenter2.fX); | 419 str->appendScalar(fCenter2.fX); |
415 str->append(", "); | 420 str->append(", "); |
416 str->appendScalar(fCenter2.fY); | 421 str->appendScalar(fCenter2.fY); |
417 str->append(") radius2: "); | 422 str->append(") radius2: "); |
418 str->appendScalar(fRadius2); | 423 str->appendScalar(fRadius2); |
419 str->append(" "); | 424 str->append(" "); |
420 | 425 |
421 this->INHERITED::toString(str); | 426 this->INHERITED::toString(str); |
422 | 427 |
423 str->append(")"); | 428 str->append(")"); |
424 } | 429 } |
425 #endif | 430 #endif |
OLD | NEW |