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

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

Issue 231093002: Do div-by-zero check for all gpus in ellipse/rr effects. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/effects/GrOvalEffect.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 GrCrash("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 if (builder->ctxInfo().caps()->dropsTileOnZeroDivide()) { 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 }
578 builder->fsCodeAppendf("\t\tfloat approx_dist = implicit * inversesqrt(grad_ dot);\n"); 577 builder->fsCodeAppendf("\t\tfloat approx_dist = implicit * inversesqrt(grad_ dot);\n");
579 578
580 if (kFillAA_GrEffectEdgeType == erre.getEdgeType()) { 579 if (kFillAA_GrEffectEdgeType == erre.getEdgeType()) {
581 builder->fsCodeAppend("\t\tfloat alpha = clamp(0.5 - approx_dist, 0.0, 1 .0);\n"); 580 builder->fsCodeAppend("\t\tfloat alpha = clamp(0.5 - approx_dist, 0.0, 1 .0);\n");
582 } else { 581 } else {
583 builder->fsCodeAppend("\t\tfloat alpha = clamp(0.5 + approx_dist, 0.0, 1 .0);\n"); 582 builder->fsCodeAppend("\t\tfloat alpha = clamp(0.5 + approx_dist, 0.0, 1 .0);\n");
584 } 583 }
585 584
586 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor, 585 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor,
587 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_st r()); 586 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_st r());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 if (rrect.isNinePatch()) { 721 if (rrect.isNinePatch()) {
723 return EllipticalRRectEffect::Create(edgeType, rrect); 722 return EllipticalRRectEffect::Create(edgeType, rrect);
724 } 723 }
725 return NULL; 724 return NULL;
726 } 725 }
727 } 726 }
728 } 727 }
729 728
730 return NULL; 729 return NULL;
731 } 730 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrOvalEffect.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698