Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: src/gpu/GrDrawState.h

Issue 719203002: Add GrProcOptInfo class to track various output information for color and coverage stages. (Closed) Base URL: https://skia.googlesource.com/skia.git@moveIO
Patch Set: initialize values Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/gpu/GrInvariantOutput.h ('k') | src/gpu/GrDrawState.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 GrDrawState_DEFINED 8 #ifndef GrDrawState_DEFINED
9 #define GrDrawState_DEFINED 9 #define GrDrawState_DEFINED
10 10
11 11
12 #include "GrBlend.h" 12 #include "GrBlend.h"
13 #include "GrDrawTargetCaps.h" 13 #include "GrDrawTargetCaps.h"
14 #include "GrGeometryProcessor.h" 14 #include "GrGeometryProcessor.h"
15 #include "GrGpuResourceRef.h" 15 #include "GrGpuResourceRef.h"
16 #include "GrProcessorStage.h" 16 #include "GrProcessorStage.h"
17 #include "GrProcOptInfo.h"
17 #include "GrRenderTarget.h" 18 #include "GrRenderTarget.h"
18 #include "GrStencil.h" 19 #include "GrStencil.h"
19 #include "SkMatrix.h" 20 #include "SkMatrix.h"
20 #include "effects/GrSimpleTextureEffect.h" 21 #include "effects/GrSimpleTextureEffect.h"
21 22
22 class GrDrawTargetCaps; 23 class GrDrawTargetCaps;
23 class GrOptDrawState; 24 class GrOptDrawState;
24 class GrPaint; 25 class GrPaint;
25 class GrTexture; 26 class GrTexture;
26 27
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 GrColor getColor() const { return fColor; } 175 GrColor getColor() const { return fColor; }
175 176
176 /** 177 /**
177 * Sets color for next draw to a premultiplied-alpha color. 178 * Sets color for next draw to a premultiplied-alpha color.
178 * 179 *
179 * @param color the color to set. 180 * @param color the color to set.
180 */ 181 */
181 void setColor(GrColor color) { 182 void setColor(GrColor color) {
182 if (color != fColor) { 183 if (color != fColor) {
183 fColor = color; 184 fColor = color;
185 fColorProcInfoValid = false;
184 } 186 }
185 } 187 }
186 188
187 /** 189 /**
188 * Sets the color to be used for the next draw to be 190 * Sets the color to be used for the next draw to be
189 * (r,g,b,a) = (alpha, alpha, alpha, alpha). 191 * (r,g,b,a) = (alpha, alpha, alpha, alpha).
190 * 192 *
191 * @param alpha The alpha value to set as the color. 193 * @param alpha The alpha value to set as the color.
192 */ 194 */
193 void setAlpha(uint8_t a) { this->setColor((a << 24) | (a << 16) | (a << 8) | a); } 195 void setAlpha(uint8_t a) { this->setColor((a << 24) | (a << 16) | (a << 8) | a); }
(...skipping 11 matching lines...) Expand all
205 } 207 }
206 208
207 /** 209 /**
208 * Sets a constant fractional coverage to be applied to the draw. The 210 * Sets a constant fractional coverage to be applied to the draw. The
209 * initial value (after construction or reset()) is 0xff. The constant 211 * initial value (after construction or reset()) is 0xff. The constant
210 * coverage is ignored when per-vertex coverage is provided. 212 * coverage is ignored when per-vertex coverage is provided.
211 */ 213 */
212 void setCoverage(uint8_t coverage) { 214 void setCoverage(uint8_t coverage) {
213 if (coverage != fCoverage) { 215 if (coverage != fCoverage) {
214 fCoverage = coverage; 216 fCoverage = coverage;
217 fCoverageProcInfoValid = false;
215 } 218 }
216 } 219 }
217 220
218 /// @} 221 /// @}
219 222
220 /** 223 /**
221 * The geometry processor is the sole element of the skia pipeline which can use the vertex, 224 * The geometry processor is the sole element of the skia pipeline which can use the vertex,
222 * geometry, and tesselation shaders. The GP may also compute a coverage in its fragment shader 225 * geometry, and tesselation shaders. The GP may also compute a coverage in its fragment shader
223 * but is never put in the color processing pipeline. 226 * but is never put in the color processing pipeline.
224 */ 227 */
225 228
226 const GrGeometryProcessor* setGeometryProcessor(const GrGeometryProcessor* g eometryProcessor) { 229 const GrGeometryProcessor* setGeometryProcessor(const GrGeometryProcessor* g eometryProcessor) {
227 SkASSERT(geometryProcessor); 230 SkASSERT(geometryProcessor);
228 SkASSERT(!this->hasGeometryProcessor()); 231 SkASSERT(!this->hasGeometryProcessor());
229 fGeometryProcessor.reset(SkRef(geometryProcessor)); 232 fGeometryProcessor.reset(SkRef(geometryProcessor));
233 fCoverageProcInfoValid = false;
230 return geometryProcessor; 234 return geometryProcessor;
231 } 235 }
232 236
233 /////////////////////////////////////////////////////////////////////////// 237 ///////////////////////////////////////////////////////////////////////////
234 /// @name Effect Stages 238 /// @name Effect Stages
235 /// Each stage hosts a GrProcessor. The effect produces an output color or c overage in the 239 /// Each stage hosts a GrProcessor. The effect produces an output color or c overage in the
236 /// fragment shader. Its inputs are the output from the previous stage as we ll as some variables 240 /// fragment shader. Its inputs are the output from the previous stage as we ll as some variables
237 /// available to it in the fragment and vertex shader (e.g. the vertex posit ion, the dst color, 241 /// available to it in the fragment and vertex shader (e.g. the vertex posit ion, the dst color,
238 /// the fragment position, local coordinates). 242 /// the fragment position, local coordinates).
239 /// 243 ///
(...skipping 23 matching lines...) Expand all
263 const GrFragmentStage& getCoverageStage(int idx) const { return fCoverageSta ges[idx]; } 267 const GrFragmentStage& getCoverageStage(int idx) const { return fCoverageSta ges[idx]; }
264 268
265 /** 269 /**
266 * Checks whether any of the effects will read the dst pixel color. 270 * Checks whether any of the effects will read the dst pixel color.
267 */ 271 */
268 bool willEffectReadDstColor() const; 272 bool willEffectReadDstColor() const;
269 273
270 const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* effe ct) { 274 const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* effe ct) {
271 SkASSERT(effect); 275 SkASSERT(effect);
272 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (effect)); 276 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (effect));
277 fColorProcInfoValid = false;
273 return effect; 278 return effect;
274 } 279 }
275 280
276 const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* e ffect) { 281 const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* e ffect) {
277 SkASSERT(effect); 282 SkASSERT(effect);
278 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (effect)); 283 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (effect));
284 fCoverageProcInfoValid = false;
279 return effect; 285 return effect;
280 } 286 }
281 287
282 /** 288 /**
283 * Creates a GrSimpleTextureEffect that uses local coords as texture coordin ates. 289 * Creates a GrSimpleTextureEffect that uses local coords as texture coordin ates.
284 */ 290 */
285 void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) { 291 void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
286 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))- >unref(); 292 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))- >unref();
287 } 293 }
288 294
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 */ 801 */
796 BlendOptFlags getBlendOpts(bool forceCoverage = false, 802 BlendOptFlags getBlendOpts(bool forceCoverage = false,
797 GrBlendCoeff* srcCoeff = NULL, 803 GrBlendCoeff* srcCoeff = NULL,
798 GrBlendCoeff* dstCoeff = NULL) const; 804 GrBlendCoeff* dstCoeff = NULL) const;
799 805
800 /** 806 /**
801 * Determines whether src alpha is guaranteed to be one for all src pixels 807 * Determines whether src alpha is guaranteed to be one for all src pixels
802 */ 808 */
803 bool srcAlphaWillBeOne() const; 809 bool srcAlphaWillBeOne() const;
804 810
811 /**
812 * If fColorProcInfoValid is false, function calculates the invariant output for the color
813 * stages and results are stored in fColorProcInfo.
814 */
815 void calcColorInvariantOutput() const;
816
817 /**
818 * If fCoverageProcInfoValid is false, function calculates the invariant out put for the coverage
819 * stages and results are stored in fCoverageProcInfo.
820 */
821 void calcCoverageInvariantOutput() const;
822
805 void onReset(const SkMatrix* initialViewMatrix); 823 void onReset(const SkMatrix* initialViewMatrix);
806 824
807 // Some of the auto restore objects assume that no effects are removed durin g their lifetime. 825 // Some of the auto restore objects assume that no effects are removed durin g their lifetime.
808 // This is used to assert that this condition holds. 826 // This is used to assert that this condition holds.
809 SkDEBUGCODE(int fBlockEffectRemovalCnt;) 827 SkDEBUGCODE(int fBlockEffectRemovalCnt;)
810 828
811 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz e_t stride); 829 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz e_t stride);
812 830
813 typedef GrTGpuResourceRef<GrRenderTarget> ProgramRenderTarget; 831 typedef GrTGpuResourceRef<GrRenderTarget> ProgramRenderTarget;
814 // These fields are roughly sorted by decreasing likelihood of being differe nt in op== 832 // These fields are roughly sorted by decreasing likelihood of being differe nt in op==
(...skipping 16 matching lines...) Expand all
831 ProgramGeometryProcessor fGeometryProcessor; 849 ProgramGeometryProcessor fGeometryProcessor;
832 FragmentStageArray fColorStages; 850 FragmentStageArray fColorStages;
833 FragmentStageArray fCoverageStages; 851 FragmentStageArray fCoverageStages;
834 852
835 uint32_t fHints; 853 uint32_t fHints;
836 854
837 // This is simply a different representation of info in fVertexAttribs and t hus does 855 // This is simply a different representation of info in fVertexAttribs and t hus does
838 // not need to be compared in op==. 856 // not need to be compared in op==.
839 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt ]; 857 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt ];
840 858
859 mutable GrProcOptInfo fColorProcInfo;
860 mutable GrProcOptInfo fCoverageProcInfo;
861 mutable bool fColorProcInfoValid;
862 mutable bool fCoverageProcInfoValid;
863
841 friend class GrOptDrawState; 864 friend class GrOptDrawState;
842 865
843 typedef SkRefCnt INHERITED; 866 typedef SkRefCnt INHERITED;
844 }; 867 };
845 868
846 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags); 869 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags);
847 870
848 #endif 871 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrInvariantOutput.h ('k') | src/gpu/GrDrawState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698