| OLD | NEW |
| 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 16 matching lines...) Expand all Loading... |
| 27 SkASSERT(sizeof(T) <= kMaxSize); | 27 SkASSERT(sizeof(T) <= kMaxSize); |
| 28 return reinterpret_cast<T*>(fData); | 28 return reinterpret_cast<T*>(fData); |
| 29 } | 29 } |
| 30 | 30 |
| 31 static const size_t kMaxSize = 32; | 31 static const size_t kMaxSize = 32; |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 uint8_t fData[kMaxSize]; | 34 uint8_t fData[kMaxSize]; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 class GrGLCaps; |
| 38 class GrGLGeometryProcessor; |
| 37 class GrOptDrawState; | 39 class GrOptDrawState; |
| 38 | 40 |
| 39 /** | 41 /** |
| 40 * A GrGeometryProcessor is used to perform computation in the vertex shader and | 42 * A GrGeometryProcessor is used to perform computation in the vertex shader and |
| 41 * add support for custom vertex attributes. A GrGemeotryProcessor is typically | 43 * add support for custom vertex attributes. A GrGemeotryProcessor is typically |
| 42 * tied to the code that does a specific type of high-level primitive rendering | 44 * tied to the code that does a specific type of high-level primitive rendering |
| 43 * (e.g. anti-aliased circle rendering). The GrGeometryProcessor used for a draw
is | 45 * (e.g. anti-aliased circle rendering). The GrGeometryProcessor used for a draw
is |
| 44 * specified using GrDrawState. There can only be one geometry processor active
for | 46 * specified using GrDrawState. There can only be one geometry processor active
for |
| 45 * a draw. The custom vertex attributes required by the geometry processor must
be | 47 * a draw. The custom vertex attributes required by the geometry processor must
be |
| 46 * added to the vertex attribute array specified on the GrDrawState. | 48 * added to the vertex attribute array specified on the GrDrawState. |
| 47 * GrGeometryProcessor subclasses should be immutable after construction. | 49 * GrGeometryProcessor subclasses should be immutable after construction. |
| 48 */ | 50 */ |
| 49 class GrGeometryProcessor : public GrProcessor { | 51 class GrGeometryProcessor : public GrProcessor { |
| 50 public: | 52 public: |
| 51 GrGeometryProcessor() | 53 GrGeometryProcessor() |
| 52 : fVertexStride(0) | 54 : fVertexStride(0) |
| 53 , fWillUseGeoShader(false) | 55 , fWillUseGeoShader(false) |
| 54 , fHasVertexColor(false) | 56 , fHasVertexColor(false) |
| 55 , fHasVertexCoverage(false) | 57 , fHasVertexCoverage(false) |
| 56 , fHasLocalCoords(false) {} | 58 , fHasLocalCoords(false) {} |
| 57 | 59 |
| 58 virtual const GrBackendGeometryProcessorFactory& getFactory() const = 0; | 60 virtual const char* name() const = 0; |
| 61 |
| 62 /** Implemented using GLProcessor::GenKey as described in this class's comme
nt. */ |
| 63 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 64 const GrGLCaps& caps, |
| 65 GrProcessorKeyBuilder* b) const = 0; |
| 66 |
| 67 |
| 68 /** Returns a new instance of the appropriate *GL* implementation class |
| 69 for the given GrProcessor; caller is responsible for deleting |
| 70 the object. */ |
| 71 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst = 0; |
| 59 | 72 |
| 60 /* | 73 /* |
| 61 * This is a safeguard to prevent GPs from going beyond platform specific at
tribute limits. | 74 * This is a safeguard to prevent GPs from going beyond platform specific at
tribute limits. |
| 62 * This number can almost certainly be raised if required. | 75 * This number can almost certainly be raised if required. |
| 63 */ | 76 */ |
| 64 static const int kMaxVertexAttribs = 6; | 77 static const int kMaxVertexAttribs = 6; |
| 65 | 78 |
| 66 struct GrAttribute { | 79 struct GrAttribute { |
| 67 GrAttribute(const char* name, GrVertexAttribType type) | 80 GrAttribute(const char* name, GrVertexAttribType type) |
| 68 : fName(name) | 81 : fName(name) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 84 | 97 |
| 85 bool willUseGeoShader() const { return fWillUseGeoShader; } | 98 bool willUseGeoShader() const { return fWillUseGeoShader; } |
| 86 | 99 |
| 87 /** Returns true if this and other processor conservatively draw identically
. It can only return | 100 /** Returns true if this and other processor conservatively draw identically
. It can only return |
| 88 true when the two prcoessors are of the same subclass (i.e. they return
the same object from | 101 true when the two prcoessors are of the same subclass (i.e. they return
the same object from |
| 89 from getFactory()). | 102 from getFactory()). |
| 90 A return value of true from isEqual() should not be used to test whether
the processors | 103 A return value of true from isEqual() should not be used to test whether
the processors |
| 91 would generate the same shader code. To test for identical code generati
on use the | 104 would generate the same shader code. To test for identical code generati
on use the |
| 92 processors' keys computed by the GrBackendEffectFactory. */ | 105 processors' keys computed by the GrBackendEffectFactory. */ |
| 93 bool isEqual(const GrGeometryProcessor& that) const { | 106 bool isEqual(const GrGeometryProcessor& that) const { |
| 94 if (&this->getFactory() != &that.getFactory() || !this->hasSameTextureAc
cesses(that)) { | 107 if (this->classID() != that.classID() || !this->hasSameTextureAccesses(t
hat)) { |
| 95 return false; | 108 return false; |
| 96 } | 109 } |
| 97 return this->onIsEqual(that); | 110 return this->onIsEqual(that); |
| 98 } | 111 } |
| 99 | 112 |
| 100 struct InitBT { | 113 struct InitBT { |
| 101 bool fOutputColor; | 114 bool fOutputColor; |
| 102 bool fOutputCoverage; | 115 bool fOutputCoverage; |
| 103 GrColor fColor; | 116 GrColor fColor; |
| 104 GrColor fCoverage; | 117 GrColor fCoverage; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 149 |
| 137 SkSTArray<kMaxVertexAttribs, GrAttribute, true> fAttribs; | 150 SkSTArray<kMaxVertexAttribs, GrAttribute, true> fAttribs; |
| 138 size_t fVertexStride; | 151 size_t fVertexStride; |
| 139 bool fWillUseGeoShader; | 152 bool fWillUseGeoShader; |
| 140 bool fHasVertexColor; | 153 bool fHasVertexColor; |
| 141 bool fHasVertexCoverage; | 154 bool fHasVertexCoverage; |
| 142 bool fHasLocalCoords; | 155 bool fHasLocalCoords; |
| 143 | 156 |
| 144 typedef GrProcessor INHERITED; | 157 typedef GrProcessor INHERITED; |
| 145 }; | 158 }; |
| 146 | |
| 147 #endif | 159 #endif |
| OLD | NEW |