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