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

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

Issue 1121463002: Move bounds to GrBatch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweak Created 5 years, 7 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/GrAADistanceFieldPathRenderer.cpp ('k') | src/gpu/GrAARectRenderer.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 2011 Google Inc. 2 * Copyright 2011 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 "GrAAHairLinePathRenderer.h" 8 #include "GrAAHairLinePathRenderer.h"
9 9
10 #include "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 return true; 692 return true;
693 } 693 }
694 694
695 class AAHairlineBatch : public GrBatch { 695 class AAHairlineBatch : public GrBatch {
696 public: 696 public:
697 struct Geometry { 697 struct Geometry {
698 GrColor fColor; 698 GrColor fColor;
699 uint8_t fCoverage; 699 uint8_t fCoverage;
700 SkMatrix fViewMatrix; 700 SkMatrix fViewMatrix;
701 SkPath fPath; 701 SkPath fPath;
702 SkDEBUGCODE(SkRect fDevBounds;)
703 SkIRect fDevClipBounds; 702 SkIRect fDevClipBounds;
704 }; 703 };
705 704
706 // TODO Batch itself should not hold on to index buffers. Instead, these sh ould live in the 705 // TODO Batch itself should not hold on to index buffers. Instead, these sh ould live in the
707 // cache. 706 // cache.
708 static GrBatch* Create(const Geometry& geometry, const GrIndexBuffer* linesI ndexBuffer, 707 static GrBatch* Create(const Geometry& geometry, const GrIndexBuffer* linesI ndexBuffer,
709 const GrIndexBuffer* quadsIndexBuffer) { 708 const GrIndexBuffer* quadsIndexBuffer) {
710 return SkNEW_ARGS(AAHairlineBatch, (geometry, linesIndexBuffer, quadsInd exBuffer)); 709 return SkNEW_ARGS(AAHairlineBatch, (geometry, linesIndexBuffer, quadsInd exBuffer));
711 } 710 }
712 711
(...skipping 14 matching lines...) Expand all
727 } else if (GrColor_ILLEGAL != init.fOverrideColor) { 726 } else if (GrColor_ILLEGAL != init.fOverrideColor) {
728 fGeoData[0].fColor = init.fOverrideColor; 727 fGeoData[0].fColor = init.fOverrideColor;
729 } 728 }
730 729
731 // setup batch properties 730 // setup batch properties
732 fBatch.fColorIgnored = init.fColorIgnored; 731 fBatch.fColorIgnored = init.fColorIgnored;
733 fBatch.fColor = fGeoData[0].fColor; 732 fBatch.fColor = fGeoData[0].fColor;
734 fBatch.fUsesLocalCoords = init.fUsesLocalCoords; 733 fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
735 fBatch.fCoverageIgnored = init.fCoverageIgnored; 734 fBatch.fCoverageIgnored = init.fCoverageIgnored;
736 fBatch.fCoverage = fGeoData[0].fCoverage; 735 fBatch.fCoverage = fGeoData[0].fCoverage;
737 SkDEBUGCODE(fBatch.fDevBounds = fGeoData[0].fDevBounds;)
738 } 736 }
739 737
740 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) override; 738 void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline ) override;
741 739
742 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 740 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
743 741
744 private: 742 private:
745 typedef SkTArray<SkPoint, true> PtArray; 743 typedef SkTArray<SkPoint, true> PtArray;
746 typedef SkTArray<int, true> IntArray; 744 typedef SkTArray<int, true> IntArray;
747 typedef SkTArray<float, true> FloatArray; 745 typedef SkTArray<float, true> FloatArray;
748 746
749 AAHairlineBatch(const Geometry& geometry, const GrIndexBuffer* linesIndexBuf fer, 747 AAHairlineBatch(const Geometry& geometry, const GrIndexBuffer* linesIndexBuf fer,
750 const GrIndexBuffer* quadsIndexBuffer) 748 const GrIndexBuffer* quadsIndexBuffer)
751 : fLinesIndexBuffer(linesIndexBuffer) 749 : fLinesIndexBuffer(linesIndexBuffer)
752 , fQuadsIndexBuffer(quadsIndexBuffer) { 750 , fQuadsIndexBuffer(quadsIndexBuffer) {
753 SkASSERT(linesIndexBuffer && quadsIndexBuffer); 751 SkASSERT(linesIndexBuffer && quadsIndexBuffer);
754 this->initClassID<AAHairlineBatch>(); 752 this->initClassID<AAHairlineBatch>();
755 fGeoData.push_back(geometry); 753 fGeoData.push_back(geometry);
754
755 // compute bounds
756 fBounds = geometry.fPath.getBounds();
757 geometry.fViewMatrix.mapRect(&fBounds);
756 } 758 }
757 759
758 bool onCombineIfPossible(GrBatch* t) override { 760 bool onCombineIfPossible(GrBatch* t) override {
759 AAHairlineBatch* that = t->cast<AAHairlineBatch>(); 761 AAHairlineBatch* that = t->cast<AAHairlineBatch>();
760 762
761 if (this->viewMatrix().hasPerspective() != that->viewMatrix().hasPerspec tive()) { 763 if (this->viewMatrix().hasPerspective() != that->viewMatrix().hasPerspec tive()) {
762 return false; 764 return false;
763 } 765 }
764 766
765 // We go to identity if we don't have perspective 767 // We go to identity if we don't have perspective
(...skipping 12 matching lines...) Expand all
778 if (this->color() != that->color()) { 780 if (this->color() != that->color()) {
779 return false; 781 return false;
780 } 782 }
781 783
782 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); 784 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords());
783 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi ewMatrix())) { 785 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi ewMatrix())) {
784 return false; 786 return false;
785 } 787 }
786 788
787 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin()) ; 789 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin()) ;
790 this->joinBounds(that->bounds());
788 return true; 791 return true;
789 } 792 }
790 793
791 GrColor color() const { return fBatch.fColor; } 794 GrColor color() const { return fBatch.fColor; }
792 uint8_t coverage() const { return fBatch.fCoverage; } 795 uint8_t coverage() const { return fBatch.fCoverage; }
793 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } 796 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
794 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } 797 const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
795 798
796 struct BatchTracker { 799 struct BatchTracker {
797 GrColor fColor; 800 GrColor fColor;
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 SkScalar hairlineCoverage; 1043 SkScalar hairlineCoverage;
1041 uint8_t newCoverage = 0xff; 1044 uint8_t newCoverage = 0xff;
1042 if (IsStrokeHairlineOrEquivalent(stroke, viewMatrix, &hairlineCoverage)) { 1045 if (IsStrokeHairlineOrEquivalent(stroke, viewMatrix, &hairlineCoverage)) {
1043 newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff); 1046 newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff);
1044 } 1047 }
1045 1048
1046 SkIRect devClipBounds; 1049 SkIRect devClipBounds;
1047 pipelineBuilder->clip().getConservativeBounds(pipelineBuilder->getRenderTarg et(), 1050 pipelineBuilder->clip().getConservativeBounds(pipelineBuilder->getRenderTarg et(),
1048 &devClipBounds); 1051 &devClipBounds);
1049 1052
1050 // This outset was determined experimentally by running skps and gms. It pr obably could be a
1051 // bit tighter
1052 SkRect devRect = path.getBounds();
1053 viewMatrix.mapRect(&devRect);
1054 devRect.outset(2, 2);
1055
1056 AAHairlineBatch::Geometry geometry; 1053 AAHairlineBatch::Geometry geometry;
1057 geometry.fColor = color; 1054 geometry.fColor = color;
1058 geometry.fCoverage = newCoverage; 1055 geometry.fCoverage = newCoverage;
1059 geometry.fViewMatrix = viewMatrix; 1056 geometry.fViewMatrix = viewMatrix;
1060 geometry.fPath = path; 1057 geometry.fPath = path;
1061 SkDEBUGCODE(geometry.fDevBounds = devRect;)
1062 geometry.fDevClipBounds = devClipBounds; 1058 geometry.fDevClipBounds = devClipBounds;
1063 1059
1064 SkAutoTUnref<GrBatch> batch(AAHairlineBatch::Create(geometry, fLinesIndexBuf fer, 1060 SkAutoTUnref<GrBatch> batch(AAHairlineBatch::Create(geometry, fLinesIndexBuf fer,
1065 fQuadsIndexBuffer)); 1061 fQuadsIndexBuffer));
1066 target->drawBatch(pipelineBuilder, batch, &devRect); 1062 target->drawBatch(pipelineBuilder, batch);
1067 1063
1068 return true; 1064 return true;
1069 } 1065 }
OLDNEW
« no previous file with comments | « src/gpu/GrAADistanceFieldPathRenderer.cpp ('k') | src/gpu/GrAARectRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698