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

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

Issue 1332923003: Remove batchtracker (Closed) Base URL: https://skia.googlesource.com/skia.git@latecreatepathprocessor
Patch Set: tweaks Created 5 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrAAConvexPathRenderer.h" 9 #include "GrAAConvexPathRenderer.h"
10 10
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 536
537 const Attribute* inPosition() const { return fInPosition; } 537 const Attribute* inPosition() const { return fInPosition; }
538 const Attribute* inQuadEdge() const { return fInQuadEdge; } 538 const Attribute* inQuadEdge() const { return fInQuadEdge; }
539 GrColor color() const { return fColor; } 539 GrColor color() const { return fColor; }
540 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } 540 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
541 const SkMatrix& localMatrix() const { return fLocalMatrix; } 541 const SkMatrix& localMatrix() const { return fLocalMatrix; }
542 bool usesLocalCoords() const { return fUsesLocalCoords; } 542 bool usesLocalCoords() const { return fUsesLocalCoords; }
543 543
544 class GLProcessor : public GrGLGeometryProcessor { 544 class GLProcessor : public GrGLGeometryProcessor {
545 public: 545 public:
546 GLProcessor(const GrGeometryProcessor&, 546 GLProcessor()
547 const GrBatchTracker&)
548 : fColor(GrColor_ILLEGAL) {} 547 : fColor(GrColor_ILLEGAL) {}
549 548
550 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override { 549 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
551 const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>(); 550 const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>();
552 GrGLGPBuilder* pb = args.fPB; 551 GrGLGPBuilder* pb = args.fPB;
553 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); 552 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
554 553
555 // emit attributes 554 // emit attributes
556 vsBuilder->emitAttributes(qe); 555 vsBuilder->emitAttributes(qe);
557 556
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 v.fsIn(), v.fsIn()); 589 v.fsIn(), v.fsIn());
591 fsBuilder->codeAppendf("edgeAlpha = (%s.x*%s.x - %s.y);", v.fsIn(), v.fsIn(), 590 fsBuilder->codeAppendf("edgeAlpha = (%s.x*%s.x - %s.y);", v.fsIn(), v.fsIn(),
592 v.fsIn()); 591 v.fsIn());
593 fsBuilder->codeAppendf("edgeAlpha = " 592 fsBuilder->codeAppendf("edgeAlpha = "
594 "clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0 );}"); 593 "clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0 );}");
595 594
596 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage ); 595 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage );
597 } 596 }
598 597
599 static inline void GenKey(const GrGeometryProcessor& gp, 598 static inline void GenKey(const GrGeometryProcessor& gp,
600 const GrBatchTracker& bt,
601 const GrGLSLCaps&, 599 const GrGLSLCaps&,
602 GrProcessorKeyBuilder* b) { 600 GrProcessorKeyBuilder* b) {
603 const QuadEdgeEffect& qee = gp.cast<QuadEdgeEffect>(); 601 const QuadEdgeEffect& qee = gp.cast<QuadEdgeEffect>();
604 uint32_t key = 0; 602 uint32_t key = 0;
605 key |= qee.usesLocalCoords() && qee.localMatrix().hasPerspective() ? 0x1 : 0x0; 603 key |= qee.usesLocalCoords() && qee.localMatrix().hasPerspective() ? 0x1 : 0x0;
606 key |= qee.colorIgnored() ? 0x2 : 0x0; 604 key |= qee.colorIgnored() ? 0x2 : 0x0;
607 b->add32(key); 605 b->add32(key);
608 } 606 }
609 607
610 virtual void setData(const GrGLProgramDataManager& pdman, 608 virtual void setData(const GrGLProgramDataManager& pdman,
bsalomon 2015/09/10 18:55:30 -virtual?
joshualitt 2015/09/10 20:08:05 Acknowledged.
611 const GrPrimitiveProcessor& gp, 609 const GrPrimitiveProcessor& gp) override {
612 const GrBatchTracker& bt) override {
613 const QuadEdgeEffect& qe = gp.cast<QuadEdgeEffect>(); 610 const QuadEdgeEffect& qe = gp.cast<QuadEdgeEffect>();
614 if (qe.color() != fColor) { 611 if (qe.color() != fColor) {
615 GrGLfloat c[4]; 612 GrGLfloat c[4];
616 GrColorToRGBAFloat(qe.color(), c); 613 GrColorToRGBAFloat(qe.color(), c);
617 pdman.set4fv(fColorUniform, 1, c); 614 pdman.set4fv(fColorUniform, 1, c);
618 fColor = qe.color(); 615 fColor = qe.color();
619 } 616 }
620 } 617 }
621 618
622 void setTransformData(const GrPrimitiveProcessor& primProc, 619 void setTransformData(const GrPrimitiveProcessor& primProc,
623 const GrGLProgramDataManager& pdman, 620 const GrGLProgramDataManager& pdman,
624 int index, 621 int index,
625 const SkTArray<const GrCoordTransform*, true>& tra nsforms) override { 622 const SkTArray<const GrCoordTransform*, true>& tra nsforms) override {
626 this->setTransformDataHelper<QuadEdgeEffect>(primProc, pdman, index, transforms); 623 this->setTransformDataHelper<QuadEdgeEffect>(primProc, pdman, index, transforms);
627 } 624 }
628 625
629 private: 626 private:
630 GrColor fColor; 627 GrColor fColor;
631 UniformHandle fColorUniform; 628 UniformHandle fColorUniform;
632 629
633 typedef GrGLGeometryProcessor INHERITED; 630 typedef GrGLGeometryProcessor INHERITED;
634 }; 631 };
635 632
636 virtual void getGLProcessorKey(const GrBatchTracker& bt, 633 virtual void getGLProcessorKey(const GrGLSLCaps& caps,
bsalomon 2015/09/10 18:55:30 -virtual?
joshualitt 2015/09/10 20:08:05 Acknowledged.
637 const GrGLSLCaps& caps,
638 GrProcessorKeyBuilder* b) const override { 634 GrProcessorKeyBuilder* b) const override {
639 GLProcessor::GenKey(*this, bt, caps, b); 635 GLProcessor::GenKey(*this, caps, b);
640 } 636 }
641 637
642 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, 638 virtual GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps&) const ov erride {
bsalomon 2015/09/10 18:55:30 -virtual?
joshualitt 2015/09/10 20:08:05 Acknowledged.
643 const GrGLSLCaps&) const ov erride { 639 return new GLProcessor();
644 return new GLProcessor(*this, bt);
645 } 640 }
646 641
647 private: 642 private:
648 QuadEdgeEffect(GrColor color, const SkMatrix& localMatrix, bool usesLocalCoo rds) 643 QuadEdgeEffect(GrColor color, const SkMatrix& localMatrix, bool usesLocalCoo rds)
649 : fColor(color) 644 : fColor(color)
650 , fLocalMatrix(localMatrix) 645 , fLocalMatrix(localMatrix)
651 , fUsesLocalCoords(usesLocalCoords) { 646 , fUsesLocalCoords(usesLocalCoords) {
652 this->initClassID<QuadEdgeEffect>(); 647 this->initClassID<QuadEdgeEffect>();
653 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType)); 648 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType));
654 fInQuadEdge = &this->addVertexAttrib(Attribute("inQuadEdge", kVec4f_GrVe rtexAttribType)); 649 fInQuadEdge = &this->addVertexAttrib(Attribute("inQuadEdge", kVec4f_GrVe rtexAttribType));
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { 1007 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) {
1013 AAConvexPathBatch::Geometry geometry; 1008 AAConvexPathBatch::Geometry geometry;
1014 geometry.fColor = GrRandomColor(random); 1009 geometry.fColor = GrRandomColor(random);
1015 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); 1010 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
1016 geometry.fPath = GrTest::TestPathConvex(random); 1011 geometry.fPath = GrTest::TestPathConvex(random);
1017 1012
1018 return AAConvexPathBatch::Create(geometry); 1013 return AAConvexPathBatch::Create(geometry);
1019 } 1014 }
1020 1015
1021 #endif 1016 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698