| 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 "SkRadialGradient.h" | 9 #include "SkRadialGradient.h" |
| 10 #include "SkRadialGradient_Table.h" | 10 #include "SkRadialGradient_Table.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 245 |
| 246 SkShader::GradientType SkRadialGradient::asAGradient(GradientInfo* info) const { | 246 SkShader::GradientType SkRadialGradient::asAGradient(GradientInfo* info) const { |
| 247 if (info) { | 247 if (info) { |
| 248 commonAsAGradient(info); | 248 commonAsAGradient(info); |
| 249 info->fPoint[0] = fCenter; | 249 info->fPoint[0] = fCenter; |
| 250 info->fRadius[0] = fRadius; | 250 info->fRadius[0] = fRadius; |
| 251 } | 251 } |
| 252 return kRadial_GradientType; | 252 return kRadial_GradientType; |
| 253 } | 253 } |
| 254 | 254 |
| 255 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 256 SkRadialGradient::SkRadialGradient(SkReadBuffer& buffer) |
| 257 : INHERITED(buffer), |
| 258 fCenter(buffer.readPoint()), |
| 259 fRadius(buffer.readScalar()) { |
| 260 } |
| 261 #endif |
| 262 |
| 255 SkFlattenable* SkRadialGradient::CreateProc(SkReadBuffer& buffer) { | 263 SkFlattenable* SkRadialGradient::CreateProc(SkReadBuffer& buffer) { |
| 256 DescriptorScope desc; | 264 DescriptorScope desc; |
| 257 if (!desc.unflatten(buffer)) { | 265 if (!desc.unflatten(buffer)) { |
| 258 return NULL; | 266 return NULL; |
| 259 } | 267 } |
| 260 const SkPoint center = buffer.readPoint(); | 268 const SkPoint center = buffer.readPoint(); |
| 261 const SkScalar radius = buffer.readScalar(); | 269 const SkScalar radius = buffer.readScalar(); |
| 262 return SkGradientShader::CreateRadial(center, radius, desc.fColors, desc.fPo
s, desc.fCount, | 270 return SkGradientShader::CreateRadial(center, radius, desc.fColors, desc.fPo
s, desc.fCount, |
| 263 desc.fTileMode, desc.fGradFlags, desc.
fLocalMatrix); | 271 desc.fTileMode, desc.fGradFlags, desc.
fLocalMatrix); |
| 264 } | 272 } |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 t.append(")"); | 571 t.append(")"); |
| 564 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); | 572 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); |
| 565 } | 573 } |
| 566 | 574 |
| 567 ///////////////////////////////////////////////////////////////////// | 575 ///////////////////////////////////////////////////////////////////// |
| 568 | 576 |
| 569 bool SkRadialGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa
int, | 577 bool SkRadialGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa
int, |
| 570 const SkMatrix* localMatrix, GrColor*
paintColor, | 578 const SkMatrix* localMatrix, GrColor*
paintColor, |
| 571 GrFragmentProcessor** fp) const { | 579 GrFragmentProcessor** fp) const { |
| 572 SkASSERT(context); | 580 SkASSERT(context); |
| 573 | 581 |
| 574 SkMatrix matrix; | 582 SkMatrix matrix; |
| 575 if (!this->getLocalMatrix().invert(&matrix)) { | 583 if (!this->getLocalMatrix().invert(&matrix)) { |
| 576 return false; | 584 return false; |
| 577 } | 585 } |
| 578 if (localMatrix) { | 586 if (localMatrix) { |
| 579 SkMatrix inv; | 587 SkMatrix inv; |
| 580 if (!localMatrix->invert(&inv)) { | 588 if (!localMatrix->invert(&inv)) { |
| 581 return false; | 589 return false; |
| 582 } | 590 } |
| 583 matrix.postConcat(inv); | 591 matrix.postConcat(inv); |
| 584 } | 592 } |
| 585 matrix.postConcat(fPtsToUnit); | 593 matrix.postConcat(fPtsToUnit); |
| 586 | 594 |
| 587 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); | 595 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); |
| 588 *fp = GrRadialGradient::Create(context, *this, matrix, fTileMode); | 596 *fp = GrRadialGradient::Create(context, *this, matrix, fTileMode); |
| 589 | 597 |
| 590 return true; | 598 return true; |
| 591 } | 599 } |
| 592 | 600 |
| 593 #else | 601 #else |
| 594 | 602 |
| 595 bool SkRadialGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkM
atrix*, GrColor*, | 603 bool SkRadialGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkM
atrix*, GrColor*, |
| 596 GrFragmentProcessor**) const { | 604 GrFragmentProcessor**) const { |
| 597 SkDEBUGFAIL("Should not call in GPU-less build"); | 605 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 598 return false; | 606 return false; |
| 599 } | 607 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 610 str->appendScalar(fCenter.fY); | 618 str->appendScalar(fCenter.fY); |
| 611 str->append(") radius: "); | 619 str->append(") radius: "); |
| 612 str->appendScalar(fRadius); | 620 str->appendScalar(fRadius); |
| 613 str->append(" "); | 621 str->append(" "); |
| 614 | 622 |
| 615 this->INHERITED::toString(str); | 623 this->INHERITED::toString(str); |
| 616 | 624 |
| 617 str->append(")"); | 625 str->append(")"); |
| 618 } | 626 } |
| 619 #endif | 627 #endif |
| OLD | NEW |