Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: src/gpu/effects/GrRRectEffect.cpp

Issue 257393004: Convert GrCrash->SkFAIL GrDebugCrash->SkDEBUGFAIL (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: whitespace change Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 rect.fBottom -= radius; 362 rect.fBottom -= radius;
363 break; 363 break;
364 case CircularRRectEffect::kBottom_CornerFlags: 364 case CircularRRectEffect::kBottom_CornerFlags:
365 radius = rrect.radii(SkRRect::kLowerLeft_Corner).fX; 365 radius = rrect.radii(SkRRect::kLowerLeft_Corner).fX;
366 rect.fLeft += radius; 366 rect.fLeft += radius;
367 rect.fTop -= 0.5f; 367 rect.fTop -= 0.5f;
368 rect.fRight -= radius; 368 rect.fRight -= radius;
369 rect.fBottom -= radius; 369 rect.fBottom -= radius;
370 break; 370 break;
371 default: 371 default:
372 GrCrash("Should have been one of the above cases."); 372 SkFAIL("Should have been one of the above cases.");
373 } 373 }
374 uman.set4f(fInnerRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.f Bottom); 374 uman.set4f(fInnerRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.f Bottom);
375 uman.set1f(fRadiusPlusHalfUniform, radius + 0.5f); 375 uman.set1f(fRadiusPlusHalfUniform, radius + 0.5f);
376 fPrevRRect = rrect; 376 fPrevRRect = rrect;
377 } 377 }
378 } 378 }
379 379
380 ////////////////////////////////////////////////////////////////////////////// 380 //////////////////////////////////////////////////////////////////////////////
381 381
382 class GLEllipticalRRectEffect; 382 class GLEllipticalRRectEffect;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 &invRadiiLTRBSqdName); 559 &invRadiiLTRBSqdName);
560 builder->fsCodeAppend("\t\tvec2 dxy = max(max(dxy0, dxy1), 0.0);\n") ; 560 builder->fsCodeAppend("\t\tvec2 dxy = max(max(dxy0, dxy1), 0.0);\n") ;
561 // Z is the x/y offsets divided by squared radii. We only care about the (at most) one 561 // Z is the x/y offsets divided by squared radii. We only care about the (at most) one
562 // corner where both the x and y offsets are positive, hence the max es. (The inverse 562 // corner where both the x and y offsets are positive, hence the max es. (The inverse
563 // squared radii will always be positive.) 563 // squared radii will always be positive.)
564 builder->fsCodeAppendf("\t\tvec2 Z = max(max(dxy0 * %s.xy, dxy1 * %s .zw), 0.0);\n", 564 builder->fsCodeAppendf("\t\tvec2 Z = max(max(dxy0 * %s.xy, dxy1 * %s .zw), 0.0);\n",
565 invRadiiLTRBSqdName, invRadiiLTRBSqdName); 565 invRadiiLTRBSqdName, invRadiiLTRBSqdName);
566 break; 566 break;
567 } 567 }
568 default: 568 default:
569 GrCrash("RRect should always be simple or nine-patch."); 569 SkFAIL("RRect should always be simple or nine-patch.");
570 } 570 }
571 // implicit is the evaluation of (x/a)^2 + (y/b)^2 - 1. 571 // implicit is the evaluation of (x/a)^2 + (y/b)^2 - 1.
572 builder->fsCodeAppend("\t\tfloat implicit = dot(Z, dxy) - 1.0;\n"); 572 builder->fsCodeAppend("\t\tfloat implicit = dot(Z, dxy) - 1.0;\n");
573 // grad_dot is the squared length of the gradient of the implicit. 573 // grad_dot is the squared length of the gradient of the implicit.
574 builder->fsCodeAppendf("\t\tfloat grad_dot = 4.0 * dot(Z, Z);\n"); 574 builder->fsCodeAppendf("\t\tfloat grad_dot = 4.0 * dot(Z, Z);\n");
575 // avoid calling inversesqrt on zero. 575 // avoid calling inversesqrt on zero.
576 builder->fsCodeAppend("\t\tgrad_dot = max(grad_dot, 1.0e-4);\n"); 576 builder->fsCodeAppend("\t\tgrad_dot = max(grad_dot, 1.0e-4);\n");
577 builder->fsCodeAppendf("\t\tfloat approx_dist = implicit * inversesqrt(grad_ dot);\n"); 577 builder->fsCodeAppendf("\t\tfloat approx_dist = implicit * inversesqrt(grad_ dot);\n");
578 578
579 if (kFillAA_GrEffectEdgeType == erre.getEdgeType()) { 579 if (kFillAA_GrEffectEdgeType == erre.getEdgeType()) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 rect.fTop += r0.fY; 616 rect.fTop += r0.fY;
617 rect.fRight -= r1.fX; 617 rect.fRight -= r1.fX;
618 rect.fBottom -= r1.fY; 618 rect.fBottom -= r1.fY;
619 uman.set4f(fInvRadiiSqdUniform, 1.f / (r0.fX * r0.fX), 619 uman.set4f(fInvRadiiSqdUniform, 1.f / (r0.fX * r0.fX),
620 1.f / (r0.fY * r0.fY), 620 1.f / (r0.fY * r0.fY),
621 1.f / (r1.fX * r1.fX), 621 1.f / (r1.fX * r1.fX),
622 1.f / (r1.fY * r1.fY)); 622 1.f / (r1.fY * r1.fY));
623 break; 623 break;
624 } 624 }
625 default: 625 default:
626 GrCrash("RRect should always be simple or nine-patch."); 626 SkFAIL("RRect should always be simple or nine-patch.");
627 } 627 }
628 uman.set4f(fInnerRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.f Bottom); 628 uman.set4f(fInnerRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.f Bottom);
629 fPrevRRect = rrect; 629 fPrevRRect = rrect;
630 } 630 }
631 } 631 }
632 632
633 ////////////////////////////////////////////////////////////////////////////// 633 //////////////////////////////////////////////////////////////////////////////
634 634
635 GrEffectRef* GrRRectEffect::Create(GrEffectEdgeType edgeType, const SkRRect& rre ct) { 635 GrEffectRef* GrRRectEffect::Create(GrEffectEdgeType edgeType, const SkRRect& rre ct) {
636 if (rrect.isRect()) { 636 if (rrect.isRect()) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 if (rrect.isNinePatch()) { 721 if (rrect.isNinePatch()) {
722 return EllipticalRRectEffect::Create(edgeType, rrect); 722 return EllipticalRRectEffect::Create(edgeType, rrect);
723 } 723 }
724 return NULL; 724 return NULL;
725 } 725 }
726 } 726 }
727 } 727 }
728 728
729 return NULL; 729 return NULL;
730 } 730 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698