Chromium Code Reviews| 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 optstate, it i s managed | |
|
bsalomon
2014/12/03 14:58:52
Can you make optstate be GrOptState? I've noticed
| |
| 17 * entirely by the derived classes of the GP. | |
| 18 */ | |
| 19 class GrBatchTracker { | |
| 20 public: | |
| 21 template <typename T> const T& cast() const { | |
| 22 return *reinterpret_cast<const T*>(fStorage.begin()); | |
| 23 } | |
| 24 | |
| 25 template <typename T> T* cast() { return reinterpret_cast<T*>(fStorage.begin ()); } | |
| 26 | |
| 27 private: | |
| 28 // kPreAllocSize is actually more like a maxsize. | |
|
bsalomon
2014/12/03 14:38:19
huh?
bsalomon
2014/12/03 14:58:52
If it's a max size and it's preallocated then SkST
| |
| 29 static const size_t kPreAllocSize = 32; | |
| 30 SkSTArray<kPreAllocSize, uint8_t, true> fStorage; | |
| 31 }; | |
| 32 | |
| 33 class GrOptDrawState; | |
| 34 | |
| 15 /** | 35 /** |
| 16 * A GrGeometryProcessor is used to perform computation in the vertex shader and | 36 * A GrGeometryProcessor is used to perform computation in the vertex shader and |
| 17 * add support for custom vertex attributes. A GrGemeotryProcessor is typically | 37 * 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 | 38 * 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 | 39 * (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 | 40 * 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 | 41 * a draw. The custom vertex attributes required by the geometry processor must be |
| 22 * added to the vertex attribute array specified on the GrDrawState. | 42 * added to the vertex attribute array specified on the GrDrawState. |
| 23 * GrGeometryProcessor subclasses should be immutable after construction. | 43 * GrGeometryProcessor subclasses should be immutable after construction. |
| 24 */ | 44 */ |
| (...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 | 86 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 | 87 would generate the same shader code. To test for identical code generati on use the |
| 68 processors' keys computed by the GrBackendEffectFactory. */ | 88 processors' keys computed by the GrBackendEffectFactory. */ |
| 69 bool isEqual(const GrGeometryProcessor& that) const { | 89 bool isEqual(const GrGeometryProcessor& that) const { |
| 70 if (&this->getFactory() != &that.getFactory() || !this->hasSameTextureAc cesses(that)) { | 90 if (&this->getFactory() != &that.getFactory() || !this->hasSameTextureAc cesses(that)) { |
| 71 return false; | 91 return false; |
| 72 } | 92 } |
| 73 return this->onIsEqual(that); | 93 return this->onIsEqual(that); |
| 74 } | 94 } |
| 75 | 95 |
| 96 struct InitBT { | |
|
bsalomon
2014/12/03 14:38:19
comments?
We're getting rid of fColor and fCovera
bsalomon
2014/12/03 14:58:52
What I meant is that GrGP shouldn't have an input
| |
| 97 bool fOutputColor; | |
| 98 bool fOutputCoverage; | |
| 99 GrColor fColor; | |
| 100 GrColor fCoverage; | |
| 101 }; | |
| 102 | |
| 103 virtual void initBatchTracker(GrBatchTracker*, const InitBT&) const {} | |
| 104 | |
| 76 // TODO this is a total hack until the gp can own whether or not it uses uni form | 105 // TODO this is a total hack until the gp can own whether or not it uses uni form |
| 77 // color / coverage | 106 // color / coverage |
| 78 bool hasVertexColor() const { return fHasVertexColor; } | 107 bool hasVertexColor() const { return fHasVertexColor; } |
| 79 bool hasVertexCoverage() const { return fHasVertexCoverage; } | 108 bool hasVertexCoverage() const { return fHasVertexCoverage; } |
| 80 bool hasLocalCoords() const { return fHasLocalCoords; } | 109 bool hasLocalCoords() const { return fHasLocalCoords; } |
| 81 | 110 |
| 82 protected: | 111 protected: |
| 83 /** | 112 /** |
| 84 * Subclasses call this from their constructor to register vertex attributes . Attributes | 113 * Subclasses call this from their constructor to register vertex attributes . Attributes |
| 85 * will be padded to the nearest 4 bytes for performance reasons. | 114 * will be padded to the nearest 4 bytes for performance reasons. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 105 size_t fVertexStride; | 134 size_t fVertexStride; |
| 106 bool fWillUseGeoShader; | 135 bool fWillUseGeoShader; |
| 107 bool fHasVertexColor; | 136 bool fHasVertexColor; |
| 108 bool fHasVertexCoverage; | 137 bool fHasVertexCoverage; |
| 109 bool fHasLocalCoords; | 138 bool fHasLocalCoords; |
| 110 | 139 |
| 111 typedef GrProcessor INHERITED; | 140 typedef GrProcessor INHERITED; |
| 112 }; | 141 }; |
| 113 | 142 |
| 114 #endif | 143 #endif |
| OLD | NEW |