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

Side by Side Diff: src/gpu/batches/GrDrawPathBatch.h

Issue 1966763002: Eliminate special case nvpr batch handling (Closed) Base URL: https://skia.googlesource.com/skia.git@reallyupload_userstencil
Patch Set: fixes Created 4 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/GrStencilSettings.cpp ('k') | src/gpu/batches/GrDrawPathBatch.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 #ifndef GrDrawPathBatch_DEFINED 8 #ifndef GrDrawPathBatch_DEFINED
9 #define GrDrawPathBatch_DEFINED 9 #define GrDrawPathBatch_DEFINED
10 10
11 #include "GrBatchFlushState.h" 11 #include "GrBatchFlushState.h"
12 #include "GrDrawBatch.h" 12 #include "GrDrawBatch.h"
13 #include "GrGpu.h" 13 #include "GrGpu.h"
14 #include "GrPath.h" 14 #include "GrPath.h"
15 #include "GrPathRendering.h" 15 #include "GrPathRendering.h"
16 #include "GrPathProcessor.h" 16 #include "GrPathProcessor.h"
17 17
18 #include "SkTLList.h" 18 #include "SkTLList.h"
19 19
20 class GrDrawPathBatchBase : public GrDrawBatch { 20 class GrDrawPathBatchBase : public GrDrawBatch {
21 public: 21 public:
22 void computePipelineOptimizations(GrInitInvariantOutput* color, 22 void computePipelineOptimizations(GrInitInvariantOutput* color,
23 GrInitInvariantOutput* coverage, 23 GrInitInvariantOutput* coverage,
24 GrBatchToXPOverrides* overrides) const ove rride { 24 GrBatchToXPOverrides* overrides) const ove rride {
25 color->setKnownFourComponents(fColor); 25 color->setKnownFourComponents(fColor);
26 coverage->setKnownSingleComponent(0xff); 26 coverage->setKnownSingleComponent(0xff);
27 } 27 }
28 28
29 GrPathRendering::FillType fillType() const { return fFillType; }
30
31 void setStencilSettings(const GrUserStencilSettings& stencil, bool hasStenci lClip,
32 int numStencilBits) {
33 fStencilSettings.reset(stencil, hasStencilClip, numStencilBits);
34 }
35
36 protected: 29 protected:
37 GrDrawPathBatchBase(uint32_t classID, const SkMatrix& viewMatrix, GrColor in itialColor, 30 GrDrawPathBatchBase(uint32_t classID, const SkMatrix& viewMatrix, GrColor in itialColor,
38 GrPathRendering::FillType fill) 31 GrPathRendering::FillType fill)
39 : INHERITED(classID) 32 : INHERITED(classID)
40 , fViewMatrix(viewMatrix) 33 , fViewMatrix(viewMatrix)
41 , fColor(initialColor) 34 , fColor(initialColor)
42 , fFillType(fill) {} 35 , fFillType(fill) {}
43 36
44 const GrStencilSettings& stencilSettings() const { return fStencilSettings; } 37 const GrStencilSettings& stencilPassSettings() const {
38 SkASSERT(!fStencilPassSettings.isDisabled()); // This shouldn't be calle d before onPrepare.
39 return fStencilPassSettings;
40 }
45 const GrXPOverridesForBatch& overrides() const { return fOverrides; } 41 const GrXPOverridesForBatch& overrides() const { return fOverrides; }
46 const SkMatrix& viewMatrix() const { return fViewMatrix; } 42 const SkMatrix& viewMatrix() const { return fViewMatrix; }
47 GrColor color() const { return fColor; } 43 GrColor color() const { return fColor; }
44 GrPathRendering::FillType fillType() const { return fFillType; }
48 45
49 private: 46 private:
50 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { 47 void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
51 overrides.getOverrideColorIfSet(&fColor); 48 overrides.getOverrideColorIfSet(&fColor);
52 fOverrides = overrides; 49 fOverrides = overrides;
53 } 50 }
54 51
52 void onPrepare(GrBatchFlushState*) override; // Initializes fStencilPassSett ings.
53
55 SkMatrix fViewMatrix; 54 SkMatrix fViewMatrix;
56 GrColor fColor; 55 GrColor fColor;
57 GrPathRendering::FillType fFillType; 56 GrPathRendering::FillType fFillType;
58 GrStencilSettings fStencilSettings; 57 GrStencilSettings fStencilPassSettings ;
59 GrXPOverridesForBatch fOverrides; 58 GrXPOverridesForBatch fOverrides;
60 59
61 typedef GrDrawBatch INHERITED; 60 typedef GrDrawBatch INHERITED;
62 }; 61 };
63 62
64 class GrDrawPathBatch final : public GrDrawPathBatchBase { 63 class GrDrawPathBatch final : public GrDrawPathBatchBase {
65 public: 64 public:
66 DEFINE_BATCH_CLASS_ID 65 DEFINE_BATCH_CLASS_ID
67 66
68 // This can't return a more abstract type because we install the stencil set tings late :( 67 static GrDrawBatch* Create(const SkMatrix& viewMatrix, GrColor color,
69 static GrDrawPathBatchBase* Create(const SkMatrix& viewMatrix, GrColor color , 68 GrPathRendering::FillType fill, const GrPath* pat h) {
70 GrPathRendering::FillType fill, const GrP ath* path) {
71 return new GrDrawPathBatch(viewMatrix, color, fill, path); 69 return new GrDrawPathBatch(viewMatrix, color, fill, path);
72 } 70 }
73 71
74 const char* name() const override { return "DrawPath"; } 72 const char* name() const override { return "DrawPath"; }
75 73
76 SkString dumpInfo() const override; 74 SkString dumpInfo() const override;
77 75
78 private: 76 private:
79 GrDrawPathBatch(const SkMatrix& viewMatrix, GrColor color, GrPathRendering:: FillType fill, 77 GrDrawPathBatch(const SkMatrix& viewMatrix, GrColor color, GrPathRendering:: FillType fill,
80 const GrPath* path) 78 const GrPath* path)
81 : INHERITED(ClassID(), viewMatrix, color, fill) 79 : INHERITED(ClassID(), viewMatrix, color, fill)
82 , fPath(path) { 80 , fPath(path) {
83 fBounds = path->getBounds(); 81 fBounds = path->getBounds();
84 viewMatrix.mapRect(&fBounds); 82 viewMatrix.mapRect(&fBounds);
85 } 83 }
86 84
87 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f alse; } 85 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f alse; }
88 86
89 void onPrepare(GrBatchFlushState*) override {}
90
91 void onDraw(GrBatchFlushState* state) override; 87 void onDraw(GrBatchFlushState* state) override;
92 88
93 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; 89 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
94 90
95 typedef GrDrawPathBatchBase INHERITED; 91 typedef GrDrawPathBatchBase INHERITED;
96 }; 92 };
97 93
98 // Template this if we decide to support index types other than 16bit 94 // Template this if we decide to support index types other than 16bit
99 class GrDrawPathRangeBatch final : public GrDrawPathBatchBase { 95 class GrDrawPathRangeBatch final : public GrDrawPathBatchBase {
100 public: 96 public:
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 ~InstanceData() {} 150 ~InstanceData() {}
155 151
156 uint16_t* fIndices; 152 uint16_t* fIndices;
157 float* fTransformValues; 153 float* fTransformValues;
158 TransformType fTransformType; 154 TransformType fTransformType;
159 int fInstanceCount; 155 int fInstanceCount;
160 mutable int fRefCnt; 156 mutable int fRefCnt;
161 SkDEBUGCODE(int fReserveCnt;) 157 SkDEBUGCODE(int fReserveCnt;)
162 }; 158 };
163 159
164 // This can't return a more abstract type because we install the stencil set tings late :( 160 static GrDrawBatch* Create(const SkMatrix& viewMatrix, SkScalar scale, SkSca lar x, SkScalar y,
165 static GrDrawPathBatchBase* Create(const SkMatrix& viewMatrix, SkScalar scal e, SkScalar x, 161 GrColor color, GrPathRendering::FillType fill, Gr PathRange* range,
166 SkScalar y, GrColor color, GrPathRenderin g::FillType fill, 162 const InstanceData* instanceData, const SkRect& b ounds) {
167 GrPathRange* range, const InstanceData* i nstanceData,
168 const SkRect& bounds) {
169 return new GrDrawPathRangeBatch(viewMatrix, scale, x, y, color, fill, ra nge, instanceData, 163 return new GrDrawPathRangeBatch(viewMatrix, scale, x, y, color, fill, ra nge, instanceData,
170 bounds); 164 bounds);
171 } 165 }
172 166
173 const char* name() const override { return "DrawPathRange"; } 167 const char* name() const override { return "DrawPathRange"; }
174 168
175 SkString dumpInfo() const override; 169 SkString dumpInfo() const override;
176 170
177 private: 171 private:
178 GrDrawPathRangeBatch(const SkMatrix& viewMatrix, SkScalar scale, SkScalar x, SkScalar y, 172 GrDrawPathRangeBatch(const SkMatrix& viewMatrix, SkScalar scale, SkScalar x, SkScalar y,
179 GrColor color, GrPathRendering::FillType fill, GrPathRa nge* range, 173 GrColor color, GrPathRendering::FillType fill, GrPathRa nge* range,
180 const InstanceData* instanceData, const SkRect& bounds) ; 174 const InstanceData* instanceData, const SkRect& bounds) ;
181 175
182 TransformType transformType() const { return fDraws.head()->fInstanceData->t ransformType(); } 176 TransformType transformType() const { return fDraws.head()->fInstanceData->t ransformType(); }
183 177
184 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override; 178 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override;
185 179
186 void onPrepare(GrBatchFlushState*) override {}
187
188 void onDraw(GrBatchFlushState* state) override; 180 void onDraw(GrBatchFlushState* state) override;
189 181
190 struct Draw { 182 struct Draw {
191 void set(const InstanceData* instanceData, SkScalar x, SkScalar y) { 183 void set(const InstanceData* instanceData, SkScalar x, SkScalar y) {
192 fInstanceData.reset(SkRef(instanceData)); 184 fInstanceData.reset(SkRef(instanceData));
193 fX = x; 185 fX = x;
194 fY = y; 186 fY = y;
195 } 187 }
196 188
197 SkAutoTUnref<const InstanceData> fInstanceData; 189 SkAutoTUnref<const InstanceData> fInstanceData;
198 SkScalar fX, fY; 190 SkScalar fX, fY;
199 }; 191 };
200 192
201 typedef GrPendingIOResource<const GrPathRange, kRead_GrIOType> PendingPathRa nge; 193 typedef GrPendingIOResource<const GrPathRange, kRead_GrIOType> PendingPathRa nge;
202 typedef SkTLList<Draw, 4> DrawList; 194 typedef SkTLList<Draw, 4> DrawList;
203 195
204 PendingPathRange fPathRange; 196 PendingPathRange fPathRange;
205 DrawList fDraws; 197 DrawList fDraws;
206 int fTotalPathCount; 198 int fTotalPathCount;
207 SkScalar fScale; 199 SkScalar fScale;
208 200
209 typedef GrDrawPathBatchBase INHERITED; 201 typedef GrDrawPathBatchBase INHERITED;
210 }; 202 };
211 203
212 #endif 204 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrStencilSettings.cpp ('k') | src/gpu/batches/GrDrawPathBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698