OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrPLSPathRenderer.h" | 8 #include "GrPLSPathRenderer.h" |
9 | 9 |
10 #include "SkChunkAlloc.h" | 10 #include "SkChunkAlloc.h" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 GrGLSLVertToFrag windings(kInt_GrSLType); | 329 GrGLSLVertToFrag windings(kInt_GrSLType); |
330 varyingHandler->addFlatVarying("windings", &windings, kLow_GrSLPreci
sion); | 330 varyingHandler->addFlatVarying("windings", &windings, kLow_GrSLPreci
sion); |
331 vsBuilder->codeAppendf("%s = %s;", | 331 vsBuilder->codeAppendf("%s = %s;", |
332 windings.vsOut(), te.inWindings()->fName); | 332 windings.vsOut(), te.inWindings()->fName); |
333 | 333 |
334 // emit transforms | 334 // emit transforms |
335 this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpAr
gs->fPositionVar, | 335 this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpAr
gs->fPositionVar, |
336 te.inPosition()->fName, te.localMatrix(), args.
fTransformsIn, | 336 te.inPosition()->fName, te.localMatrix(), args.
fTransformsIn, |
337 args.fTransformsOut); | 337 args.fTransformsOut); |
338 | 338 |
339 GrGLSLFragmentBuilder* fsBuilder = args.fFragBuilder; | 339 GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder; |
340 SkAssertResult(fsBuilder->enableFeature( | 340 SkAssertResult(fsBuilder->enableFeature( |
341 GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLF
eature)); | 341 GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLF
eature)); |
342 SkAssertResult(fsBuilder->enableFeature( | 342 SkAssertResult(fsBuilder->enableFeature( |
343 GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeatur
e)); | 343 GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeatur
e)); |
344 fsBuilder->declAppendf(GR_GL_PLS_PATH_DATA_DECL); | 344 fsBuilder->declAppendf(GR_GL_PLS_PATH_DATA_DECL); |
345 // Compute four subsamples, each shifted a quarter pixel along x and
y from | 345 // Compute four subsamples, each shifted a quarter pixel along x and
y from |
346 // gl_FragCoord. The oriented box positioning of the subsamples is o
f course not | 346 // gl_FragCoord. The oriented box positioning of the subsamples is o
f course not |
347 // optimal, but it greatly simplifies the math and this simplificati
on is necessary for | 347 // optimal, but it greatly simplifies the math and this simplificati
on is necessary for |
348 // performance reasons. | 348 // performance reasons. |
349 fsBuilder->codeAppendf("highp vec2 firstSample = %s.xy - vec2(0.25);
", | 349 fsBuilder->codeAppendf("highp vec2 firstSample = %s.xy - vec2(0.25);
", |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 windings.vsOut(), qe.inWindings()->fName); | 517 windings.vsOut(), qe.inWindings()->fName); |
518 | 518 |
519 // Setup position | 519 // Setup position |
520 this->setupPosition(vsBuilder, gpArgs, qe.inPosition()->fName); | 520 this->setupPosition(vsBuilder, gpArgs, qe.inPosition()->fName); |
521 | 521 |
522 // emit transforms | 522 // emit transforms |
523 this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpAr
gs->fPositionVar, | 523 this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpAr
gs->fPositionVar, |
524 qe.inPosition()->fName, qe.localMatrix(), args.
fTransformsIn, | 524 qe.inPosition()->fName, qe.localMatrix(), args.
fTransformsIn, |
525 args.fTransformsOut); | 525 args.fTransformsOut); |
526 | 526 |
527 GrGLSLFragmentBuilder* fsBuilder = args.fFragBuilder; | 527 GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder; |
528 SkAssertResult(fsBuilder->enableFeature( | 528 SkAssertResult(fsBuilder->enableFeature( |
529 GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLF
eature)); | 529 GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLF
eature)); |
530 SkAssertResult(fsBuilder->enableFeature( | 530 SkAssertResult(fsBuilder->enableFeature( |
531 GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeatur
e)); | 531 GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeatur
e)); |
532 static const int QUAD_ARGS = 2; | 532 static const int QUAD_ARGS = 2; |
533 GrGLSLShaderVar inQuadArgs[QUAD_ARGS] = { | 533 GrGLSLShaderVar inQuadArgs[QUAD_ARGS] = { |
534 GrGLSLShaderVar("dot", kFloat_GrSLType, 0, kHigh_GrSLPrecision), | 534 GrGLSLShaderVar("dot", kFloat_GrSLType, 0, kHigh_GrSLPrecision), |
535 GrGLSLShaderVar("uv", kVec2f_GrSLType, 0, kHigh_GrSLPrecision) | 535 GrGLSLShaderVar("uv", kVec2f_GrSLType, 0, kHigh_GrSLPrecision) |
536 }; | 536 }; |
537 SkString inQuadName; | 537 SkString inQuadName; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 kFloat_GrSLType, kLow_GrSLPr
ecision, | 675 kFloat_GrSLType, kLow_GrSLPr
ecision, |
676 "useEvenOdd"); | 676 "useEvenOdd"); |
677 const char* useEvenOdd = uniformHandler->getUniformCStr(fUseEvenOdd)
; | 677 const char* useEvenOdd = uniformHandler->getUniformCStr(fUseEvenOdd)
; |
678 | 678 |
679 varyingHandler->emitAttributes(fe); | 679 varyingHandler->emitAttributes(fe); |
680 this->setupPosition(vsBuilder, gpArgs, fe.inPosition()->fName); | 680 this->setupPosition(vsBuilder, gpArgs, fe.inPosition()->fName); |
681 this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpAr
gs->fPositionVar, | 681 this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpAr
gs->fPositionVar, |
682 fe.inPosition()->fName, fe.localMatrix(), args.
fTransformsIn, | 682 fe.inPosition()->fName, fe.localMatrix(), args.
fTransformsIn, |
683 args.fTransformsOut); | 683 args.fTransformsOut); |
684 | 684 |
685 GrGLSLFragmentBuilder* fsBuilder = args.fFragBuilder; | 685 GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder; |
686 SkAssertResult(fsBuilder->enableFeature( | 686 SkAssertResult(fsBuilder->enableFeature( |
687 GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLF
eature)); | 687 GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLF
eature)); |
688 fsBuilder->declAppendf(GR_GL_PLS_PATH_DATA_DECL); | 688 fsBuilder->declAppendf(GR_GL_PLS_PATH_DATA_DECL); |
689 fsBuilder->codeAppend("float coverage;"); | 689 fsBuilder->codeAppend("float coverage;"); |
690 fsBuilder->codeAppendf("if (%s != 0.0) {", useEvenOdd); | 690 fsBuilder->codeAppendf("if (%s != 0.0) {", useEvenOdd); |
691 fsBuilder->codeAppend("coverage = float(abs(pls.windings[0]) % 2) *
0.25;"); | 691 fsBuilder->codeAppend("coverage = float(abs(pls.windings[0]) % 2) *
0.25;"); |
692 fsBuilder->codeAppend("coverage += float(abs(pls.windings[1]) % 2) *
0.25;"); | 692 fsBuilder->codeAppend("coverage += float(abs(pls.windings[1]) % 2) *
0.25;"); |
693 fsBuilder->codeAppend("coverage += float(abs(pls.windings[2]) % 2) *
0.25;"); | 693 fsBuilder->codeAppend("coverage += float(abs(pls.windings[2]) % 2) *
0.25;"); |
694 fsBuilder->codeAppend("coverage += float(abs(pls.windings[3]) % 2) *
0.25;"); | 694 fsBuilder->codeAppend("coverage += float(abs(pls.windings[3]) % 2) *
0.25;"); |
695 fsBuilder->codeAppend("} else {"); | 695 fsBuilder->codeAppend("} else {"); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 DRAW_BATCH_TEST_DEFINE(PLSPathBatch) { | 1002 DRAW_BATCH_TEST_DEFINE(PLSPathBatch) { |
1003 PLSPathBatch::Geometry geometry; | 1003 PLSPathBatch::Geometry geometry; |
1004 geometry.fColor = GrRandomColor(random); | 1004 geometry.fColor = GrRandomColor(random); |
1005 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); | 1005 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); |
1006 geometry.fPath = GrTest::TestPathConvex(random); | 1006 geometry.fPath = GrTest::TestPathConvex(random); |
1007 | 1007 |
1008 return PLSPathBatch::Create(geometry); | 1008 return PLSPathBatch::Create(geometry); |
1009 } | 1009 } |
1010 | 1010 |
1011 #endif | 1011 #endif |
OLD | NEW |