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 "GrPrimitiveProcessor.h" | 11 #include "GrPrimitiveProcessor.h" |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * A GrGeometryProcessor is a flexible method for rendering a primitive. The Gr GeometryProcessor | 14 * A GrGeometryProcessor is a flexible method for rendering a primitive. The Gr GeometryProcessor |
| 15 * has complete control over vertex attributes and uniforms(aside from the rende r target) but it | 15 * has complete control over vertex attributes and uniforms(aside from the rende r target) but it |
| 16 * must obey the same contract as any GrPrimitiveProcessor, specifically it must emit a color and | 16 * must obey the same contract as any GrPrimitiveProcessor, specifically it must emit a color and |
| 17 * coverage into the fragment shader. Where this color and coverage come from i s completely the | 17 * coverage into the fragment shader. Where this color and coverage come from i s completely the |
| 18 * responsibility of the GrGeometryProcessor. | 18 * responsibility of the GrGeometryProcessor. |
| 19 */ | 19 */ |
| 20 class GrGeometryProcessor : public GrPrimitiveProcessor { | 20 class GrGeometryProcessor : public GrPrimitiveProcessor { |
| 21 public: | 21 public: |
| 22 GrGeometryProcessor() | 22 GrGeometryProcessor() |
| 23 : INHERITED(false) | 23 : INHERITED(false) |
| 24 , fWillUseGeoShader(false) | 24 , fWillUseGeoShader(false) |
| 25 , fHasLocalCoords(false) {} | 25 , fLocalCoordsType(kIgnoredOrPosition_LocalCoordsType) {} |
| 26 | 26 |
| 27 bool willUseGeoShader() const override { return fWillUseGeoShader; } | 27 bool willUseGeoShader() const override { return fWillUseGeoShader; } |
| 28 | 28 |
| 29 // TODO delete when paths are in batch | 29 // TODO delete when paths are in batch |
| 30 void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const override {} | 30 void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const override {} |
| 31 | 31 |
| 32 // TODO delete this when paths are in batch | 32 // TODO delete this when paths are in batch |
| 33 bool canMakeEqual(const GrBatchTracker& mine, | 33 bool canMakeEqual(const GrBatchTracker& mine, |
| 34 const GrPrimitiveProcessor& that, | 34 const GrPrimitiveProcessor& that, |
| 35 const GrBatchTracker& theirs) const override { | 35 const GrBatchTracker& theirs) const override { |
| 36 SkFAIL("Unsupported\n"); | 36 SkFAIL("Unsupported\n"); |
| 37 return false; | 37 return false; |
| 38 } | 38 } |
| 39 | 39 |
| 40 // TODO Delete when paths are in batch | 40 // TODO Delete when paths are in batch |
| 41 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 41 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 42 SkFAIL("Unsupported\n"); | 42 SkFAIL("Unsupported\n"); |
| 43 } | 43 } |
| 44 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 44 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
| 45 SkFAIL("Unsupported\n"); | 45 SkFAIL("Unsupported\n"); |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool hasTransformedLocalCoords() const override { | |
|
bsalomon
2015/08/05 16:20:19
enum getter here rather than two queries?
joshualitt
2015/08/05 16:32:30
I'd rather just leave the queries. All of this wi
| |
| 49 return kHasTransformed_LocalCoordsType == fLocalCoordsType; | |
| 50 } | |
| 51 | |
| 52 bool hasExplicitLocalCoords() const override { | |
| 53 return kHasExplicit_LocalCoordsType == fLocalCoordsType; | |
| 54 } | |
| 55 | |
| 48 protected: | 56 protected: |
| 49 /** | 57 /** |
| 50 * Subclasses call this from their constructor to register vertex attributes . Attributes | 58 * Subclasses call this from their constructor to register vertex attributes . Attributes |
| 51 * will be padded to the nearest 4 bytes for performance reasons. | 59 * will be padded to the nearest 4 bytes for performance reasons. |
| 52 * TODO After deferred geometry, we should do all of this inline in Generate Geometry alongside | 60 * TODO After deferred geometry, we should do all of this inline in Generate Geometry alongside |
| 53 * the struct used to actually populate the attributes. This is all extreme ly fragile, vertex | 61 * the struct used to actually populate the attributes. This is all extreme ly fragile, vertex |
| 54 * attributes have to be added in the order they will appear in the struct w hich maps memory. | 62 * attributes have to be added in the order they will appear in the struct w hich maps memory. |
| 55 * The processor key should reflect the vertex attributes, or there lack the reof in the | 63 * The processor key should reflect the vertex attributes, or there lack the reof in the |
| 56 * GrGeometryProcessor. | 64 * GrGeometryProcessor. |
| 57 */ | 65 */ |
| 58 const Attribute& addVertexAttrib(const Attribute& attribute) { | 66 const Attribute& addVertexAttrib(const Attribute& attribute) { |
| 59 SkASSERT(fNumAttribs < kMaxVertexAttribs); | 67 SkASSERT(fNumAttribs < kMaxVertexAttribs); |
| 60 fVertexStride += attribute.fOffset; | 68 fVertexStride += attribute.fOffset; |
| 61 fAttribs[fNumAttribs] = attribute; | 69 fAttribs[fNumAttribs] = attribute; |
| 62 return fAttribs[fNumAttribs++]; | 70 return fAttribs[fNumAttribs++]; |
| 63 } | 71 } |
| 64 | 72 |
| 65 void setWillUseGeoShader() { fWillUseGeoShader = true; } | 73 void setWillUseGeoShader() { fWillUseGeoShader = true; } |
| 66 | 74 |
| 67 // TODO hack see above | 75 /** |
| 68 void setHasLocalCoords() { fHasLocalCoords = true; } | 76 * If a GrFragmentProcessor in the GrPipeline needs localCoods, we will prov ide them in one of |
| 77 * three ways | |
| 78 * 1) LocalCoordTransform * Position - in Shader | |
| 79 * 2) LocalCoordTransform * ExplicitLocalCoords- in Shader | |
| 80 * 3) A transformation on the CPU uploaded via vertex attribute | |
| 81 * TODO make this GrBatches responsibility | |
| 82 */ | |
| 83 enum LocalCoordsType { | |
| 84 kIgnoredOrPosition_LocalCoordsType, | |
|
bsalomon
2015/08/05 16:20:19
Are there really ignored local local coords? Unuse
joshualitt
2015/08/05 16:32:30
Acknowledged.
| |
| 85 kHasExplicit_LocalCoordsType, | |
| 86 kHasTransformed_LocalCoordsType | |
| 87 }; | |
| 88 | |
| 89 void setHasExplicitLocalCoords() { | |
| 90 SkASSERT(kIgnoredOrPosition_LocalCoordsType == fLocalCoordsType); | |
| 91 fLocalCoordsType = kHasExplicit_LocalCoordsType; | |
| 92 } | |
| 93 void setHasTransformedLocalCoords() { | |
| 94 SkASSERT(kIgnoredOrPosition_LocalCoordsType == fLocalCoordsType); | |
| 95 fLocalCoordsType = kHasTransformed_LocalCoordsType; | |
| 96 } | |
| 69 | 97 |
| 70 private: | 98 private: |
| 71 bool hasExplicitLocalCoords() const override { return fHasLocalCoords; } | |
| 72 | |
| 73 bool fWillUseGeoShader; | 99 bool fWillUseGeoShader; |
| 74 bool fHasLocalCoords; | 100 LocalCoordsType fLocalCoordsType; |
| 75 | 101 |
| 76 typedef GrPrimitiveProcessor INHERITED; | 102 typedef GrPrimitiveProcessor INHERITED; |
| 77 }; | 103 }; |
| 78 | 104 |
| 79 #endif | 105 #endif |
| OLD | NEW |