 Chromium Code Reviews
 Chromium Code Reviews Issue 12942014:
  Move GrGLProgram::Desc out of GrGLProgram.  (Closed) 
  Base URL: http://skia.googlecode.com/svn/trunk/
    
  
    Issue 12942014:
  Move GrGLProgram::Desc out of GrGLProgram.  (Closed) 
  Base URL: http://skia.googlecode.com/svn/trunk/| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2013 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #ifndef GrGLProgramDesc_DEFINED | |
| 9 #define GrGLProgramDesc_DEFINED | |
| 10 | |
| 11 #include "GrGLEffect.h" | |
| 12 | |
| 13 class GrGpuGL; | |
| 14 | |
| 15 // optionally compile the experimental GS code. Set to GR_DEBUG so that debug bu ild bots will | |
| 16 // execute the code. | |
| 17 #define GR_GL_EXPERIMENTAL_GS GR_DEBUG | |
| 18 | |
| 19 | |
| 20 /** This class describes a program to generate. It also serves as a program cach e key. The only | |
| 21 thing GL-specific about this is the generation of GrGLEffect::EffectKeys. Wi th some refactoring | |
| 22 it could be made backend-neutral. */ | |
| 23 class GrGLProgramDesc { | |
| 24 public: | |
| 25 GrGLProgramDesc() { | |
| 26 // since we use this as part of a key we can't have any uninitialized pa dding | |
| 27 memset(this, 0, sizeof(GrGLProgramDesc)); | |
| 28 } | |
| 29 | |
| 30 // Returns this as a uint32_t array to be used as a key in the program cache | |
| 31 const uint32_t* asKey() const { | |
| 32 return reinterpret_cast<const uint32_t*>(this); | |
| 33 } | |
| 34 | |
| 35 // For unit testing. | |
| 36 void setRandom(SkMWCRandom*, | |
| 
robertphillips
2013/03/27 18:07:10
spaces
 
bsalomon
2013/03/27 18:17:16
Done.
 | |
| 37 const GrGpuGL* gpu, | |
| 38 const GrEffectStage stages[GrDrawState::kNumStages]); | |
| 39 | |
| 40 /** | |
| 41 * Builds a program descriptor from a GrDrawState. Whether the primitive typ e is points, the | |
| 42 * output of GrDrawState::getBlendOpts, and the caps of the GrGpuGL are also inputs. | |
| 43 */ | |
| 44 static void Build(const GrDrawState&, | |
| 45 bool isPoints, | |
| 46 GrDrawState::BlendOptFlags, | |
| 47 GrBlendCoeff srcCoeff, | |
| 48 GrBlendCoeff dstCoeff, | |
| 49 const GrGpuGL* gpu, | |
| 50 GrGLProgramDesc* outDesc); | |
| 51 | |
| 52 private: | |
| 53 // Specifies where the initial color comes from before the stages are applie d. | |
| 54 enum ColorInput { | |
| 55 kSolidWhite_ColorInput, | |
| 56 kTransBlack_ColorInput, | |
| 57 kAttribute_ColorInput, | |
| 58 kUniform_ColorInput, | |
| 59 | |
| 60 kColorInputCnt | |
| 61 }; | |
| 62 // Dual-src blending makes use of a secondary output color that can be | |
| 63 // used as a per-pixel blend coefficient. This controls whether a | |
| 64 // secondary source is output and what value it holds. | |
| 65 enum DualSrcOutput { | |
| 66 kNone_DualSrcOutput, | |
| 67 kCoverage_DualSrcOutput, | |
| 68 kCoverageISA_DualSrcOutput, | |
| 69 kCoverageISC_DualSrcOutput, | |
| 70 | |
| 71 kDualSrcOutputCnt | |
| 72 }; | |
| 73 | |
| 74 // should the FS discard if the coverage is zero (to avoid stencil manipulat ion) | |
| 75 bool fDiscardIfZeroCoverage; | |
| 76 | |
| 77 // stripped of bits that don't affect program generation | |
| 78 GrAttribBindings fAttribBindings; | |
| 79 | |
| 80 /** Non-zero if this stage has an effect */ | |
| 81 GrGLEffect::EffectKey fEffectKeys[GrDrawState::kNumStages]; | |
| 82 | |
| 83 // To enable experimental geometry shader code (not for use in | |
| 84 // production) | |
| 85 #if GR_GL_EXPERIMENTAL_GS | |
| 86 bool fExperimentalGS; | |
| 87 #endif | |
| 88 uint8_t fColorInput; // casts to enum ColorIn put | |
| 89 uint8_t fCoverageInput; // casts to enum ColorIn put | |
| 90 uint8_t fDualSrcOutput; // casts to enum DualSrc Output | |
| 91 int8_t fFirstCoverageStage; | |
| 92 SkBool8 fEmitsPointSize; | |
| 93 uint8_t fColorFilterXfermode; // casts to enum SkXferm ode::Mode | |
| 94 | |
| 95 int8_t fPositionAttributeIndex; | |
| 96 int8_t fColorAttributeIndex; | |
| 97 int8_t fCoverageAttributeIndex; | |
| 98 int8_t fLocalCoordsAttributeIndex; | |
| 99 | |
| 100 // GrGLProgram reads the private fields to generate code. | |
| 101 friend class GrGLProgram; | |
| 102 }; | |
| 103 | |
| 104 #endif | |
| OLD | NEW |