junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2011 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. |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 8 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 9 | #ifndef GrGLProgram_DEFINED |
| 10 | #define GrGLProgram_DEFINED |
| 11 | |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 12 | #include "GrDrawState.h" |
bsalomon@google.com | 9639994 | 2012-02-13 14:39:16 +0000 | [diff] [blame] | 13 | #include "GrGLContextInfo.h" |
tomhudson@google.com | 086e535 | 2011-12-08 14:44:10 +0000 | [diff] [blame] | 14 | #include "GrGLSL.h" |
bsalomon@google.com | 890e3b5 | 2012-06-01 19:01:37 +0000 | [diff] [blame] | 15 | #include "GrGLTexture.h" |
bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 16 | #include "GrGLUniformManager.h" |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 17 | |
bsalomon@google.com | f0a104e | 2012-07-10 17:51:07 +0000 | [diff] [blame] | 18 | #include "SkString.h" |
Scroggo | 97c88c2 | 2011-05-11 14:05:25 +0000 | [diff] [blame] | 19 | #include "SkXfermode.h" |
| 20 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 21 | class GrBinHashKeyBuilder; |
tomhudson@google.com | 07eecdc | 2012-04-20 18:35:38 +0000 | [diff] [blame] | 22 | class GrGLProgramStage; |
tomhudson@google.com | f9ad886 | 2012-05-11 20:38:48 +0000 | [diff] [blame] | 23 | class GrGLShaderBuilder; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 24 | |
bsalomon@google.com | edfe1aa | 2011-09-29 14:40:26 +0000 | [diff] [blame] | 25 | // optionally compile the experimental GS code. Set to GR_DEBUG |
| 26 | // so that debug build bots will execute the code. |
| 27 | #define GR_GL_EXPERIMENTAL_GS GR_DEBUG |
| 28 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 29 | /** |
| 30 | * This class manages a GPU program and records per-program information. |
| 31 | * We can specify the attribute locations so that they are constant |
| 32 | * across our shaders. But the driver determines the uniform locations |
| 33 | * at link time. We don't need to remember the sampler uniform location |
| 34 | * because we will bind a texture slot to it and never change it |
| 35 | * Uniforms are program-local so we can't rely on fHWState to hold the |
| 36 | * previous uniform state after a program change. |
| 37 | */ |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 38 | class GrGLProgram : public GrRefCnt { |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 39 | public: |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 40 | SK_DECLARE_INST_COUNT(GrGLProgram) |
bsalomon@google.com | 4fa6694 | 2011-09-20 19:06:12 +0000 | [diff] [blame] | 41 | |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 42 | struct Desc; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 43 | |
bsalomon@google.com | ecb60aa | 2012-07-18 13:20:29 +0000 | [diff] [blame] | 44 | static GrGLProgram* Create(const GrGLContextInfo& gl, |
| 45 | const Desc& desc, |
bsalomon@google.com | cddaf34 | 2012-07-30 13:09:05 +0000 | [diff] [blame] | 46 | const GrCustomStage** customStages); |
bsalomon@google.com | ecb60aa | 2012-07-18 13:20:29 +0000 | [diff] [blame] | 47 | |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 48 | virtual ~GrGLProgram(); |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 49 | |
bsalomon@google.com | ecb60aa | 2012-07-18 13:20:29 +0000 | [diff] [blame] | 50 | /** Call to abandon GL objects owned by this program */ |
| 51 | void abandon(); |
| 52 | |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 53 | /** |
bsalomon@google.com | 4285acc | 2012-10-22 14:11:24 +0000 | [diff] [blame] | 54 | * The shader may modify the blend coefficients. Params are in/out |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 55 | */ |
bsalomon@google.com | ecb60aa | 2012-07-18 13:20:29 +0000 | [diff] [blame] | 56 | void overrideBlend(GrBlendCoeff* srcCoeff, GrBlendCoeff* dstCoeff) const; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 57 | |
bsalomon@google.com | ecb60aa | 2012-07-18 13:20:29 +0000 | [diff] [blame] | 58 | const Desc& getDesc() { return fDesc; } |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 59 | |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 60 | /** |
bsalomon@google.com | 28f6ab4 | 2012-10-23 14:21:11 +0000 | [diff] [blame] | 61 | * Attribute indices. These should not overlap. |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 62 | */ |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 63 | static int PositionAttributeIdx() { return 0; } |
bsalomon@google.com | 28f6ab4 | 2012-10-23 14:21:11 +0000 | [diff] [blame] | 64 | static int ColorAttributeIdx() { return 1; } |
| 65 | static int CoverageAttributeIdx() { return 2; } |
| 66 | static int EdgeAttributeIdx() { return 3; } |
| 67 | static int TexCoordAttributeIdx(int tcIdx) { return 4 + tcIdx; } |
bsalomon@google.com | aeb2160 | 2011-08-30 18:13:44 +0000 | [diff] [blame] | 68 | |
bsalomon@google.com | 4285acc | 2012-10-22 14:11:24 +0000 | [diff] [blame] | 69 | /** |
| 70 | * This function uploads uniforms and calls each GrCustomStage's setData. It is called before a |
| 71 | * draw occurs using the program after the program has already been bound. |
| 72 | */ |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame^] | 73 | void setData(const GrDrawState& drawState); |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 74 | |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 75 | // Parameters that affect code generation |
| 76 | // These structs should be kept compact; they are the input to an |
| 77 | // expensive hash key generator. |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 78 | struct Desc { |
| 79 | Desc() { |
bsalomon@google.com | 4285acc | 2012-10-22 14:11:24 +0000 | [diff] [blame] | 80 | // since we use this as part of a key we can't have any uninitialized |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 81 | // padding |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 82 | memset(this, 0, sizeof(Desc)); |
| 83 | } |
| 84 | |
| 85 | // returns this as a uint32_t array to be used as a key in the program cache |
| 86 | const uint32_t* asKey() const { |
| 87 | return reinterpret_cast<const uint32_t*>(this); |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 88 | } |
| 89 | |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 90 | struct StageDesc { |
| 91 | enum OptFlagBits { |
| 92 | kNoPerspective_OptFlagBit = 1 << 0, |
| 93 | kIdentityMatrix_OptFlagBit = 1 << 1, |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 94 | kIsEnabled_OptFlagBit = 1 << 7 |
| 95 | }; |
bsalomon@google.com | b505a12 | 2012-05-31 18:40:36 +0000 | [diff] [blame] | 96 | |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 97 | uint8_t fOptFlags; |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 98 | |
tomhudson@google.com | 07eecdc | 2012-04-20 18:35:38 +0000 | [diff] [blame] | 99 | /** Non-zero if user-supplied code will write the stage's |
| 100 | contribution to the fragment shader. */ |
twiz@google.com | a5e65ec | 2012-08-02 15:15:16 +0000 | [diff] [blame] | 101 | GrProgramStageFactory::StageKey fCustomStageKey; |
tomhudson@google.com | 07eecdc | 2012-04-20 18:35:38 +0000 | [diff] [blame] | 102 | |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 103 | inline bool isEnabled() const { |
bsalomon@google.com | c2c9b97 | 2011-10-03 13:17:22 +0000 | [diff] [blame] | 104 | return SkToBool(fOptFlags & kIsEnabled_OptFlagBit); |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 105 | } |
| 106 | inline void setEnabled(bool newValue) { |
| 107 | if (newValue) { |
| 108 | fOptFlags |= kIsEnabled_OptFlagBit; |
| 109 | } else { |
| 110 | fOptFlags &= ~kIsEnabled_OptFlagBit; |
| 111 | } |
| 112 | } |
| 113 | }; |
| 114 | |
bsalomon@google.com | 4285acc | 2012-10-22 14:11:24 +0000 | [diff] [blame] | 115 | // Specifies where the initial color comes from before the stages are applied. |
bsalomon@google.com | 85b505b | 2011-11-07 14:56:51 +0000 | [diff] [blame] | 116 | enum ColorInput { |
| 117 | kSolidWhite_ColorInput, |
| 118 | kTransBlack_ColorInput, |
| 119 | kAttribute_ColorInput, |
| 120 | kUniform_ColorInput, |
bsalomon@google.com | 86c1f71 | 2011-10-12 14:54:26 +0000 | [diff] [blame] | 121 | |
bsalomon@google.com | 85b505b | 2011-11-07 14:56:51 +0000 | [diff] [blame] | 122 | kColorInputCnt |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 123 | }; |
| 124 | // Dual-src blending makes use of a secondary output color that can be |
bsalomon@google.com | 4285acc | 2012-10-22 14:11:24 +0000 | [diff] [blame] | 125 | // used as a per-pixel blend coefficient. This controls whether a |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 126 | // secondary source is output and what value it holds. |
| 127 | enum DualSrcOutput { |
| 128 | kNone_DualSrcOutput, |
| 129 | kCoverage_DualSrcOutput, |
| 130 | kCoverageISA_DualSrcOutput, |
| 131 | kCoverageISC_DualSrcOutput, |
bsalomon@google.com | 1e257a5 | 2011-07-06 19:52:16 +0000 | [diff] [blame] | 132 | |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 133 | kDualSrcOutputCnt |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 134 | }; |
bsalomon@google.com | 271cffc | 2011-05-20 14:13:56 +0000 | [diff] [blame] | 135 | |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 136 | GrDrawState::VertexEdgeType fVertexEdgeType; |
bsalomon@google.com | aeb2160 | 2011-08-30 18:13:44 +0000 | [diff] [blame] | 137 | |
bsalomon@google.com | 4285acc | 2012-10-22 14:11:24 +0000 | [diff] [blame] | 138 | // stripped of bits that don't affect program generation |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 139 | GrVertexLayout fVertexLayout; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 140 | |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 141 | StageDesc fStages[GrDrawState::kNumStages]; |
Scroggo | 97c88c2 | 2011-05-11 14:05:25 +0000 | [diff] [blame] | 142 | |
bsalomon@google.com | edfe1aa | 2011-09-29 14:40:26 +0000 | [diff] [blame] | 143 | // To enable experimental geometry shader code (not for use in |
| 144 | // production) |
| 145 | #if GR_GL_EXPERIMENTAL_GS |
| 146 | bool fExperimentalGS; |
| 147 | #endif |
| 148 | |
bsalomon@google.com | 85b505b | 2011-11-07 14:56:51 +0000 | [diff] [blame] | 149 | uint8_t fColorInput; // casts to enum ColorInput |
bsalomon@google.com | 2401ae8 | 2012-01-17 21:03:05 +0000 | [diff] [blame] | 150 | uint8_t fCoverageInput; // casts to enum CoverageInput |
bsalomon@google.com | 85b505b | 2011-11-07 14:56:51 +0000 | [diff] [blame] | 151 | uint8_t fDualSrcOutput; // casts to enum DualSrcOutput |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 152 | int8_t fFirstCoverageStage; |
| 153 | SkBool8 fEmitsPointSize; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 154 | |
tomhudson@google.com | 0d83172 | 2011-06-02 15:37:14 +0000 | [diff] [blame] | 155 | uint8_t fColorFilterXfermode; // casts to enum SkXfermode::Mode |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 156 | }; |
| 157 | GR_STATIC_ASSERT(!(sizeof(Desc) % 4)); |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 158 | |
bsalomon@google.com | 22c5dea | 2011-07-07 14:38:03 +0000 | [diff] [blame] | 159 | // for code readability |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 160 | typedef Desc::StageDesc StageDesc; |
bsalomon@google.com | 22c5dea | 2011-07-07 14:38:03 +0000 | [diff] [blame] | 161 | |
tomhudson@google.com | 2a2e3ef | 2011-10-25 19:51:09 +0000 | [diff] [blame] | 162 | private: |
bsalomon@google.com | f06df1b | 2012-09-06 20:22:31 +0000 | [diff] [blame] | 163 | struct StageUniforms; |
| 164 | |
bsalomon@google.com | ecb60aa | 2012-07-18 13:20:29 +0000 | [diff] [blame] | 165 | GrGLProgram(const GrGLContextInfo& gl, |
| 166 | const Desc& desc, |
bsalomon@google.com | cddaf34 | 2012-07-30 13:09:05 +0000 | [diff] [blame] | 167 | const GrCustomStage** customStages); |
bsalomon@google.com | ecb60aa | 2012-07-18 13:20:29 +0000 | [diff] [blame] | 168 | |
| 169 | bool succeeded() const { return 0 != fProgramID; } |
| 170 | |
| 171 | /** |
bsalomon@google.com | 4285acc | 2012-10-22 14:11:24 +0000 | [diff] [blame] | 172 | * This is the heavy initialization routine for building a GLProgram. |
bsalomon@google.com | ecb60aa | 2012-07-18 13:20:29 +0000 | [diff] [blame] | 173 | */ |
bsalomon@google.com | cddaf34 | 2012-07-30 13:09:05 +0000 | [diff] [blame] | 174 | bool genProgram(const GrCustomStage** customStages); |
bsalomon@google.com | ecb60aa | 2012-07-18 13:20:29 +0000 | [diff] [blame] | 175 | |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 176 | void genInputColor(GrGLShaderBuilder* builder, SkString* inColor); |
tomhudson@google.com | 2a2e3ef | 2011-10-25 19:51:09 +0000 | [diff] [blame] | 177 | |
bsalomon@google.com | f06df1b | 2012-09-06 20:22:31 +0000 | [diff] [blame] | 178 | static GrGLProgramStage* GenStageCode(const GrCustomStage* stage, |
| 179 | const StageDesc& desc, // TODO: Eliminate this |
| 180 | StageUniforms* stageUniforms, // TODO: Eliminate this |
| 181 | const char* fsInColor, // NULL means no incoming color |
| 182 | const char* fsOutColor, |
| 183 | const char* vsInCoord, |
| 184 | GrGLShaderBuilder* builder); |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 185 | |
bsalomon@google.com | ecb60aa | 2012-07-18 13:20:29 +0000 | [diff] [blame] | 186 | void genGeometryShader(GrGLShaderBuilder* segments) const; |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 187 | |
bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 188 | typedef GrGLUniformManager::UniformHandle UniformHandle; |
| 189 | |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 190 | void genUniformCoverage(GrGLShaderBuilder* segments, SkString* inOutCoverage); |
| 191 | |
bsalomon@google.com | d472620 | 2012-08-03 14:34:46 +0000 | [diff] [blame] | 192 | // generates code to compute coverage based on edge AA. Returns true if edge coverage was |
| 193 | // inserted in which case coverageVar will be updated to refer to a scalar. Otherwise, |
| 194 | // coverageVar is set to an empty string. |
| 195 | bool genEdgeCoverage(SkString* coverageVar, GrGLShaderBuilder* builder) const; |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 196 | |
| 197 | // Creates a GL program ID, binds shader attributes to GL vertex attrs, and links the program |
bsalomon@google.com | ecb60aa | 2012-07-18 13:20:29 +0000 | [diff] [blame] | 198 | bool bindOutputsAttribsAndLinkProgram(SkString texCoordAttrNames[GrDrawState::kMaxTexCoords], |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 199 | bool bindColorOut, |
| 200 | bool bindDualSrcOut); |
| 201 | |
bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 202 | // Sets the texture units for samplers |
| 203 | void initSamplerUniforms(); |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 204 | |
bsalomon@google.com | ecb60aa | 2012-07-18 13:20:29 +0000 | [diff] [blame] | 205 | bool compileShaders(const GrGLShaderBuilder& builder); |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 206 | |
bsalomon@google.com | f0a104e | 2012-07-10 17:51:07 +0000 | [diff] [blame] | 207 | const char* adjustInColor(const SkString& inColor) const; |
tomhudson@google.com | 2a2e3ef | 2011-10-25 19:51:09 +0000 | [diff] [blame] | 208 | |
bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 209 | struct StageUniforms { |
| 210 | UniformHandle fTextureMatrixUni; |
bsalomon@google.com | 0982d35 | 2012-07-31 15:33:25 +0000 | [diff] [blame] | 211 | SkTArray<UniformHandle, true> fSamplerUniforms; |
bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 212 | StageUniforms() { |
| 213 | fTextureMatrixUni = GrGLUniformManager::kInvalidUniformHandle; |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 214 | } |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 215 | }; |
| 216 | |
bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 217 | struct Uniforms { |
| 218 | UniformHandle fViewMatrixUni; |
| 219 | UniformHandle fColorUni; |
| 220 | UniformHandle fCoverageUni; |
| 221 | UniformHandle fColorFilterUni; |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame^] | 222 | // We use the render target height to provide a y-down frag coord when specifying |
| 223 | // origin_upper_left is not supported. |
| 224 | UniformHandle fRTHeight; |
bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 225 | StageUniforms fStages[GrDrawState::kNumStages]; |
| 226 | Uniforms() { |
| 227 | fViewMatrixUni = GrGLUniformManager::kInvalidUniformHandle; |
| 228 | fColorUni = GrGLUniformManager::kInvalidUniformHandle; |
| 229 | fCoverageUni = GrGLUniformManager::kInvalidUniformHandle; |
| 230 | fColorFilterUni = GrGLUniformManager::kInvalidUniformHandle; |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame^] | 231 | fRTHeight = GrGLUniformManager::kInvalidUniformHandle; |
bsalomon@google.com | 9196130 | 2011-05-09 18:39:58 +0000 | [diff] [blame] | 232 | } |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 233 | }; |
| 234 | |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 235 | // IDs |
| 236 | GrGLuint fVShaderID; |
| 237 | GrGLuint fGShaderID; |
| 238 | GrGLuint fFShaderID; |
| 239 | GrGLuint fProgramID; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 240 | |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 241 | // The matrix sent to GL is determined by both the client's matrix and |
| 242 | // the size of the viewport. |
| 243 | GrMatrix fViewMatrix; |
| 244 | SkISize fViewportSize; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 245 | |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 246 | // these reflect the current values of uniforms |
| 247 | // (GL uniform values travel with program) |
| 248 | GrColor fColor; |
| 249 | GrColor fCoverage; |
| 250 | GrColor fColorFilterColor; |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame^] | 251 | int fRTHeight; |
tomhudson@google.com | 2f68e76 | 2012-07-17 18:43:21 +0000 | [diff] [blame] | 252 | /// When it is sent to GL, the texture matrix will be flipped if the texture orientation |
| 253 | /// (below) requires. |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 254 | GrMatrix fTextureMatrices[GrDrawState::kNumStages]; |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 255 | GrGLTexture::Orientation fTextureOrientation[GrDrawState::kNumStages]; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 256 | |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 257 | GrGLProgramStage* fProgramStage[GrDrawState::kNumStages]; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 258 | |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 259 | Desc fDesc; |
bsalomon@google.com | ecb60aa | 2012-07-18 13:20:29 +0000 | [diff] [blame] | 260 | const GrGLContextInfo& fContextInfo; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 261 | |
bsalomon@google.com | dbbc4e2 | 2012-07-25 17:48:39 +0000 | [diff] [blame] | 262 | GrGLUniformManager fUniformManager; |
| 263 | Uniforms fUniforms; |
| 264 | |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 265 | friend class GrGpuGL; // TODO: remove this by adding getters and moving functionality. |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 266 | |
bsalomon@google.com | 9ba4fa6 | 2012-07-16 17:36:28 +0000 | [diff] [blame] | 267 | typedef GrRefCnt INHERITED; |
junov@google.com | f93e717 | 2011-03-31 21:26:24 +0000 | [diff] [blame] | 268 | }; |
| 269 | |
| 270 | #endif |