| 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 | |
| 39 /** | 15 /** |
| 40 * A GrGeometryProcessor is used to perform computation in the vertex shader and | 16 * A GrGeometryProcessor is used to perform computation in the vertex shader and |
| 41 * add support for custom vertex attributes. A GrGemeotryProcessor is typically | 17 * 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 | 18 * 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 | 19 * (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 | 20 * 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 | 21 * a draw. The custom vertex attributes required by the geometry processor must
be |
| 46 * added to the vertex attribute array specified on the GrDrawState. | 22 * added to the vertex attribute array specified on the GrDrawState. |
| 47 * GrGeometryProcessor subclasses should be immutable after construction. | 23 * GrGeometryProcessor subclasses should be immutable after construction. |
| 48 */ | 24 */ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 A return value of true from isEqual() should not be used to test whether
the processors | 66 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 | 67 would generate the same shader code. To test for identical code generati
on use the |
| 92 processors' keys computed by the GrBackendEffectFactory. */ | 68 processors' keys computed by the GrBackendEffectFactory. */ |
| 93 bool isEqual(const GrGeometryProcessor& that) const { | 69 bool isEqual(const GrGeometryProcessor& that) const { |
| 94 if (&this->getFactory() != &that.getFactory() || !this->hasSameTextureAc
cesses(that)) { | 70 if (&this->getFactory() != &that.getFactory() || !this->hasSameTextureAc
cesses(that)) { |
| 95 return false; | 71 return false; |
| 96 } | 72 } |
| 97 return this->onIsEqual(that); | 73 return this->onIsEqual(that); |
| 98 } | 74 } |
| 99 | 75 |
| 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 | |
| 109 // TODO this is a total hack until the gp can own whether or not it uses uni
form | 76 // TODO this is a total hack until the gp can own whether or not it uses uni
form |
| 110 // color / coverage | 77 // color / coverage |
| 111 bool hasVertexColor() const { return fHasVertexColor; } | 78 bool hasVertexColor() const { return fHasVertexColor; } |
| 112 bool hasVertexCoverage() const { return fHasVertexCoverage; } | 79 bool hasVertexCoverage() const { return fHasVertexCoverage; } |
| 113 bool hasLocalCoords() const { return fHasLocalCoords; } | 80 bool hasLocalCoords() const { return fHasLocalCoords; } |
| 114 | 81 |
| 115 protected: | 82 protected: |
| 116 /** | 83 /** |
| 117 * Subclasses call this from their constructor to register vertex attributes
. Attributes | 84 * Subclasses call this from their constructor to register vertex attributes
. Attributes |
| 118 * will be padded to the nearest 4 bytes for performance reasons. | 85 * will be padded to the nearest 4 bytes for performance reasons. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 138 size_t fVertexStride; | 105 size_t fVertexStride; |
| 139 bool fWillUseGeoShader; | 106 bool fWillUseGeoShader; |
| 140 bool fHasVertexColor; | 107 bool fHasVertexColor; |
| 141 bool fHasVertexCoverage; | 108 bool fHasVertexCoverage; |
| 142 bool fHasLocalCoords; | 109 bool fHasLocalCoords; |
| 143 | 110 |
| 144 typedef GrProcessor INHERITED; | 111 typedef GrProcessor INHERITED; |
| 145 }; | 112 }; |
| 146 | 113 |
| 147 #endif | 114 #endif |
| OLD | NEW |