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

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

Issue 678953002: Default geometry processor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix dm bug Created 6 years, 1 month 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 * 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
11 #include "GrProcessor.h" 11 #include "GrProcessor.h"
12 #include "GrShaderVar.h" 12 #include "GrShaderVar.h"
13 13
14 /** 14 /**
15 * A GrGeomteryProcessor is used to perform computation in the vertex shader and 15 * A GrGeomteryProcessor is used to perform computation in the vertex shader and
16 * add support for custom vertex attributes. A GrGemeotryProcessor is typically 16 * add support for custom vertex attributes. A GrGemeotryProcessor is typically
17 * tied to the code that does a specific type of high-level primitive rendering 17 * tied to the code that does a specific type of high-level primitive rendering
18 * (e.g. anti-aliased circle rendering). The GrGeometryProcessor used for a draw is 18 * (e.g. anti-aliased circle rendering). The GrGeometryProcessor used for a draw is
19 * specified using GrDrawState. There can only be one geometry processor active for 19 * specified using GrDrawState. There can only be one geometry processor active for
20 * a draw. The custom vertex attributes required by the geometry processor must be 20 * a draw. The custom vertex attributes required by the geometry processor must be
21 * added to the vertex attribute array specified on the GrDrawState. 21 * added to the vertex attribute array specified on the GrDrawState.
22 * GrGeometryProcessor subclasses should be immutable after construction. 22 * GrGeometryProcessor subclasses should be immutable after construction.
23 */ 23 */
24 class GrGeometryProcessor : public GrProcessor { 24 class GrGeometryProcessor : public GrProcessor {
25 public: 25 public:
26 GrGeometryProcessor() 26 GrGeometryProcessor()
27 : fWillUseGeoShader(false) {} 27 : fInPosition("inPosition")
28 , fWillUseGeoShader(false) {}
28 29
29 virtual const GrBackendGeometryProcessorFactory& getFactory() const = 0; 30 virtual const GrBackendGeometryProcessorFactory& getFactory() const = 0;
30 31
31 /* 32 /*
32 * This only has a max because GLProgramsTest needs to generate test arrays, and these have to 33 * This only has a max because GLProgramsTest needs to generate test arrays, and these have to
33 * be static 34 * be static
34 * TODO make this truly dynamic 35 * TODO make this truly dynamic
35 */ 36 */
36 static const int kMaxVertexAttribs = 2; 37 static const int kMaxVertexAttribs = 2;
37 typedef SkTArray<GrShaderVar, true> VertexAttribArray; 38 typedef SkTArray<GrShaderVar, true> VertexAttribArray;
38 39
39 const VertexAttribArray& getVertexAttribs() const { return fVertexAttribs; } 40 const VertexAttribArray& getVertexAttribs() const { return fVertexAttribs; }
40 41
42 // A uniform view mat3 taken from the drawstate.
43 const char* uViewM() const { return "uViewM"; }
bsalomon 2014/10/27 13:43:43 Does any code outside of the geo processor subclas
44
45 const char* inPosition() const { return fInPosition; }
46
41 bool willUseGeoShader() const { return fWillUseGeoShader; } 47 bool willUseGeoShader() const { return fWillUseGeoShader; }
42 48
43 /** Returns true if this and other processor conservatively draw identically . It can only return 49 /** Returns true if this and other processor conservatively draw identically . It can only return
44 true when the two prcoessors are of the same subclass (i.e. they return the same object from 50 true when the two prcoessors are of the same subclass (i.e. they return the same object from
45 from getFactory()). 51 from getFactory()).
46 A return value of true from isEqual() should not be used to test whether the prcoessors 52 A return value of true from isEqual() should not be used to test whether the processors
47 would generate the same shader code. To test for identical code generati on use the 53 would generate the same shader code. To test for identical code generati on use the
48 processors' keys computed by the GrBackendEffectFactory. */ 54 processors' keys computed by the GrBackendEffectFactory. */
49 bool isEqual(const GrGeometryProcessor& that) const { 55 bool isEqual(const GrGeometryProcessor& that) const {
50 if (&this->getFactory() != &that.getFactory() || !this->hasSameTextureAc cesses(that)) { 56 if (&this->getFactory() != &that.getFactory() || !this->hasSameTextureAc cesses(that)) {
51 return false; 57 return false;
52 } 58 }
53 return this->onIsEqual(that); 59 return this->onIsEqual(that);
54 } 60 }
55 61
56 protected: 62 protected:
57 /** 63 /**
58 * Subclasses call this from their constructor to register vertex attributes (at most 64 * Subclasses call this from their constructor to register vertex attributes (at most
59 * kMaxVertexAttribs). This must only be called from the constructor because GrProcessors are 65 * kMaxVertexAttribs). This must only be called from the constructor because GrProcessors are
60 * immutable. 66 * immutable.
61 */ 67 */
62 const GrShaderVar& addVertexAttrib(const GrShaderVar& var) { 68 const GrShaderVar& addVertexAttrib(const GrShaderVar& var) {
63 SkASSERT(fVertexAttribs.count() < kMaxVertexAttribs); 69 SkASSERT(fVertexAttribs.count() < kMaxVertexAttribs);
64 return fVertexAttribs.push_back(var); 70 return fVertexAttribs.push_back(var);
65 } 71 }
66 72
67 void setWillUseGeoShader() { fWillUseGeoShader = true; } 73 void setWillUseGeoShader() { fWillUseGeoShader = true; }
68 74
69 private: 75 private:
70 virtual bool onIsEqual(const GrGeometryProcessor&) const = 0; 76 virtual bool onIsEqual(const GrGeometryProcessor&) const = 0;
71 77
72 SkSTArray<kMaxVertexAttribs, GrShaderVar, true> fVertexAttribs; 78 SkSTArray<kMaxVertexAttribs, GrShaderVar, true> fVertexAttribs;
79 const char* fInPosition;
73 bool fWillUseGeoShader; 80 bool fWillUseGeoShader;
74 81
75 typedef GrProcessor INHERITED; 82 typedef GrProcessor INHERITED;
76 }; 83 };
77 84
78 #endif 85 #endif
OLDNEW
« no previous file with comments | « gyp/gpu.gypi ('k') | src/gpu/GrAAConvexPathRenderer.cpp » ('j') | src/gpu/GrAARectRenderer.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698