| 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 |
| 11 #include "GrGeometryData.h" | 11 #include "GrGeometryData.h" |
| 12 #include "GrProcessor.h" | 12 #include "GrProcessor.h" |
| 13 #include "GrShaderVar.h" | 13 #include "GrShaderVar.h" |
| 14 | 14 |
| 15 /* |
| 16 * A struct for tracking batching decisions. While this lives on GrOptState, it
is managed |
| 17 * entirely by the derived classes of the GP. |
| 18 */ |
| 19 class GrBatchTracker { |
| 20 public: |
| 21 template <typename T> const T& cast() const { |
| 22 SkASSERT(sizeof(T) <= kMaxSize); |
| 23 return *reinterpret_cast<const T*>(fData); |
| 24 } |
| 25 |
| 26 template <typename T> T* cast() { |
| 27 SkASSERT(sizeof(T) <= kMaxSize); |
| 28 return reinterpret_cast<T*>(fData); |
| 29 } |
| 30 |
| 31 static const size_t kMaxSize = 32; |
| 32 |
| 33 private: |
| 34 uint8_t fData[kMaxSize]; |
| 35 }; |
| 36 |
| 37 class GrOptDrawState; |
| 38 |
| 15 /** | 39 /** |
| 16 * A GrGeometryProcessor is used to perform computation in the vertex shader and | 40 * A GrGeometryProcessor is used to perform computation in the vertex shader and |
| 17 * add support for custom vertex attributes. A GrGemeotryProcessor is typically | 41 * add support for custom vertex attributes. A GrGemeotryProcessor is typically |
| 18 * tied to the code that does a specific type of high-level primitive rendering | 42 * tied to the code that does a specific type of high-level primitive rendering |
| 19 * (e.g. anti-aliased circle rendering). The GrGeometryProcessor used for a draw
is | 43 * (e.g. anti-aliased circle rendering). The GrGeometryProcessor used for a draw
is |
| 20 * specified using GrDrawState. There can only be one geometry processor active
for | 44 * specified using GrDrawState. There can only be one geometry processor active
for |
| 21 * a draw. The custom vertex attributes required by the geometry processor must
be | 45 * a draw. The custom vertex attributes required by the geometry processor must
be |
| 22 * added to the vertex attribute array specified on the GrDrawState. | 46 * added to the vertex attribute array specified on the GrDrawState. |
| 23 * GrGeometryProcessor subclasses should be immutable after construction. | 47 * GrGeometryProcessor subclasses should be immutable after construction. |
| 24 */ | 48 */ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 A return value of true from isEqual() should not be used to test whether
the processors | 90 A return value of true from isEqual() should not be used to test whether
the processors |
| 67 would generate the same shader code. To test for identical code generati
on use the | 91 would generate the same shader code. To test for identical code generati
on use the |
| 68 processors' keys computed by the GrBackendEffectFactory. */ | 92 processors' keys computed by the GrBackendEffectFactory. */ |
| 69 bool isEqual(const GrGeometryProcessor& that) const { | 93 bool isEqual(const GrGeometryProcessor& that) const { |
| 70 if (&this->getFactory() != &that.getFactory() || !this->hasSameTextureAc
cesses(that)) { | 94 if (&this->getFactory() != &that.getFactory() || !this->hasSameTextureAc
cesses(that)) { |
| 71 return false; | 95 return false; |
| 72 } | 96 } |
| 73 return this->onIsEqual(that); | 97 return this->onIsEqual(that); |
| 74 } | 98 } |
| 75 | 99 |
| 100 struct InitBT { |
| 101 bool fOutputColor; |
| 102 bool fOutputCoverage; |
| 103 GrColor fColor; |
| 104 GrColor fCoverage; |
| 105 }; |
| 106 |
| 107 virtual void initBatchTracker(GrBatchTracker*, const InitBT&) const {} |
| 108 |
| 76 // TODO this is a total hack until the gp can own whether or not it uses uni
form | 109 // TODO this is a total hack until the gp can own whether or not it uses uni
form |
| 77 // color / coverage | 110 // color / coverage |
| 78 bool hasVertexColor() const { return fHasVertexColor; } | 111 bool hasVertexColor() const { return fHasVertexColor; } |
| 79 bool hasVertexCoverage() const { return fHasVertexCoverage; } | 112 bool hasVertexCoverage() const { return fHasVertexCoverage; } |
| 80 bool hasLocalCoords() const { return fHasLocalCoords; } | 113 bool hasLocalCoords() const { return fHasLocalCoords; } |
| 81 | 114 |
| 82 protected: | 115 protected: |
| 83 /** | 116 /** |
| 84 * Subclasses call this from their constructor to register vertex attributes
. Attributes | 117 * Subclasses call this from their constructor to register vertex attributes
. Attributes |
| 85 * will be padded to the nearest 4 bytes for performance reasons. | 118 * will be padded to the nearest 4 bytes for performance reasons. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 105 size_t fVertexStride; | 138 size_t fVertexStride; |
| 106 bool fWillUseGeoShader; | 139 bool fWillUseGeoShader; |
| 107 bool fHasVertexColor; | 140 bool fHasVertexColor; |
| 108 bool fHasVertexCoverage; | 141 bool fHasVertexCoverage; |
| 109 bool fHasLocalCoords; | 142 bool fHasLocalCoords; |
| 110 | 143 |
| 111 typedef GrProcessor INHERITED; | 144 typedef GrProcessor INHERITED; |
| 112 }; | 145 }; |
| 113 | 146 |
| 114 #endif | 147 #endif |
| OLD | NEW |