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

Side by Side Diff: src/gpu/GrOvalRenderer.cpp

Issue 1683843006: Remove the 0.5 bias from the ellipse edge function. This makes coverage drop to zero before we get … (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Oops, removing debugging code. Created 4 years, 10 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
« no previous file with comments | « no previous file | 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 2013 Google Inc. 2 * Copyright 2013 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 "GrOvalRenderer.h" 8 #include "GrOvalRenderer.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // for outer curve 296 // for outer curve
297 fragBuilder->codeAppendf("vec2 scaledOffset = %s*%s.xy;", ellipseOff sets.fsIn(), 297 fragBuilder->codeAppendf("vec2 scaledOffset = %s*%s.xy;", ellipseOff sets.fsIn(),
298 ellipseRadii.fsIn()); 298 ellipseRadii.fsIn());
299 fragBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset ) - 1.0;"); 299 fragBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset ) - 1.0;");
300 fragBuilder->codeAppendf("vec2 grad = 2.0*scaledOffset*%s.xy;", elli pseRadii.fsIn()); 300 fragBuilder->codeAppendf("vec2 grad = 2.0*scaledOffset*%s.xy;", elli pseRadii.fsIn());
301 fragBuilder->codeAppend("float grad_dot = dot(grad, grad);"); 301 fragBuilder->codeAppend("float grad_dot = dot(grad, grad);");
302 302
303 // avoid calling inversesqrt on zero. 303 // avoid calling inversesqrt on zero.
304 fragBuilder->codeAppend("grad_dot = max(grad_dot, 1.0e-4);"); 304 fragBuilder->codeAppend("grad_dot = max(grad_dot, 1.0e-4);");
305 fragBuilder->codeAppend("float invlen = inversesqrt(grad_dot);"); 305 fragBuilder->codeAppend("float invlen = inversesqrt(grad_dot);");
306 fragBuilder->codeAppend("float edgeAlpha = clamp(0.5-test*invlen, 0. 0, 1.0);"); 306 fragBuilder->codeAppend("float edgeAlpha = clamp(-test*invlen, 0.0, 1.0);");
307 307
308 // for inner curve 308 // for inner curve
309 if (ee.isStroked()) { 309 if (ee.isStroked()) {
310 fragBuilder->codeAppendf("scaledOffset = %s*%s.zw;", 310 fragBuilder->codeAppendf("scaledOffset = %s*%s.zw;",
311 ellipseOffsets.fsIn(), ellipseRadii.fsI n()); 311 ellipseOffsets.fsIn(), ellipseRadii.fsI n());
312 fragBuilder->codeAppend("test = dot(scaledOffset, scaledOffset) - 1.0;"); 312 fragBuilder->codeAppend("test = dot(scaledOffset, scaledOffset) - 1.0;");
313 fragBuilder->codeAppendf("grad = 2.0*scaledOffset*%s.zw;", 313 fragBuilder->codeAppendf("grad = 2.0*scaledOffset*%s.zw;",
314 ellipseRadii.fsIn()); 314 ellipseRadii.fsIn());
315 fragBuilder->codeAppend("invlen = inversesqrt(dot(grad, grad));" ); 315 fragBuilder->codeAppend("invlen = inversesqrt(dot(grad, grad));" );
316 fragBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0 , 1.0);"); 316 fragBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0 , 1.0);");
(...skipping 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after
2078 } 2078 }
2079 2079
2080 DRAW_BATCH_TEST_DEFINE(RRectBatch) { 2080 DRAW_BATCH_TEST_DEFINE(RRectBatch) {
2081 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); 2081 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random);
2082 GrColor color = GrRandomColor(random); 2082 GrColor color = GrRandomColor(random);
2083 const SkRRect& rrect = GrTest::TestRRectSimple(random); 2083 const SkRRect& rrect = GrTest::TestRRectSimple(random);
2084 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom)); 2084 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom));
2085 } 2085 }
2086 2086
2087 #endif 2087 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698