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

Side by Side Diff: src/gpu/effects/GrOvalEffect.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/GrOvalRenderer.cpp ('k') | src/gpu/effects/GrRRectEffect.cpp » ('j') | 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 "GrOvalEffect.h" 8 #include "GrOvalEffect.h"
9 9
10 #include "gl/GrGLEffect.h" 10 #include "gl/GrGLEffect.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 &ellipseName); 310 &ellipseName);
311 const char* fragmentPos = builder->fragmentPosition(); 311 const char* fragmentPos = builder->fragmentPosition();
312 312
313 // d is the offset to the ellipse center 313 // d is the offset to the ellipse center
314 builder->fsCodeAppendf("\t\tvec2 d = %s.xy - %s.xy;\n", fragmentPos, ellipse Name); 314 builder->fsCodeAppendf("\t\tvec2 d = %s.xy - %s.xy;\n", fragmentPos, ellipse Name);
315 builder->fsCodeAppendf("\t\tvec2 Z = d * %s.zw;\n", ellipseName); 315 builder->fsCodeAppendf("\t\tvec2 Z = d * %s.zw;\n", ellipseName);
316 // implicit is the evaluation of (x/rx)^2 + (y/ry)^2 - 1. 316 // implicit is the evaluation of (x/rx)^2 + (y/ry)^2 - 1.
317 builder->fsCodeAppend("\t\tfloat implicit = dot(Z, d) - 1.0;\n"); 317 builder->fsCodeAppend("\t\tfloat implicit = dot(Z, d) - 1.0;\n");
318 // grad_dot is the squared length of the gradient of the implicit. 318 // grad_dot is the squared length of the gradient of the implicit.
319 builder->fsCodeAppendf("\t\tfloat grad_dot = 4.0 * dot(Z, Z);\n"); 319 builder->fsCodeAppendf("\t\tfloat grad_dot = 4.0 * dot(Z, Z);\n");
320 if (builder->ctxInfo().caps()->dropsTileOnZeroDivide()) { 320 // avoid calling inversesqrt on zero.
321 builder->fsCodeAppend("\t\tgrad_dot = max(grad_dot, 1.0e-4);\n"); 321 builder->fsCodeAppend("\t\tgrad_dot = max(grad_dot, 1.0e-4);\n");
322 }
323 builder->fsCodeAppendf("\t\tfloat approx_dist = implicit * inversesqrt(grad_ dot);\n"); 322 builder->fsCodeAppendf("\t\tfloat approx_dist = implicit * inversesqrt(grad_ dot);\n");
324 323
325 switch (ee.getEdgeType()) { 324 switch (ee.getEdgeType()) {
326 case kFillAA_GrEffectEdgeType: 325 case kFillAA_GrEffectEdgeType:
327 builder->fsCodeAppend("\t\tfloat alpha = clamp(0.5 - approx_dist, 0. 0, 1.0);\n"); 326 builder->fsCodeAppend("\t\tfloat alpha = clamp(0.5 - approx_dist, 0. 0, 1.0);\n");
328 break; 327 break;
329 case kInverseFillAA_GrEffectEdgeType: 328 case kInverseFillAA_GrEffectEdgeType:
330 builder->fsCodeAppend("\t\tfloat alpha = clamp(0.5 + approx_dist, 0. 0, 1.0);\n"); 329 builder->fsCodeAppend("\t\tfloat alpha = clamp(0.5 + approx_dist, 0. 0, 1.0);\n");
331 break; 330 break;
332 case kFillBW_GrEffectEdgeType: 331 case kFillBW_GrEffectEdgeType:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 w /= 2; 371 w /= 2;
373 return CircleEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval .fTop + w), w); 372 return CircleEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval .fTop + w), w);
374 } else { 373 } else {
375 w /= 2; 374 w /= 2;
376 h /= 2; 375 h /= 2;
377 return EllipseEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, ova l.fTop + h), w, h); 376 return EllipseEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, ova l.fTop + h), w, h);
378 } 377 }
379 378
380 return NULL; 379 return NULL;
381 } 380 }
OLDNEW
« no previous file with comments | « src/gpu/GrOvalRenderer.cpp ('k') | src/gpu/effects/GrRRectEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698