| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrRRectEffect.h" | 8 #include "GrRRectEffect.h" |
| 9 | 9 |
| 10 #include "gl/GrGLEffect.h" | 10 #include "gl/GrGLEffect.h" |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 fPrevRRect = rrect; | 370 fPrevRRect = rrect; |
| 371 } | 371 } |
| 372 } | 372 } |
| 373 | 373 |
| 374 ////////////////////////////////////////////////////////////////////////////// | 374 ////////////////////////////////////////////////////////////////////////////// |
| 375 | 375 |
| 376 class GLEllipticalRRectEffect; | 376 class GLEllipticalRRectEffect; |
| 377 | 377 |
| 378 class EllipticalRRectEffect : public GrEffect { | 378 class EllipticalRRectEffect : public GrEffect { |
| 379 public: | 379 public: |
| 380 // This effect currently works for these two classifications of SkRRects | |
| 381 enum RRectType { | |
| 382 kSimple_RRectType, // SkRRect::kSimple_Type | |
| 383 kNinePatch_RRectType, // The two left x radii are the same, the two | |
| 384 // top y radii are the same, etc. | |
| 385 }; | |
| 386 | |
| 387 // This effect only supports rrects where the radii are >= kRadiusMin. | 380 // This effect only supports rrects where the radii are >= kRadiusMin. |
| 388 static const SkScalar kRadiusMin; | 381 static const SkScalar kRadiusMin; |
| 389 | 382 |
| 390 static GrEffectRef* Create(GrEffectEdgeType, RRectType, const SkRRect&); | 383 static GrEffectRef* Create(GrEffectEdgeType, const SkRRect&); |
| 391 | 384 |
| 392 virtual ~EllipticalRRectEffect() {}; | 385 virtual ~EllipticalRRectEffect() {}; |
| 393 static const char* Name() { return "EllipticalRRect"; } | 386 static const char* Name() { return "EllipticalRRect"; } |
| 394 | 387 |
| 395 const SkRRect& getRRect() const { return fRRect; } | 388 const SkRRect& getRRect() const { return fRRect; } |
| 396 | 389 |
| 397 RRectType getRRectType() const { return fRRectType; } | |
| 398 | 390 |
| 399 GrEffectEdgeType getEdgeType() const { return fEdgeType; } | 391 GrEffectEdgeType getEdgeType() const { return fEdgeType; } |
| 400 | 392 |
| 401 typedef GLEllipticalRRectEffect GLEffect; | 393 typedef GLEllipticalRRectEffect GLEffect; |
| 402 | 394 |
| 403 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | 395 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; |
| 404 | 396 |
| 405 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; | 397 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
| 406 | 398 |
| 407 private: | 399 private: |
| 408 EllipticalRRectEffect(GrEffectEdgeType, RRectType, const SkRRect&); | 400 EllipticalRRectEffect(GrEffectEdgeType, const SkRRect&); |
| 409 | 401 |
| 410 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; | 402 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE; |
| 411 | 403 |
| 412 SkRRect fRRect; | 404 SkRRect fRRect; |
| 413 RRectType fRRectType; | |
| 414 GrEffectEdgeType fEdgeType; | 405 GrEffectEdgeType fEdgeType; |
| 415 | 406 |
| 416 GR_DECLARE_EFFECT_TEST; | 407 GR_DECLARE_EFFECT_TEST; |
| 417 | 408 |
| 418 typedef GrEffect INHERITED; | 409 typedef GrEffect INHERITED; |
| 419 }; | 410 }; |
| 420 | 411 |
| 421 const SkScalar EllipticalRRectEffect::kRadiusMin = 0.5f; | 412 const SkScalar EllipticalRRectEffect::kRadiusMin = 0.5f; |
| 422 | 413 |
| 423 GrEffectRef* EllipticalRRectEffect::Create(GrEffectEdgeType edgeType, | 414 GrEffectRef* EllipticalRRectEffect::Create(GrEffectEdgeType edgeType, const SkRR
ect& rrect) { |
| 424 RRectType rrType, | |
| 425 const SkRRect& rrect) { | |
| 426 SkASSERT(kFillAA_GrEffectEdgeType == edgeType || kInverseFillAA_GrEffectEdge
Type == edgeType); | 415 SkASSERT(kFillAA_GrEffectEdgeType == edgeType || kInverseFillAA_GrEffectEdge
Type == edgeType); |
| 427 return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(EllipticalRRectEffect, (ed
geType, rrType, | 416 return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(EllipticalRRectEffect, (ed
geType, rrect)))); |
| 428 rr
ect)))); | |
| 429 } | 417 } |
| 430 | 418 |
| 431 void EllipticalRRectEffect::getConstantColorComponents(GrColor* color, uint32_t*
validFlags) const { | 419 void EllipticalRRectEffect::getConstantColorComponents(GrColor* color, uint32_t*
validFlags) const { |
| 432 *validFlags = 0; | 420 *validFlags = 0; |
| 433 } | 421 } |
| 434 | 422 |
| 435 const GrBackendEffectFactory& EllipticalRRectEffect::getFactory() const { | 423 const GrBackendEffectFactory& EllipticalRRectEffect::getFactory() const { |
| 436 return GrTBackendEffectFactory<EllipticalRRectEffect>::getInstance(); | 424 return GrTBackendEffectFactory<EllipticalRRectEffect>::getInstance(); |
| 437 } | 425 } |
| 438 | 426 |
| 439 EllipticalRRectEffect::EllipticalRRectEffect(GrEffectEdgeType edgeType, RRectTyp
e rrType, | 427 EllipticalRRectEffect::EllipticalRRectEffect(GrEffectEdgeType edgeType, const Sk
RRect& rrect) |
| 440 const SkRRect& rrect) | |
| 441 : fRRect(rrect) | 428 : fRRect(rrect) |
| 442 , fRRectType(rrType) | |
| 443 , fEdgeType(edgeType){ | 429 , fEdgeType(edgeType){ |
| 444 this->setWillReadFragmentPosition(); | 430 this->setWillReadFragmentPosition(); |
| 445 } | 431 } |
| 446 | 432 |
| 447 bool EllipticalRRectEffect::onIsEqual(const GrEffect& other) const { | 433 bool EllipticalRRectEffect::onIsEqual(const GrEffect& other) const { |
| 448 const EllipticalRRectEffect& erre = CastEffect<EllipticalRRectEffect>(other)
; | 434 const EllipticalRRectEffect& erre = CastEffect<EllipticalRRectEffect>(other)
; |
| 449 // No need to check fRRectType as it is derived from fRRect. | |
| 450 return fEdgeType == erre.fEdgeType && fRRect == erre.fRRect; | 435 return fEdgeType == erre.fEdgeType && fRRect == erre.fRRect; |
| 451 } | 436 } |
| 452 | 437 |
| 453 ////////////////////////////////////////////////////////////////////////////// | 438 ////////////////////////////////////////////////////////////////////////////// |
| 454 | 439 |
| 455 GR_DEFINE_EFFECT_TEST(EllipticalRRectEffect); | 440 GR_DEFINE_EFFECT_TEST(EllipticalRRectEffect); |
| 456 | 441 |
| 457 GrEffectRef* EllipticalRRectEffect::TestCreate(SkRandom* random, | 442 GrEffectRef* EllipticalRRectEffect::TestCreate(SkRandom* random, |
| 458 GrContext*, | 443 GrContext*, |
| 459 const GrDrawTargetCaps& caps, | 444 const GrDrawTargetCaps& caps, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 // a vector that points straight up for both the TL left and TR corners. Com
puting an | 529 // a vector that points straight up for both the TL left and TR corners. Com
puting an |
| 545 // alpha from this vector at either the TR or TL corner will give the correc
t result. Similarly, | 530 // alpha from this vector at either the TR or TL corner will give the correc
t result. Similarly, |
| 546 // fragments near the other three edges will get the correct AA. Fragments i
n the interior of | 531 // fragments near the other three edges will get the correct AA. Fragments i
n the interior of |
| 547 // the rrect will have a (0,0) vector at all four corners. So long as the ra
dii > 0.5 they will | 532 // the rrect will have a (0,0) vector at all four corners. So long as the ra
dii > 0.5 they will |
| 548 // correctly produce an alpha value of 1 at all four corners. We take the mi
n of all the alphas. | 533 // correctly produce an alpha value of 1 at all four corners. We take the mi
n of all the alphas. |
| 549 // The code below is a simplified version of the above that performs maxs on
the vector | 534 // The code below is a simplified version of the above that performs maxs on
the vector |
| 550 // components before computing distances and alpha values so that only one d
istance computation | 535 // components before computing distances and alpha values so that only one d
istance computation |
| 551 // need be computed to determine the min alpha. | 536 // need be computed to determine the min alpha. |
| 552 builder->fsCodeAppendf("\t\tvec2 dxy0 = %s.xy - %s.xy;\n", rectName, fragmen
tPos); | 537 builder->fsCodeAppendf("\t\tvec2 dxy0 = %s.xy - %s.xy;\n", rectName, fragmen
tPos); |
| 553 builder->fsCodeAppendf("\t\tvec2 dxy1 = %s.xy - %s.zw;\n", fragmentPos, rect
Name); | 538 builder->fsCodeAppendf("\t\tvec2 dxy1 = %s.xy - %s.zw;\n", fragmentPos, rect
Name); |
| 554 switch (erre.getRRectType()) { | 539 switch (erre.getRRect().getType()) { |
| 555 case EllipticalRRectEffect::kSimple_RRectType: { | 540 case SkRRect::kSimple_Type: { |
| 556 const char *invRadiiXYSqdName; | 541 const char *invRadiiXYSqdName; |
| 557 fInvRadiiSqdUniform = builder->addUniform(GrGLShaderBuilder::kFragme
nt_Visibility, | 542 fInvRadiiSqdUniform = builder->addUniform(GrGLShaderBuilder::kFragme
nt_Visibility, |
| 558 kVec2f_GrSLType, | 543 kVec2f_GrSLType, |
| 559 "invRadiiXY", | 544 "invRadiiXY", |
| 560 &invRadiiXYSqdName); | 545 &invRadiiXYSqdName); |
| 561 builder->fsCodeAppend("\t\tvec2 dxy = max(max(dxy0, dxy1), 0.0);\n")
; | 546 builder->fsCodeAppend("\t\tvec2 dxy = max(max(dxy0, dxy1), 0.0);\n")
; |
| 562 // Z is the x/y offsets divided by squared radii. | 547 // Z is the x/y offsets divided by squared radii. |
| 563 builder->fsCodeAppendf("\t\tvec2 Z = dxy * %s;\n", invRadiiXYSqdName
); | 548 builder->fsCodeAppendf("\t\tvec2 Z = dxy * %s;\n", invRadiiXYSqdName
); |
| 564 break; | 549 break; |
| 565 } | 550 } |
| 566 case EllipticalRRectEffect::kNinePatch_RRectType: { | 551 case SkRRect::kNinePatch_Type: { |
| 567 const char *invRadiiLTRBSqdName; | 552 const char *invRadiiLTRBSqdName; |
| 568 fInvRadiiSqdUniform = builder->addUniform(GrGLShaderBuilder::kFragme
nt_Visibility, | 553 fInvRadiiSqdUniform = builder->addUniform(GrGLShaderBuilder::kFragme
nt_Visibility, |
| 569 kVec4f_GrSLType, | 554 kVec4f_GrSLType, |
| 570 "invRadiiLTRB", | 555 "invRadiiLTRB", |
| 571 &invRadiiLTRBSqdName); | 556 &invRadiiLTRBSqdName); |
| 572 builder->fsCodeAppend("\t\tvec2 dxy = max(max(dxy0, dxy1), 0.0);\n")
; | 557 builder->fsCodeAppend("\t\tvec2 dxy = max(max(dxy0, dxy1), 0.0);\n")
; |
| 573 // Z is the x/y offsets divided by squared radii. We only care about
the (at most) one | 558 // Z is the x/y offsets divided by squared radii. We only care about
the (at most) one |
| 574 // corner where both the x and y offsets are positive, hence the max
es. (The inverse | 559 // corner where both the x and y offsets are positive, hence the max
es. (The inverse |
| 575 // squared radii will always be positive.) | 560 // squared radii will always be positive.) |
| 576 builder->fsCodeAppendf("\t\tvec2 Z = max(max(dxy0 * %s.xy, dxy1 * %s
.zw), 0.0);\n", | 561 builder->fsCodeAppendf("\t\tvec2 Z = max(max(dxy0 * %s.xy, dxy1 * %s
.zw), 0.0);\n", |
| 577 invRadiiLTRBSqdName, invRadiiLTRBSqdName); | 562 invRadiiLTRBSqdName, invRadiiLTRBSqdName); |
| 578 break; | 563 break; |
| 579 } | 564 } |
| 565 default: |
| 566 GrCrash("RRect should always be simple or nine-patch."); |
| 580 } | 567 } |
| 581 // implicit is the evaluation of (x/a)^2 + (y/b)^2 - 1. | 568 // implicit is the evaluation of (x/a)^2 + (y/b)^2 - 1. |
| 582 builder->fsCodeAppend("\t\tfloat implicit = dot(Z, dxy) - 1.0;\n"); | 569 builder->fsCodeAppend("\t\tfloat implicit = dot(Z, dxy) - 1.0;\n"); |
| 583 // grad_dot is the squared length of the gradient of the implicit. | 570 // grad_dot is the squared length of the gradient of the implicit. |
| 584 builder->fsCodeAppendf("\t\tfloat grad_dot = 4.0 * dot(Z, Z);\n"); | 571 builder->fsCodeAppendf("\t\tfloat grad_dot = 4.0 * dot(Z, Z);\n"); |
| 585 builder->fsCodeAppend("\t\tgrad_dot = max(grad_dot, 1.0e-4);\n"); | 572 builder->fsCodeAppend("\t\tgrad_dot = max(grad_dot, 1.0e-4);\n"); |
| 586 builder->fsCodeAppendf("\t\tfloat approx_dist = implicit * inversesqrt(grad_
dot);\n"); | 573 builder->fsCodeAppendf("\t\tfloat approx_dist = implicit * inversesqrt(grad_
dot);\n"); |
| 587 | 574 |
| 588 if (kFillAA_GrEffectEdgeType == erre.getEdgeType()) { | 575 if (kFillAA_GrEffectEdgeType == erre.getEdgeType()) { |
| 589 builder->fsCodeAppend("\t\tfloat alpha = clamp(0.5 - approx_dist, 0.0, 1
.0);\n"); | 576 builder->fsCodeAppend("\t\tfloat alpha = clamp(0.5 - approx_dist, 0.0, 1
.0);\n"); |
| 590 } else { | 577 } else { |
| 591 builder->fsCodeAppend("\t\tfloat alpha = clamp(0.5 + approx_dist, 0.0, 1
.0);\n"); | 578 builder->fsCodeAppend("\t\tfloat alpha = clamp(0.5 + approx_dist, 0.0, 1
.0);\n"); |
| 592 } | 579 } |
| 593 | 580 |
| 594 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor, | 581 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor, |
| 595 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_st
r()); | 582 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_st
r()); |
| 596 } | 583 } |
| 597 | 584 |
| 598 GrGLEffect::EffectKey GLEllipticalRRectEffect::GenKey(const GrDrawEffect& drawEf
fect, | 585 GrGLEffect::EffectKey GLEllipticalRRectEffect::GenKey(const GrDrawEffect& drawEf
fect, |
| 599 const GrGLCaps&) { | 586 const GrGLCaps&) { |
| 600 const EllipticalRRectEffect& erre = drawEffect.castEffect<EllipticalRRectEff
ect>(); | 587 const EllipticalRRectEffect& erre = drawEffect.castEffect<EllipticalRRectEff
ect>(); |
| 601 GR_STATIC_ASSERT(kLast_GrEffectEdgeType < (1 << 3)); | 588 GR_STATIC_ASSERT(kLast_GrEffectEdgeType < (1 << 3)); |
| 602 return erre.getRRectType() | erre.getEdgeType() << 3; | 589 return erre.getRRect().getType() | erre.getEdgeType() << 3; |
| 603 } | 590 } |
| 604 | 591 |
| 605 void GLEllipticalRRectEffect::setData(const GrGLUniformManager& uman, | 592 void GLEllipticalRRectEffect::setData(const GrGLUniformManager& uman, |
| 606 const GrDrawEffect& drawEffect) { | 593 const GrDrawEffect& drawEffect) { |
| 607 const EllipticalRRectEffect& erre = drawEffect.castEffect<EllipticalRRectEff
ect>(); | 594 const EllipticalRRectEffect& erre = drawEffect.castEffect<EllipticalRRectEff
ect>(); |
| 608 const SkRRect& rrect = erre.getRRect(); | 595 const SkRRect& rrect = erre.getRRect(); |
| 609 if (rrect != fPrevRRect) { | 596 if (rrect != fPrevRRect) { |
| 610 SkRect rect = rrect.getBounds(); | 597 SkRect rect = rrect.getBounds(); |
| 611 const SkVector& r0 = rrect.radii(SkRRect::kUpperLeft_Corner); | 598 const SkVector& r0 = rrect.radii(SkRRect::kUpperLeft_Corner); |
| 612 SkASSERT(r0.fX >= EllipticalRRectEffect::kRadiusMin); | 599 SkASSERT(r0.fX >= EllipticalRRectEffect::kRadiusMin); |
| 613 SkASSERT(r0.fY >= EllipticalRRectEffect::kRadiusMin); | 600 SkASSERT(r0.fY >= EllipticalRRectEffect::kRadiusMin); |
| 614 switch (erre.getRRectType()) { | 601 switch (erre.getRRect().getType()) { |
| 615 case EllipticalRRectEffect::kSimple_RRectType: | 602 case SkRRect::kSimple_Type: |
| 616 rect.inset(r0.fX, r0.fY); | 603 rect.inset(r0.fX, r0.fY); |
| 617 uman.set2f(fInvRadiiSqdUniform, 1.f / (r0.fX * r0.fX), | 604 uman.set2f(fInvRadiiSqdUniform, 1.f / (r0.fX * r0.fX), |
| 618 1.f / (r0.fY * r0.fY)); | 605 1.f / (r0.fY * r0.fY)); |
| 619 break; | 606 break; |
| 620 case EllipticalRRectEffect::kNinePatch_RRectType: { | 607 case SkRRect::kNinePatch_Type: { |
| 621 const SkVector& r1 = rrect.radii(SkRRect::kLowerRight_Corner); | 608 const SkVector& r1 = rrect.radii(SkRRect::kLowerRight_Corner); |
| 622 SkASSERT(r1.fX >= EllipticalRRectEffect::kRadiusMin); | 609 SkASSERT(r1.fX >= EllipticalRRectEffect::kRadiusMin); |
| 623 SkASSERT(r1.fY >= EllipticalRRectEffect::kRadiusMin); | 610 SkASSERT(r1.fY >= EllipticalRRectEffect::kRadiusMin); |
| 624 rect.fLeft += r0.fX; | 611 rect.fLeft += r0.fX; |
| 625 rect.fTop += r0.fY; | 612 rect.fTop += r0.fY; |
| 626 rect.fRight -= r1.fX; | 613 rect.fRight -= r1.fX; |
| 627 rect.fBottom -= r1.fY; | 614 rect.fBottom -= r1.fY; |
| 628 uman.set4f(fInvRadiiSqdUniform, 1.f / (r0.fX * r0.fX), | 615 uman.set4f(fInvRadiiSqdUniform, 1.f / (r0.fX * r0.fX), |
| 629 1.f / (r0.fY * r0.fY), | 616 1.f / (r0.fY * r0.fY), |
| 630 1.f / (r1.fX * r1.fX), | 617 1.f / (r1.fX * r1.fX), |
| 631 1.f / (r1.fY * r1.fY)); | 618 1.f / (r1.fY * r1.fY)); |
| 632 break; | 619 break; |
| 633 } | 620 } |
| 621 default: |
| 622 GrCrash("RRect should always be simple or nine-patch."); |
| 634 } | 623 } |
| 635 uman.set4f(fInnerRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.f
Bottom); | 624 uman.set4f(fInnerRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.f
Bottom); |
| 636 fPrevRRect = rrect; | 625 fPrevRRect = rrect; |
| 637 } | 626 } |
| 638 } | 627 } |
| 639 | 628 |
| 640 ////////////////////////////////////////////////////////////////////////////// | 629 ////////////////////////////////////////////////////////////////////////////// |
| 641 | 630 |
| 642 GrEffectRef* GrRRectEffect::Create(GrEffectEdgeType edgeType, const SkRRect& rre
ct) { | 631 GrEffectRef* GrRRectEffect::Create(GrEffectEdgeType edgeType, const SkRRect& rre
ct) { |
| 643 if (kFillAA_GrEffectEdgeType != edgeType && kInverseFillAA_GrEffectEdgeType
!= edgeType) { | 632 if (kFillAA_GrEffectEdgeType != edgeType && kInverseFillAA_GrEffectEdgeType
!= edgeType) { |
| 644 return NULL; | 633 return NULL; |
| 645 } | 634 } |
| 646 uint32_t cornerFlags; | 635 uint32_t cornerFlags; |
| 647 if (rrect.isSimple()) { | 636 if (rrect.isSimple()) { |
| 648 if (rrect.getSimpleRadii().fX == rrect.getSimpleRadii().fY) { | 637 if (rrect.getSimpleRadii().fX == rrect.getSimpleRadii().fY) { |
| 649 if (rrect.getSimpleRadii().fX < CircularRRectEffect::kRadiusMin) { | 638 if (rrect.getSimpleRadii().fX < CircularRRectEffect::kRadiusMin) { |
| 650 return NULL; | 639 return NULL; |
| 651 } | 640 } |
| 652 cornerFlags = CircularRRectEffect::kAll_CornerFlags; | 641 cornerFlags = CircularRRectEffect::kAll_CornerFlags; |
| 653 } else { | 642 } else { |
| 654 if (rrect.getSimpleRadii().fX < EllipticalRRectEffect::kRadiusMin || | 643 if (rrect.getSimpleRadii().fX < EllipticalRRectEffect::kRadiusMin || |
| 655 rrect.getSimpleRadii().fY < EllipticalRRectEffect::kRadiusMin) { | 644 rrect.getSimpleRadii().fY < EllipticalRRectEffect::kRadiusMin) { |
| 656 return NULL; | 645 return NULL; |
| 657 } | 646 } |
| 658 return EllipticalRRectEffect::Create(edgeType, | 647 return EllipticalRRectEffect::Create(edgeType, rrect); |
| 659 EllipticalRRectEffect::kSimple_
RRectType, rrect); | |
| 660 } | 648 } |
| 661 } else if (rrect.isComplex() || rrect.isNinePatch()) { | 649 } else if (rrect.isComplex() || rrect.isNinePatch()) { |
| 662 // Check for the "tab" cases - two adjacent circular corners and two squ
are corners. | 650 // Check for the "tab" cases - two adjacent circular corners and two squ
are corners. |
| 663 SkScalar radius = 0; | 651 SkScalar radius = 0; |
| 664 cornerFlags = 0; | 652 cornerFlags = 0; |
| 665 for (int c = 0; c < 4; ++c) { | 653 for (int c = 0; c < 4; ++c) { |
| 666 const SkVector& r = rrect.radii((SkRRect::Corner)c); | 654 const SkVector& r = rrect.radii((SkRRect::Corner)c); |
| 667 SkASSERT((0 == r.fX) == (0 == r.fY)); | 655 SkASSERT((0 == r.fX) == (0 == r.fY)); |
| 668 if (0 == r.fX) { | 656 if (0 == r.fX) { |
| 669 continue; | 657 continue; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 700 case CircularRRectEffect::kAll_CornerFlags: | 688 case CircularRRectEffect::kAll_CornerFlags: |
| 701 break; | 689 break; |
| 702 default: | 690 default: |
| 703 if (rrect.isNinePatch()) { | 691 if (rrect.isNinePatch()) { |
| 704 const SkVector& r0 = rrect.radii(SkRRect::kUpperLeft_Corner)
; | 692 const SkVector& r0 = rrect.radii(SkRRect::kUpperLeft_Corner)
; |
| 705 const SkVector& r1 = rrect.radii(SkRRect::kLowerRight_Corner
); | 693 const SkVector& r1 = rrect.radii(SkRRect::kLowerRight_Corner
); |
| 706 if (r0.fX >= EllipticalRRectEffect::kRadiusMin && | 694 if (r0.fX >= EllipticalRRectEffect::kRadiusMin && |
| 707 r0.fY >= EllipticalRRectEffect::kRadiusMin && | 695 r0.fY >= EllipticalRRectEffect::kRadiusMin && |
| 708 r1.fX >= EllipticalRRectEffect::kRadiusMin && | 696 r1.fX >= EllipticalRRectEffect::kRadiusMin && |
| 709 r1.fY >= EllipticalRRectEffect::kRadiusMin) { | 697 r1.fY >= EllipticalRRectEffect::kRadiusMin) { |
| 710 return EllipticalRRectEffect::Create(edgeType, | 698 return EllipticalRRectEffect::Create(edgeType, rrect); |
| 711 EllipticalRRectEffect::k
NinePatch_RRectType, | |
| 712 rrect); | |
| 713 } | 699 } |
| 714 } | 700 } |
| 715 return NULL; | 701 return NULL; |
| 716 } | 702 } |
| 717 } else { | 703 } else { |
| 718 return NULL; | 704 return NULL; |
| 719 } | 705 } |
| 720 return CircularRRectEffect::Create(edgeType, cornerFlags, rrect); | 706 return CircularRRectEffect::Create(edgeType, cornerFlags, rrect); |
| 721 } | 707 } |
| OLD | NEW |