OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |