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

Side by Side Diff: src/gpu/GrGeometryProcessor.h

Issue 822423004: Move most of the transform logic into the primitive processors (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 5 years, 11 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/GrDefaultGeoProcFactory.cpp ('k') | src/gpu/GrGeometryProcessor.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 2013 Google Inc. 2 * Copyright 2013 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 GrGeometryProcessor_DEFINED 8 #ifndef GrGeometryProcessor_DEFINED
9 #define GrGeometryProcessor_DEFINED 9 #define GrGeometryProcessor_DEFINED
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 return reinterpret_cast<T*>(fData.get()); 59 return reinterpret_cast<T*>(fData.get());
60 } 60 }
61 61
62 static const size_t kMaxSize = 32; 62 static const size_t kMaxSize = 32;
63 63
64 private: 64 private:
65 SkAlignedSStorage<kMaxSize> fData; 65 SkAlignedSStorage<kMaxSize> fData;
66 }; 66 };
67 67
68 class GrGLCaps; 68 class GrGLCaps;
69 class GrGLGeometryProcessor; 69 class GrGLPrimitiveProcessor;
70 class GrOptDrawState; 70 class GrOptDrawState;
71 71
72 struct GrInitInvariantOutput; 72 struct GrInitInvariantOutput;
73 73
74 74
75 /* 75 /*
76 * This enum is shared by GrPrimitiveProcessors and GrGLPrimitiveProcessors to c oordinate shaders 76 * This enum is shared by GrPrimitiveProcessors and GrGLPrimitiveProcessors to c oordinate shaders
77 * with vertex attributes / uniforms. 77 * with vertex attributes / uniforms.
78 */ 78 */
79 enum GrGPInput { 79 enum GrGPInput {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 * We always call canMakeEqual before makeEqual so there is no need to do an y kind of equality 115 * We always call canMakeEqual before makeEqual so there is no need to do an y kind of equality
116 * testing here 116 * testing here
117 * TODO make this pure virtual when primProcs can actually use it 117 * TODO make this pure virtual when primProcs can actually use it
118 */ 118 */
119 virtual void makeEqual(GrBatchTracker*, const GrBatchTracker&) const {} 119 virtual void makeEqual(GrBatchTracker*, const GrBatchTracker&) const {}
120 120
121 virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0; 121 virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0;
122 virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const = 0; 122 virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const = 0;
123 123
124 /** 124 /**
125 * Gets a transformKey from an array of coord transforms
126 */
127 uint32_t getTransformKey(const SkTArray<const GrCoordTransform*, true>&) con st;
128
129 /**
125 * Sets a unique key on the GrProcessorKeyBuilder that is directly associate d with this geometry 130 * Sets a unique key on the GrProcessorKeyBuilder that is directly associate d with this geometry
126 * processor's GL backend implementation. 131 * processor's GL backend implementation.
127 */ 132 */
128 virtual void getGLProcessorKey(const GrBatchTracker& bt, 133 virtual void getGLProcessorKey(const GrBatchTracker& bt,
129 const GrGLCaps& caps, 134 const GrGLCaps& caps,
130 GrProcessorKeyBuilder* b) const = 0; 135 GrProcessorKeyBuilder* b) const = 0;
131 136
132 137
133 /** Returns a new instance of the appropriate *GL* implementation class 138 /** Returns a new instance of the appropriate *GL* implementation class
134 for the given GrProcessor; caller is responsible for deleting 139 for the given GrProcessor; caller is responsible for deleting
135 the object. */ 140 the object. */
136 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co nst = 0; 141 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
142 const GrGLCaps& caps) const = 0;
137 143
138 protected: 144 protected:
139 GrPrimitiveProcessor(const SkMatrix& viewMatrix, const SkMatrix& localMatrix ) 145 GrPrimitiveProcessor(const SkMatrix& viewMatrix, const SkMatrix& localMatrix )
140 : fViewMatrix(viewMatrix) 146 : fViewMatrix(viewMatrix)
141 , fLocalMatrix(localMatrix) {} 147 , fLocalMatrix(localMatrix) {}
142 148
143 /* 149 /*
144 * CanCombineOutput will return true if two draws are 'batchable' from a col or perspective. 150 * CanCombineOutput will return true if two draws are 'batchable' from a col or perspective.
145 * TODO remove this when GPs can upgrade to attribute color 151 * TODO remove this when GPs can upgrade to attribute color
146 */ 152 */
(...skipping 17 matching lines...) Expand all
164 return false; 170 return false;
165 } 171 }
166 172
167 if (leftUsesLocalCoords && !left.localMatrix().cheapEqualTo(right.localM atrix())) { 173 if (leftUsesLocalCoords && !left.localMatrix().cheapEqualTo(right.localM atrix())) {
168 return false; 174 return false;
169 } 175 }
170 return true; 176 return true;
171 } 177 }
172 178
173 private: 179 private:
180 virtual bool hasExplicitLocalCoords() const = 0;
181
174 SkMatrix fViewMatrix; 182 SkMatrix fViewMatrix;
175 SkMatrix fLocalMatrix; 183 SkMatrix fLocalMatrix;
176 184
177 typedef GrProcessor INHERITED; 185 typedef GrProcessor INHERITED;
178 }; 186 };
179 187
180 /** 188 /**
181 * A GrGeometryProcessor is a flexible method for rendering a primitive. The Gr GeometryProcessor 189 * A GrGeometryProcessor is a flexible method for rendering a primitive. The Gr GeometryProcessor
182 * has complete control over vertex attributes and uniforms(aside from the rende r target) but it 190 * has complete control over vertex attributes and uniforms(aside from the rende r target) but it
183 * must obey the same contract as any GrPrimitiveProcessor, specifically it must emit a color and 191 * must obey the same contract as any GrPrimitiveProcessor, specifically it must emit a color and
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 262 }
255 263
256 // TODO this equality test should really be broken up, some of this can live on the batch 264 // TODO this equality test should really be broken up, some of this can live on the batch
257 // tracker test and some of this should be in bundles 265 // tracker test and some of this should be in bundles
258 if (!this->onIsEqual(other)) { 266 if (!this->onIsEqual(other)) {
259 return false; 267 return false;
260 } 268 }
261 269
262 return this->onCanMakeEqual(mine, other, theirs); 270 return this->onCanMakeEqual(mine, other, theirs);
263 } 271 }
264
265 272
266 // TODO we can remove color from the GrGeometryProcessor base class once we have bundles of 273 // TODO we can remove color from the GrGeometryProcessor base class once we have bundles of
267 // primitive data 274 // primitive data
268 GrColor color() const { return fColor; } 275 GrColor color() const { return fColor; }
269 276
270 // TODO this is a total hack until the gp can do deferred geometry 277 // TODO this is a total hack until the gp can do deferred geometry
271 bool hasVertexColor() const { return fHasVertexColor; } 278 bool hasVertexColor() const { return fHasVertexColor; }
272 279
273 // TODO this is a total hack until gp can setup and manage local coords
274 bool hasLocalCoords() const { return fHasLocalCoords; }
275
276 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE; 280 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE;
277 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID E; 281 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID E;
278 282
279 protected: 283 protected:
280 /* 284 /*
281 * An optional simple helper function to determine by what means the GrGeome tryProcessor should 285 * An optional simple helper function to determine by what means the GrGeome tryProcessor should
282 * use to provide color. If we are given an override color(ie the given ove rridecolor is NOT 286 * use to provide color. If we are given an override color(ie the given ove rridecolor is NOT
283 * GrColor_ILLEGAL) then we must always emit that color(currently overrides are only supported 287 * GrColor_ILLEGAL) then we must always emit that color(currently overrides are only supported
284 * via uniform, but with deferred Geometry we could use attributes). Otherw ise, if our color is 288 * via uniform, but with deferred Geometry we could use attributes). Otherw ise, if our color is
285 * ignored then we should not emit a color. Lastly, if we don't have vertex colors then we must 289 * ignored then we should not emit a color. Lastly, if we don't have vertex colors then we must
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 void setHasVertexColor() { fHasVertexColor = true; } 329 void setHasVertexColor() { fHasVertexColor = true; }
326 void setHasLocalCoords() { fHasLocalCoords = true; } 330 void setHasLocalCoords() { fHasLocalCoords = true; }
327 331
328 virtual void onGetInvariantOutputColor(GrInitInvariantOutput*) const {} 332 virtual void onGetInvariantOutputColor(GrInitInvariantOutput*) const {}
329 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const = 0; 333 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput*) const = 0;
330 334
331 private: 335 private:
332 virtual bool onCanMakeEqual(const GrBatchTracker& mine, 336 virtual bool onCanMakeEqual(const GrBatchTracker& mine,
333 const GrGeometryProcessor& that, 337 const GrGeometryProcessor& that,
334 const GrBatchTracker& theirs) const = 0; 338 const GrBatchTracker& theirs) const = 0;
339
335 // TODO delete this when we have more advanced equality testing via bundles and the BT 340 // TODO delete this when we have more advanced equality testing via bundles and the BT
336 virtual bool onIsEqual(const GrGeometryProcessor&) const = 0; 341 virtual bool onIsEqual(const GrGeometryProcessor&) const = 0;
337 342
343 bool hasExplicitLocalCoords() const SK_OVERRIDE { return fHasLocalCoords; }
344
338 SkSTArray<kMaxVertexAttribs, GrAttribute, true> fAttribs; 345 SkSTArray<kMaxVertexAttribs, GrAttribute, true> fAttribs;
339 size_t fVertexStride; 346 size_t fVertexStride;
340 GrColor fColor; 347 GrColor fColor;
341 bool fOpaqueVertexColors; 348 bool fOpaqueVertexColors;
342 bool fWillUseGeoShader; 349 bool fWillUseGeoShader;
343 bool fHasVertexColor; 350 bool fHasVertexColor;
344 bool fHasLocalCoords; 351 bool fHasLocalCoords;
345 352
346 typedef GrPrimitiveProcessor INHERITED; 353 typedef GrPrimitiveProcessor INHERITED;
347 }; 354 };
(...skipping 20 matching lines...) Expand all
368 375
369 GrColor color() const { return fColor; } 376 GrColor color() const { return fColor; }
370 377
371 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE; 378 void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE;
372 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID E; 379 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRID E;
373 380
374 virtual void getGLProcessorKey(const GrBatchTracker& bt, 381 virtual void getGLProcessorKey(const GrBatchTracker& bt,
375 const GrGLCaps& caps, 382 const GrGLCaps& caps,
376 GrProcessorKeyBuilder* b) const SK_OVERRIDE; 383 GrProcessorKeyBuilder* b) const SK_OVERRIDE;
377 384
378 GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_O VERRIDE; 385 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
386 const GrGLCaps& caps) const SK_OVERRIDE;
387
388 protected:
389 GrPathProcessor(GrColor color, const SkMatrix& viewMatrix, const SkMatrix& l ocalMatrix);
379 390
380 private: 391 private:
381 GrPathProcessor(GrColor color, const SkMatrix& viewMatrix, const SkMatrix& l ocalMatrix); 392 bool hasExplicitLocalCoords() const SK_OVERRIDE { return false; }
393
382 GrColor fColor; 394 GrColor fColor;
383 395
384 typedef GrPrimitiveProcessor INHERITED; 396 typedef GrPrimitiveProcessor INHERITED;
385 }; 397 };
398
386 #endif 399 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDefaultGeoProcFactory.cpp ('k') | src/gpu/GrGeometryProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698