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

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

Issue 560443004: Revert of Attach GrOptDrawState into shader building pipeline (Closed) Base URL: https://skia.googlesource.com/skia.git@opt2
Patch Set: Created 6 years, 3 months 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 | « src/gpu/GrOptDrawState.cpp ('k') | src/gpu/GrRODrawState.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 2014 Google Inc. 2 * Copyright 2014 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 GrRODrawState_DEFINED 8 #ifndef GrRODrawState_DEFINED
9 #define GrRODrawState_DEFINED 9 #define GrRODrawState_DEFINED
10 10
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 *dstBlendCoeff = fDstBlend; 160 *dstBlendCoeff = fDstBlend;
161 } 161 }
162 162
163 /** 163 /**
164 * Retrieves the last value set by setBlendConstant() 164 * Retrieves the last value set by setBlendConstant()
165 * @return the blending constant value 165 * @return the blending constant value
166 */ 166 */
167 GrColor getBlendConstant() const { return fBlendConstant; } 167 GrColor getBlendConstant() const { return fBlendConstant; }
168 168
169 /** 169 /**
170 * We don't use supplied vertex color attributes if our blend mode is EmitCo verage or
171 * EmitTransBlack
172 */
173 bool canIgnoreColorAttribute() const;
174
175 /**
170 * Determines whether multiplying the computed per-pixel color by the pixel' s fractional 176 * Determines whether multiplying the computed per-pixel color by the pixel' s fractional
171 * coverage before the blend will give the correct final destination color. In general it 177 * coverage before the blend will give the correct final destination color. In general it
172 * will not as coverage is applied after blending. 178 * will not as coverage is applied after blending.
173 */ 179 */
174 bool canTweakAlphaForCoverage() const; 180 bool canTweakAlphaForCoverage() const;
175 181
182 /**
183 * Optimizations for blending / coverage to that can be applied based on the current state.
184 */
185 enum BlendOptFlags {
186 /**
187 * No optimization
188 */
189 kNone_BlendOpt = 0,
190 /**
191 * Don't draw at all
192 */
193 kSkipDraw_BlendOptFlag = 0x1,
194 /**
195 * The coverage value does not have to be computed separately from alpha , the output
196 * color can be the modulation of the two.
197 */
198 kCoverageAsAlpha_BlendOptFlag = 0x2,
199 /**
200 * Instead of emitting a src color, emit coverage in the alpha channel a nd r,g,b are
201 * "don't cares".
202 */
203 kEmitCoverage_BlendOptFlag = 0x4,
204 /**
205 * Emit transparent black instead of the src color, no need to compute c overage.
206 */
207 kEmitTransBlack_BlendOptFlag = 0x8,
208 /**
209 * Flag used to invalidate the cached BlendOptFlags, OptSrcCoeff, and Op tDstCoeff cached by
210 * the get BlendOpts function.
211 */
212 kInvalid_BlendOptFlag = 1 << 31,
213 };
214 GR_DECL_BITFIELD_OPS_FRIENDS(BlendOptFlags);
215
216 /**
217 * Determines what optimizations can be applied based on the blend. The coef ficients may have
218 * to be tweaked in order for the optimization to work. srcCoeff and dstCoef f are optional
219 * params that receive the tweaked coefficients. Normally the function looks at the current
220 * state to see if coverage is enabled. By setting forceCoverage the caller can speculatively
221 * determine the blend optimizations that would be used if there was partial pixel coverage.
222 *
223 * Subclasses of GrDrawTarget that actually draw (as opposed to those that j ust buffer for
224 * playback) must call this function and respect the flags that replace the output color.
225 *
226 * If the cached BlendOptFlags does not have the invalidate bit set, then ge tBlendOpts will
227 * simply returned the cached flags and coefficients. Otherwise it will calc ulate the values.
228 */
229 BlendOptFlags getBlendOpts(bool forceCoverage = false,
230 GrBlendCoeff* srcCoeff = NULL,
231 GrBlendCoeff* dstCoeff = NULL) const;
176 /// @} 232 /// @}
177 233
178 /////////////////////////////////////////////////////////////////////////// 234 ///////////////////////////////////////////////////////////////////////////
179 /// @name View Matrix 235 /// @name View Matrix
180 //// 236 ////
181 237
182 /** 238 /**
183 * Retrieves the current view matrix 239 * Retrieves the current view matrix
184 * @return the current view matrix. 240 * @return the current view matrix.
185 */ 241 */
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 * an optimized draw state. 400 * an optimized draw state.
345 */ 401 */
346 void convertToPendingExec(); 402 void convertToPendingExec();
347 403
348 friend class GrDrawTarget; 404 friend class GrDrawTarget;
349 405
350 explicit GrRODrawState(const GrRODrawState& drawState); 406 explicit GrRODrawState(const GrRODrawState& drawState);
351 407
352 bool isEqual(const GrRODrawState& that) const; 408 bool isEqual(const GrRODrawState& that) const;
353 409
354 /**
355 * Optimizations for blending / coverage to that can be applied based on the current state.
356 */
357 enum BlendOptFlags {
358 /**
359 * No optimization
360 */
361 kNone_BlendOpt = 0,
362 /**
363 * Don't draw at all
364 */
365 kSkipDraw_BlendOptFlag = 0x1,
366 /**
367 * The coverage value does not have to be computed separately from alpha , the the output
368 * color can be the modulation of the two.
369 */
370 kCoverageAsAlpha_BlendOptFlag = 0x2,
371 /**
372 * Instead of emitting a src color, emit coverage in the alpha channel a nd r,g,b are
373 * "don't cares".
374 */
375 kEmitCoverage_BlendOptFlag = 0x4,
376 /**
377 * Emit transparent black instead of the src color, no need to compute c overage.
378 */
379 kEmitTransBlack_BlendOptFlag = 0x8,
380 };
381 GR_DECL_BITFIELD_OPS_FRIENDS(BlendOptFlags);
382
383 /**
384 * Determines what optimizations can be applied based on the blend. The coef ficients may have
385 * to be tweaked in order for the optimization to work. srcCoeff and dstCoef f are optional
386 * params that receive the tweaked coefficients. Normally the function looks at the current
387 * state to see if coverage is enabled. By setting forceCoverage the caller can speculatively
388 * determine the blend optimizations that would be used if there was partial pixel coverage.
389 *
390 * Subclasses of GrDrawTarget that actually draw (as opposed to those that j ust buffer for
391 * playback) must call this function and respect the flags that replace the output color.
392 *
393 * If the cached BlendOptFlags does not have the invalidate bit set, then ge tBlendOpts will
394 * simply returned the cached flags and coefficients. Otherwise it will calc ulate the values.
395 */
396 BlendOptFlags getBlendOpts(bool forceCoverage = false,
397 GrBlendCoeff* srcCoeff = NULL,
398 GrBlendCoeff* dstCoeff = NULL) const;
399
400 // These fields are roughly sorted by decreasing likelihood of being differe nt in op== 410 // These fields are roughly sorted by decreasing likelihood of being differe nt in op==
401 GrProgramResource fRenderTarget; 411 GrProgramResource fRenderTarget;
402 GrColor fColor; 412 GrColor fColor;
403 SkMatrix fViewMatrix; 413 SkMatrix fViewMatrix;
404 GrColor fBlendConstant; 414 GrColor fBlendConstant;
405 uint32_t fFlagBits; 415 uint32_t fFlagBits;
406 const GrVertexAttrib* fVAPtr; 416 const GrVertexAttrib* fVAPtr;
407 int fVACount; 417 int fVACount;
408 size_t fVAStride; 418 size_t fVAStride;
409 GrStencilSettings fStencilSettings; 419 GrStencilSettings fStencilSettings;
410 uint8_t fCoverage; 420 uint8_t fCoverage;
411 DrawFace fDrawFace; 421 DrawFace fDrawFace;
412 GrBlendCoeff fSrcBlend; 422 GrBlendCoeff fSrcBlend;
413 GrBlendCoeff fDstBlend; 423 GrBlendCoeff fDstBlend;
414 424
415 typedef SkSTArray<4, GrEffectStage> EffectStageArray; 425 typedef SkSTArray<4, GrEffectStage> EffectStageArray;
416 SkAutoTDelete<GrEffectStage> fGeometryProcessor; 426 SkAutoTDelete<GrEffectStage> fGeometryProcessor;
417 EffectStageArray fColorStages; 427 EffectStageArray fColorStages;
418 EffectStageArray fCoverageStages; 428 EffectStageArray fCoverageStages;
419 429
420 uint32_t fHints; 430 uint32_t fHints;
421 431
432 mutable GrBlendCoeff fOptSrcBlend;
433 mutable GrBlendCoeff fOptDstBlend;
434 mutable BlendOptFlags fBlendOptFlags;
435
422 // This is simply a different representation of info in fVertexAttribs and t hus does 436 // This is simply a different representation of info in fVertexAttribs and t hus does
423 // not need to be compared in op==. 437 // not need to be compared in op==.
424 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt ]; 438 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt ];
425 439
426 private: 440 private:
427 /** 441 /**
428 * Determines whether src alpha is guaranteed to be one for all src pixels 442 * Determines whether src alpha is guaranteed to be one for all src pixels
429 */ 443 */
430 bool srcAlphaWillBeOne() const; 444 bool srcAlphaWillBeOne() const;
431 445
446 /**
447 * Helper function for getBlendOpts.
448 */
449 BlendOptFlags calcBlendOpts(bool forceCoverage = false,
450 GrBlendCoeff* srcCoeff = NULL,
451 GrBlendCoeff* dstCoeff = NULL) const;
452
432 typedef SkRefCnt INHERITED; 453 typedef SkRefCnt INHERITED;
433 }; 454 };
434 455
435 GR_MAKE_BITFIELD_OPS(GrRODrawState::BlendOptFlags); 456 GR_MAKE_BITFIELD_OPS(GrRODrawState::BlendOptFlags);
436 457
437 #endif 458 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrOptDrawState.cpp ('k') | src/gpu/GrRODrawState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698