| 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 GrPrimitiveProcessor_DEFINED | 8 #ifndef GrPrimitiveProcessor_DEFINED |
| 9 #define GrPrimitiveProcessor_DEFINED | 9 #define GrPrimitiveProcessor_DEFINED |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 * | 35 * |
| 36 * In a deferred geometry world, the GrPrimitiveProcessor can always 'batch' To
do this, each | 36 * In a deferred geometry world, the GrPrimitiveProcessor can always 'batch' To
do this, each |
| 37 * primitive type is associated with one GrPrimitiveProcessor, who has complete
control of how | 37 * primitive type is associated with one GrPrimitiveProcessor, who has complete
control of how |
| 38 * it draws. Each primitive draw will bundle all required data to perform the d
raw, and these | 38 * it draws. Each primitive draw will bundle all required data to perform the d
raw, and these |
| 39 * bundles of data will be owned by an instance of the associated GrPrimitivePro
cessor. Bundles | 39 * bundles of data will be owned by an instance of the associated GrPrimitivePro
cessor. Bundles |
| 40 * can be updated alongside the GrBatchTracker struct itself, ultimately allowin
g the | 40 * can be updated alongside the GrBatchTracker struct itself, ultimately allowin
g the |
| 41 * GrPrimitiveProcessor complete control of how it gets data into the fragment s
hader as long as | 41 * GrPrimitiveProcessor complete control of how it gets data into the fragment s
hader as long as |
| 42 * it emits the appropriate color, or none at all, as directed. | 42 * it emits the appropriate color, or none at all, as directed. |
| 43 */ | 43 */ |
| 44 | 44 |
| 45 /* | |
| 46 * A struct for tracking batching decisions. While this lives on GrOptState, it
is managed | |
| 47 * entirely by the derived classes of the GP. | |
| 48 * // TODO this was an early attempt at handling out of order batching. It shou
ld be | |
| 49 * used carefully as it is being replaced by GrBatch | |
| 50 */ | |
| 51 class GrBatchTracker { | |
| 52 public: | |
| 53 template <typename T> const T& cast() const { | |
| 54 SkASSERT(sizeof(T) <= kMaxSize); | |
| 55 return *reinterpret_cast<const T*>(fData.get()); | |
| 56 } | |
| 57 | |
| 58 template <typename T> T* cast() { | |
| 59 SkASSERT(sizeof(T) <= kMaxSize); | |
| 60 return reinterpret_cast<T*>(fData.get()); | |
| 61 } | |
| 62 | |
| 63 static const size_t kMaxSize = 32; | |
| 64 | |
| 65 private: | |
| 66 SkAlignedSStorage<kMaxSize> fData; | |
| 67 }; | |
| 68 | |
| 69 class GrGLSLCaps; | 45 class GrGLSLCaps; |
| 70 class GrGLPrimitiveProcessor; | 46 class GrGLPrimitiveProcessor; |
| 71 | 47 |
| 72 struct GrInitInvariantOutput; | 48 struct GrInitInvariantOutput; |
| 73 | 49 |
| 74 /* | 50 /* |
| 75 * This class allows the GrPipeline to communicate information about the pipelin
e to a | 51 * This class allows the GrPipeline to communicate information about the pipelin
e to a |
| 76 * GrBatch which should be forwarded to the GrPrimitiveProcessor(s) created by t
he batch. | 52 * GrBatch which should be forwarded to the GrPrimitiveProcessor(s) created by t
he batch. |
| 77 * These are not properly part of the pipeline because they assume the specific
inputs | 53 * These are not properly part of the pipeline because they assume the specific
inputs |
| 78 * that the batch provided when it created the pipeline. Identical pipelines may
be | 54 * that the batch provided when it created the pipeline. Identical pipelines may
be |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 kIgnored_GrGPInput, | 141 kIgnored_GrGPInput, |
| 166 }; | 142 }; |
| 167 | 143 |
| 168 /* | 144 /* |
| 169 * GrPrimitiveProcessor defines an interface which all subclasses must implement
. All | 145 * GrPrimitiveProcessor defines an interface which all subclasses must implement
. All |
| 170 * GrPrimitiveProcessors must proivide seed color and coverage for the Ganesh co
lor / coverage | 146 * GrPrimitiveProcessors must proivide seed color and coverage for the Ganesh co
lor / coverage |
| 171 * pipelines, and they must provide some notion of equality | 147 * pipelines, and they must provide some notion of equality |
| 172 */ | 148 */ |
| 173 class GrPrimitiveProcessor : public GrProcessor { | 149 class GrPrimitiveProcessor : public GrProcessor { |
| 174 public: | 150 public: |
| 175 virtual void initBatchTracker(GrBatchTracker*, const GrPipelineOptimizations
&) const = 0; | |
| 176 | |
| 177 virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0; | |
| 178 virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const =
0; | |
| 179 | |
| 180 // Only the GrGeometryProcessor subclass actually has a geo shader or vertex
attributes, but | 151 // Only the GrGeometryProcessor subclass actually has a geo shader or vertex
attributes, but |
| 181 // we put these calls on the base class to prevent having to cast | 152 // we put these calls on the base class to prevent having to cast |
| 182 virtual bool willUseGeoShader() const = 0; | 153 virtual bool willUseGeoShader() const = 0; |
| 183 | 154 |
| 184 /* | 155 /* |
| 185 * This is a safeguard to prevent GrPrimitiveProcessor's from going beyond p
latform specific | 156 * This is a safeguard to prevent GrPrimitiveProcessor's from going beyond p
latform specific |
| 186 * attribute limits. This number can almost certainly be raised if required. | 157 * attribute limits. This number can almost certainly be raised if required. |
| 187 */ | 158 */ |
| 188 static const int kMaxVertexAttribs = 6; | 159 static const int kMaxVertexAttribs = 6; |
| 189 | 160 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 */ | 194 */ |
| 224 uint32_t getTransformKey(const SkTArray<const GrCoordTransform*, true>& coor
ds, | 195 uint32_t getTransformKey(const SkTArray<const GrCoordTransform*, true>& coor
ds, |
| 225 int numCoords) const; | 196 int numCoords) const; |
| 226 | 197 |
| 227 /** | 198 /** |
| 228 * Sets a unique key on the GrProcessorKeyBuilder that is directly associate
d with this geometry | 199 * Sets a unique key on the GrProcessorKeyBuilder that is directly associate
d with this geometry |
| 229 * processor's GL backend implementation. | 200 * processor's GL backend implementation. |
| 230 * | 201 * |
| 231 * TODO: A better name for this function would be "compute" instead of "get
". | 202 * TODO: A better name for this function would be "compute" instead of "get
". |
| 232 */ | 203 */ |
| 233 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 204 virtual void getGLProcessorKey(const GrGLSLCaps& caps, |
| 234 const GrGLSLCaps& caps, | |
| 235 GrProcessorKeyBuilder* b) const = 0; | 205 GrProcessorKeyBuilder* b) const = 0; |
| 236 | 206 |
| 237 | 207 |
| 238 /** Returns a new instance of the appropriate *GL* implementation class | 208 /** Returns a new instance of the appropriate *GL* implementation class |
| 239 for the given GrProcessor; caller is responsible for deleting | 209 for the given GrProcessor; caller is responsible for deleting |
| 240 the object. */ | 210 the object. */ |
| 241 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, | 211 virtual GrGLPrimitiveProcessor* createGLInstance(const GrGLSLCaps& caps) con
st = 0; |
| 242 const GrGLSLCaps& caps) con
st = 0; | |
| 243 | 212 |
| 244 bool isPathRendering() const { return fIsPathRendering; } | 213 bool isPathRendering() const { return fIsPathRendering; } |
| 245 | 214 |
| 246 /** | 215 /** |
| 247 * No Local Coord Transformation is needed in the shader, instead transforme
d local coords will | 216 * No Local Coord Transformation is needed in the shader, instead transforme
d local coords will |
| 248 * be provided via vertex attribute. | 217 * be provided via vertex attribute. |
| 249 */ | 218 */ |
| 250 virtual bool hasTransformedLocalCoords() const = 0; | 219 virtual bool hasTransformedLocalCoords() const = 0; |
| 251 | 220 |
| 252 protected: | 221 protected: |
| 253 GrPrimitiveProcessor(bool isPathRendering) | 222 GrPrimitiveProcessor(bool isPathRendering) |
| 254 : fNumAttribs(0) | 223 : fNumAttribs(0) |
| 255 , fVertexStride(0) | 224 , fVertexStride(0) |
| 256 , fIsPathRendering(isPathRendering) {} | 225 , fIsPathRendering(isPathRendering) {} |
| 257 | 226 |
| 258 Attribute fAttribs[kMaxVertexAttribs]; | 227 Attribute fAttribs[kMaxVertexAttribs]; |
| 259 int fNumAttribs; | 228 int fNumAttribs; |
| 260 size_t fVertexStride; | 229 size_t fVertexStride; |
| 261 | 230 |
| 262 private: | 231 private: |
| 263 void notifyRefCntIsZero() const final {}; | 232 void notifyRefCntIsZero() const final {}; |
| 264 virtual bool hasExplicitLocalCoords() const = 0; | 233 virtual bool hasExplicitLocalCoords() const = 0; |
| 265 | 234 |
| 266 bool fIsPathRendering; | 235 bool fIsPathRendering; |
| 267 | 236 |
| 268 typedef GrProcessor INHERITED; | 237 typedef GrProcessor INHERITED; |
| 269 }; | 238 }; |
| 270 | 239 |
| 271 #endif | 240 #endif |
| OLD | NEW |