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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 SkAlignedSStorage<kMaxSize> fData; | 66 SkAlignedSStorage<kMaxSize> fData; |
67 }; | 67 }; |
68 | 68 |
69 class GrGLSLCaps; | 69 class GrGLSLCaps; |
70 class GrGLPrimitiveProcessor; | 70 class GrGLPrimitiveProcessor; |
71 | 71 |
72 struct GrInitInvariantOutput; | 72 struct GrInitInvariantOutput; |
73 | 73 |
74 /* | 74 /* |
75 * This class allows the GrPipeline to communicate information about the pipelin
e to a | 75 * This class allows the GrPipeline to communicate information about the pipelin
e to a |
76 * GrPrimitiveProcessor that will be used in conjunction with the GrPipeline. | 76 * 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 |
| 78 * that the batch provided when it created the pipeline. Identical pipelines may
be |
| 79 * created by different batches with different input assumptions and therefore d
ifferent |
| 80 * computed optimizations. It is the batch-specific optimizations that allow the
pipelines |
| 81 * to be equal. |
77 */ | 82 */ |
78 class GrPipelineInfo { | 83 class GrPipelineOptimizations { |
79 public: | 84 public: |
80 /** Does the pipeline require the GrPrimitiveProcessor's color? */ | 85 /** Does the pipeline require the GrPrimitiveProcessor's color? */ |
81 bool readsColor() const { return SkToBool(kReadsColor_GrPipelineInfoFlag & f
Flags); } | 86 bool readsColor() const { return SkToBool(kReadsColor_GrPipelineOptimization
sFlag & fFlags); } |
82 | 87 |
83 /** Does the pipeline require the GrPrimitiveProcessor's coverage? */ | 88 /** Does the pipeline require the GrPrimitiveProcessor's coverage? */ |
84 bool readsCoverage() const { return SkToBool(kReadsCoverage_GrPipelineInfoFl
ag & fFlags); } | 89 bool readsCoverage() const { return |
| 90 SkToBool(kReadsCoverage_GrPipelineOptimizationsFlag & fFlags); } |
85 | 91 |
86 /** Does the pipeline require access to (implicit or explicit) local coordin
ates? */ | 92 /** Does the pipeline require access to (implicit or explicit) local coordin
ates? */ |
87 bool readsLocalCoords() const { | 93 bool readsLocalCoords() const { |
88 return SkToBool(kReadsLocalCoords_GrPipelineInfoFlag & fFlags); | 94 return SkToBool(kReadsLocalCoords_GrPipelineOptimizationsFlag & fFlags); |
89 } | 95 } |
90 | 96 |
91 /** Does the pipeline allow the GrPrimitiveProcessor to combine color and co
verage into one | 97 /** Does the pipeline allow the GrPrimitiveProcessor to combine color and co
verage into one |
92 color output ? */ | 98 color output ? */ |
93 bool canTweakAlphaForCoverage() const { | 99 bool canTweakAlphaForCoverage() const { |
94 return SkToBool(kCanTweakAlphaForCoverage_GrPipelineInfoFlag & fFlags); | 100 return SkToBool(kCanTweakAlphaForCoverage_GrPipelineOptimizationsFlag &
fFlags); |
95 } | 101 } |
96 | 102 |
97 /** Does the pipeline require the GrPrimitiveProcessor to specify a specific
color (and if | 103 /** Does the pipeline require the GrPrimitiveProcessor to specify a specific
color (and if |
98 so get the color)? */ | 104 so get the color)? */ |
99 bool getOverrideColorIfSet(GrColor* overrideColor) const { | 105 bool getOverrideColorIfSet(GrColor* overrideColor) const { |
100 if (SkToBool(kUseOverrideColor_GrPipelineInfoFlag & fFlags)) { | 106 if (SkToBool(kUseOverrideColor_GrPipelineOptimizationsFlag & fFlags)) { |
101 SkASSERT(SkToBool(kReadsColor_GrPipelineInfoFlag & fFlags)); | 107 SkASSERT(SkToBool(kReadsColor_GrPipelineOptimizationsFlag & fFlags))
; |
102 if (overrideColor) { | 108 if (overrideColor) { |
103 *overrideColor = fOverrideColor; | 109 *overrideColor = fOverrideColor; |
104 } | 110 } |
105 return true; | 111 return true; |
106 } | 112 } |
107 return false; | 113 return false; |
108 } | 114 } |
109 | 115 |
110 private: | 116 private: |
111 enum { | 117 enum { |
112 // If this is not set the primitive processor need not produce a color o
utput | 118 // If this is not set the primitive processor need not produce a color o
utput |
113 kReadsColor_GrPipelineInfoFlag = 0x1, | 119 kReadsColor_GrPipelineOptimizationsFlag = 0x1, |
114 | 120 |
115 // If this is not set the primitive processor need not produce a coverag
e output | 121 // If this is not set the primitive processor need not produce a coverag
e output |
116 kReadsCoverage_GrPipelineInfoFlag = 0x2, | 122 kReadsCoverage_GrPipelineOptimizationsFlag = 0x2, |
117 | 123 |
118 // If this is not set the primitive processor need not produce local coo
rdinates | 124 // If this is not set the primitive processor need not produce local coo
rdinates |
119 kReadsLocalCoords_GrPipelineInfoFlag = 0x4, | 125 kReadsLocalCoords_GrPipelineOptimizationsFlag = 0x4, |
120 | 126 |
121 // If this flag is set then the primitive processor may produce color*co
verage as | 127 // If this flag is set then the primitive processor may produce color*co
verage as |
122 // its color output (and not output a separate coverage). | 128 // its color output (and not output a separate coverage). |
123 kCanTweakAlphaForCoverage_GrPipelineInfoFlag = 0x8, | 129 kCanTweakAlphaForCoverage_GrPipelineOptimizationsFlag = 0x8, |
124 | 130 |
125 // If this flag is set the GrPrimitiveProcessor must produce fOverrideCo
lor as its | 131 // If this flag is set the GrPrimitiveProcessor must produce fOverrideCo
lor as its |
126 // output color. If not set fOverrideColor is to be ignored. | 132 // output color. If not set fOverrideColor is to be ignored. |
127 kUseOverrideColor_GrPipelineInfoFlag = 0x10, | 133 kUseOverrideColor_GrPipelineOptimizationsFlag = 0x10, |
128 }; | 134 }; |
129 | 135 |
130 uint32_t fFlags; | 136 uint32_t fFlags; |
131 GrColor fOverrideColor; | 137 GrColor fOverrideColor; |
132 | 138 |
133 friend class GrPipeline; // To initialize this | 139 friend class GrPipeline; // To initialize this |
134 }; | 140 }; |
135 | 141 |
136 /* | 142 /* |
137 * This enum is shared by GrPrimitiveProcessors and GrGLPrimitiveProcessors to c
oordinate shaders | 143 * This enum is shared by GrPrimitiveProcessors and GrGLPrimitiveProcessors to c
oordinate shaders |
138 * with vertex attributes / uniforms. | 144 * with vertex attributes / uniforms. |
139 */ | 145 */ |
140 enum GrGPInput { | 146 enum GrGPInput { |
141 kAllOnes_GrGPInput, | 147 kAllOnes_GrGPInput, |
142 kAttribute_GrGPInput, | 148 kAttribute_GrGPInput, |
143 kUniform_GrGPInput, | 149 kUniform_GrGPInput, |
144 kIgnored_GrGPInput, | 150 kIgnored_GrGPInput, |
145 }; | 151 }; |
146 | 152 |
147 /* | 153 /* |
148 * GrPrimitiveProcessor defines an interface which all subclasses must implement
. All | 154 * GrPrimitiveProcessor defines an interface which all subclasses must implement
. All |
149 * GrPrimitiveProcessors must proivide seed color and coverage for the Ganesh co
lor / coverage | 155 * GrPrimitiveProcessors must proivide seed color and coverage for the Ganesh co
lor / coverage |
150 * pipelines, and they must provide some notion of equality | 156 * pipelines, and they must provide some notion of equality |
151 */ | 157 */ |
152 class GrPrimitiveProcessor : public GrProcessor { | 158 class GrPrimitiveProcessor : public GrProcessor { |
153 public: | 159 public: |
154 virtual void initBatchTracker(GrBatchTracker*, const GrPipelineInfo&) const
= 0; | 160 virtual void initBatchTracker(GrBatchTracker*, const GrPipelineOptimizations
&) const = 0; |
155 | 161 |
156 virtual bool canMakeEqual(const GrBatchTracker& mine, | 162 virtual bool canMakeEqual(const GrBatchTracker& mine, |
157 const GrPrimitiveProcessor& that, | 163 const GrPrimitiveProcessor& that, |
158 const GrBatchTracker& theirs) const = 0; | 164 const GrBatchTracker& theirs) const = 0; |
159 | 165 |
160 virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0; | 166 virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0; |
161 virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const =
0; | 167 virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const =
0; |
162 | 168 |
163 // Only the GrGeometryProcessor subclass actually has a geo shader or vertex
attributes, but | 169 // Only the GrGeometryProcessor subclass actually has a geo shader or vertex
attributes, but |
164 // we put these calls on the base class to prevent having to cast | 170 // we put these calls on the base class to prevent having to cast |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 244 |
239 private: | 245 private: |
240 virtual bool hasExplicitLocalCoords() const = 0; | 246 virtual bool hasExplicitLocalCoords() const = 0; |
241 | 247 |
242 bool fIsPathRendering; | 248 bool fIsPathRendering; |
243 | 249 |
244 typedef GrProcessor INHERITED; | 250 typedef GrProcessor INHERITED; |
245 }; | 251 }; |
246 | 252 |
247 #endif | 253 #endif |
OLD | NEW |