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

Side by Side Diff: src/gpu/batches/GrPLSPathRenderer.cpp

Issue 2339203002: Stop flattening GrCoordTransforms in parent GrFragmentProcessors. (Closed)
Patch Set: Fix issue of taking ref to a temporary Created 4 years, 3 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 | « src/gpu/batches/GrMSAAPathRenderer.cpp ('k') | src/gpu/effects/GrBezierEffect.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 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 vsBuilder->codeAppendf("%s = vec2(%s.x - %s.x, %s.y - %s.y) * 0.5;", 326 vsBuilder->codeAppendf("%s = vec2(%s.x - %s.x, %s.y - %s.y) * 0.5;",
327 delta3.vsOut(), v3.vsOut(), v1.vsOut(), v1.vs Out(), v3.vsOut()); 327 delta3.vsOut(), v3.vsOut(), v1.vsOut(), v1.vs Out(), v3.vsOut());
328 328
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(),
337 args.fTransformsOut); 337 args.fFPCoordTransformHandler);
338 338
339 GrGLSLPPFragmentBuilder* 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
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 384
385 static inline void GenKey(const GrGeometryProcessor& gp, 385 static inline void GenKey(const GrGeometryProcessor& gp,
386 const GrGLSLCaps&, 386 const GrGLSLCaps&,
387 GrProcessorKeyBuilder* b) { 387 GrProcessorKeyBuilder* b) {
388 const PLSAATriangleEffect& te = gp.cast<PLSAATriangleEffect>(); 388 const PLSAATriangleEffect& te = gp.cast<PLSAATriangleEffect>();
389 uint32_t key = 0; 389 uint32_t key = 0;
390 key |= te.localMatrix().hasPerspective() ? 0x1 : 0x0; 390 key |= te.localMatrix().hasPerspective() ? 0x1 : 0x0;
391 b->add32(key); 391 b->add32(key);
392 } 392 }
393 393
394 virtual void setData(const GrGLSLProgramDataManager& pdman, 394 void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitivePro cessor& gp,
395 const GrPrimitiveProcessor& gp) override { 395 FPCoordTransformIter&& transformIter) override {
396 } 396 this->setTransformDataHelper(gp.cast<PLSAATriangleEffect>().fLocalMa trix, pdman,
397 397 &transformIter);
398 void setTransformData(const GrPrimitiveProcessor& primProc,
399 const GrGLSLProgramDataManager& pdman,
400 int index,
401 const SkTArray<const GrCoordTransform*, true>& tra nsforms) override {
402 this->setTransformDataHelper(primProc.cast<PLSAATriangleEffect>().fL ocalMatrix, pdman,
403 index, transforms);
404 } 398 }
405 399
406 private: 400 private:
407 typedef GrGLSLGeometryProcessor INHERITED; 401 typedef GrGLSLGeometryProcessor INHERITED;
408 }; 402 };
409 403
410 virtual void getGLSLProcessorKey(const GrGLSLCaps& caps, 404 virtual void getGLSLProcessorKey(const GrGLSLCaps& caps,
411 GrProcessorKeyBuilder* b) const override { 405 GrProcessorKeyBuilder* b) const override {
412 GLSLProcessor::GenKey(*this, caps, b); 406 GLSLProcessor::GenKey(*this, caps, b);
413 } 407 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 GrGLSLVertToFrag windings(kInt_GrSLType); 509 GrGLSLVertToFrag windings(kInt_GrSLType);
516 varyingHandler->addFlatVarying("windings", &windings, kLow_GrSLPreci sion); 510 varyingHandler->addFlatVarying("windings", &windings, kLow_GrSLPreci sion);
517 vsBuilder->codeAppendf("%s = %s;", 511 vsBuilder->codeAppendf("%s = %s;",
518 windings.vsOut(), qe.inWindings()->fName); 512 windings.vsOut(), qe.inWindings()->fName);
519 513
520 // Setup position 514 // Setup position
521 this->setupPosition(vsBuilder, gpArgs, qe.inPosition()->fName); 515 this->setupPosition(vsBuilder, gpArgs, qe.inPosition()->fName);
522 516
523 // emit transforms 517 // emit transforms
524 this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpAr gs->fPositionVar, 518 this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpAr gs->fPositionVar,
525 qe.inPosition()->fName, qe.localMatrix(), args. fTransformsIn, 519 qe.inPosition()->fName, qe.localMatrix(),
526 args.fTransformsOut); 520 args.fFPCoordTransformHandler);
527 521
528 GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder; 522 GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
529 SkAssertResult(fsBuilder->enableFeature( 523 SkAssertResult(fsBuilder->enableFeature(
530 GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLF eature)); 524 GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLF eature));
531 SkAssertResult(fsBuilder->enableFeature( 525 SkAssertResult(fsBuilder->enableFeature(
532 GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeatur e)); 526 GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeatur e));
533 static const int QUAD_ARGS = 2; 527 static const int QUAD_ARGS = 2;
534 GrGLSLShaderVar inQuadArgs[QUAD_ARGS] = { 528 GrGLSLShaderVar inQuadArgs[QUAD_ARGS] = {
535 GrGLSLShaderVar("dot", kFloat_GrSLType, 0, kHigh_GrSLPrecision), 529 GrGLSLShaderVar("dot", kFloat_GrSLType, 0, kHigh_GrSLPrecision),
536 GrGLSLShaderVar("uv", kVec2f_GrSLType, 0, kHigh_GrSLPrecision) 530 GrGLSLShaderVar("uv", kVec2f_GrSLType, 0, kHigh_GrSLPrecision)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 568
575 static inline void GenKey(const GrGeometryProcessor& gp, 569 static inline void GenKey(const GrGeometryProcessor& gp,
576 const GrGLSLCaps&, 570 const GrGLSLCaps&,
577 GrProcessorKeyBuilder* b) { 571 GrProcessorKeyBuilder* b) {
578 const PLSQuadEdgeEffect& qee = gp.cast<PLSQuadEdgeEffect>(); 572 const PLSQuadEdgeEffect& qee = gp.cast<PLSQuadEdgeEffect>();
579 uint32_t key = 0; 573 uint32_t key = 0;
580 key |= qee.usesLocalCoords() && qee.localMatrix().hasPerspective() ? 0x1 : 0x0; 574 key |= qee.usesLocalCoords() && qee.localMatrix().hasPerspective() ? 0x1 : 0x0;
581 b->add32(key); 575 b->add32(key);
582 } 576 }
583 577
584 virtual void setData(const GrGLSLProgramDataManager& pdman, 578 void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitivePro cessor& gp,
585 const GrPrimitiveProcessor& gp) override { 579 FPCoordTransformIter&& transformIter) override {
586 } 580 this->setTransformDataHelper(gp.cast<PLSQuadEdgeEffect>().fLocalMatr ix, pdman,
587 581 &transformIter);
588 void setTransformData(const GrPrimitiveProcessor& primProc,
589 const GrGLSLProgramDataManager& pdman,
590 int index,
591 const SkTArray<const GrCoordTransform*, true>& tra nsforms) override {
592 this->setTransformDataHelper(primProc.cast<PLSQuadEdgeEffect>().fLoc alMatrix, pdman,
593 index, transforms);
594 } 582 }
595 583
596 private: 584 private:
597 typedef GrGLSLGeometryProcessor INHERITED; 585 typedef GrGLSLGeometryProcessor INHERITED;
598 }; 586 };
599 587
600 virtual void getGLSLProcessorKey(const GrGLSLCaps& caps, 588 virtual void getGLSLProcessorKey(const GrGLSLCaps& caps,
601 GrProcessorKeyBuilder* b) const override { 589 GrProcessorKeyBuilder* b) const override {
602 GLSLProcessor::GenKey(*this, caps, b); 590 GLSLProcessor::GenKey(*this, caps, b);
603 } 591 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler; 661 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
674 662
675 fUseEvenOdd = uniformHandler->addUniform(kFragment_GrShaderFlag, 663 fUseEvenOdd = uniformHandler->addUniform(kFragment_GrShaderFlag,
676 kFloat_GrSLType, kLow_GrSLPr ecision, 664 kFloat_GrSLType, kLow_GrSLPr ecision,
677 "useEvenOdd"); 665 "useEvenOdd");
678 const char* useEvenOdd = uniformHandler->getUniformCStr(fUseEvenOdd) ; 666 const char* useEvenOdd = uniformHandler->getUniformCStr(fUseEvenOdd) ;
679 667
680 varyingHandler->emitAttributes(fe); 668 varyingHandler->emitAttributes(fe);
681 this->setupPosition(vsBuilder, gpArgs, fe.inPosition()->fName); 669 this->setupPosition(vsBuilder, gpArgs, fe.inPosition()->fName);
682 this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpAr gs->fPositionVar, 670 this->emitTransforms(vsBuilder, varyingHandler, uniformHandler, gpAr gs->fPositionVar,
683 fe.inPosition()->fName, fe.localMatrix(), args. fTransformsIn, 671 fe.inPosition()->fName, fe.localMatrix(),
684 args.fTransformsOut); 672 args.fFPCoordTransformHandler);
685 673
686 GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder; 674 GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder;
687 SkAssertResult(fsBuilder->enableFeature( 675 SkAssertResult(fsBuilder->enableFeature(
688 GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLF eature)); 676 GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLF eature));
689 fsBuilder->declAppendf(GR_GL_PLS_PATH_DATA_DECL); 677 fsBuilder->declAppendf(GR_GL_PLS_PATH_DATA_DECL);
690 fsBuilder->codeAppend("float coverage;"); 678 fsBuilder->codeAppend("float coverage;");
691 fsBuilder->codeAppendf("if (%s != 0.0) {", useEvenOdd); 679 fsBuilder->codeAppendf("if (%s != 0.0) {", useEvenOdd);
692 fsBuilder->codeAppend("coverage = float(abs(pls.windings[0]) % 2) * 0.25;"); 680 fsBuilder->codeAppend("coverage = float(abs(pls.windings[0]) % 2) * 0.25;");
693 fsBuilder->codeAppend("coverage += float(abs(pls.windings[1]) % 2) * 0.25;"); 681 fsBuilder->codeAppend("coverage += float(abs(pls.windings[1]) % 2) * 0.25;");
694 fsBuilder->codeAppend("coverage += float(abs(pls.windings[2]) % 2) * 0.25;"); 682 fsBuilder->codeAppend("coverage += float(abs(pls.windings[2]) % 2) * 0.25;");
(...skipping 14 matching lines...) Expand all
709 697
710 static inline void GenKey(const GrGeometryProcessor& gp, 698 static inline void GenKey(const GrGeometryProcessor& gp,
711 const GrGLSLCaps&, 699 const GrGLSLCaps&,
712 GrProcessorKeyBuilder* b) { 700 GrProcessorKeyBuilder* b) {
713 const PLSFinishEffect& fe = gp.cast<PLSFinishEffect>(); 701 const PLSFinishEffect& fe = gp.cast<PLSFinishEffect>();
714 uint32_t key = 0; 702 uint32_t key = 0;
715 key |= fe.usesLocalCoords() && fe.localMatrix().hasPerspective() ? 0 x1 : 0x0; 703 key |= fe.usesLocalCoords() && fe.localMatrix().hasPerspective() ? 0 x1 : 0x0;
716 b->add32(key); 704 b->add32(key);
717 } 705 }
718 706
719 virtual void setData(const GrGLSLProgramDataManager& pdman, 707 void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitivePro cessor& gp,
720 const GrPrimitiveProcessor& gp) override { 708 FPCoordTransformIter&& transformIter) override {
721 const PLSFinishEffect& fe = gp.cast<PLSFinishEffect>(); 709 const PLSFinishEffect& fe = gp.cast<PLSFinishEffect>();
722 pdman.set1f(fUseEvenOdd, fe.fUseEvenOdd); 710 pdman.set1f(fUseEvenOdd, fe.fUseEvenOdd);
723 if (fe.color() != fColor && !fe.colorIgnored()) { 711 if (fe.color() != fColor && !fe.colorIgnored()) {
724 GrGLfloat c[4]; 712 GrGLfloat c[4];
725 GrColorToRGBAFloat(fe.color(), c); 713 GrColorToRGBAFloat(fe.color(), c);
726 pdman.set4fv(fColorUniform, 1, c); 714 pdman.set4fv(fColorUniform, 1, c);
727 fColor = fe.color(); 715 fColor = fe.color();
728 } 716 }
729 } 717 this->setTransformDataHelper(fe.fLocalMatrix, pdman, &transformIter) ;
730
731 void setTransformData(const GrPrimitiveProcessor& primProc,
732 const GrGLSLProgramDataManager& pdman,
733 int index,
734 const SkTArray<const GrCoordTransform*, true>& tra nsforms) override {
735 this->setTransformDataHelper(primProc.cast<PLSFinishEffect>().fLocal Matrix, pdman,
736 index, transforms);
737 } 718 }
738 719
739 private: 720 private:
740 GrColor fColor; 721 GrColor fColor;
741 UniformHandle fColorUniform; 722 UniformHandle fColorUniform;
742 UniformHandle fUseEvenOdd; 723 UniformHandle fUseEvenOdd;
743 724
744 typedef GrGLSLGeometryProcessor INHERITED; 725 typedef GrGLSLGeometryProcessor INHERITED;
745 }; 726 };
746 727
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 950
970 DRAW_BATCH_TEST_DEFINE(PLSPathBatch) { 951 DRAW_BATCH_TEST_DEFINE(PLSPathBatch) {
971 GrColor color = GrRandomColor(random); 952 GrColor color = GrRandomColor(random);
972 SkMatrix vm = GrTest::TestMatrixInvertible(random); 953 SkMatrix vm = GrTest::TestMatrixInvertible(random);
973 SkPath path = GrTest::TestPathConvex(random); 954 SkPath path = GrTest::TestPathConvex(random);
974 955
975 return new PLSPathBatch(color, path, vm); 956 return new PLSPathBatch(color, path, vm);
976 } 957 }
977 958
978 #endif 959 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrMSAAPathRenderer.cpp ('k') | src/gpu/effects/GrBezierEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698