GrGLProgram.h revision dbe49f735484f8862e378b63d0a074a301093dd0
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/*
2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2011 Google Inc.
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com *
4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file.
6f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com */
7f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com
8ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
9f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com#ifndef GrGLProgram_DEFINED
10f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com#define GrGLProgram_DEFINED
11f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com
12d8f856c32b679d9f5a9926feac005e2c0186f83ftomhudson@google.com#include "GrDrawState.h"
13dbe49f735484f8862e378b63d0a074a301093dd0bsalomon@google.com#include "GrGLEffect.h"
1496399948dc2f1afd2e9d9e5be7d646c01d17f82bbsalomon@google.com#include "GrGLContextInfo.h"
15086e5354fe7ae60e69c42bdfbc3d03bd8559b44ftomhudson@google.com#include "GrGLSL.h"
16890e3b58e78c0825820f75f1f0c5a5d71e855aa6bsalomon@google.com#include "GrGLTexture.h"
17dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com#include "GrGLUniformManager.h"
18f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com
19f0a104e6f16dc095286d32f1e104894ae0b2b19fbsalomon@google.com#include "SkString.h"
2097c88c255cff3dbb8343c5d090526fdbedad6dd6Scroggo#include "SkXfermode.h"
2197c88c255cff3dbb8343c5d090526fdbedad6dd6Scroggo
22f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.comclass GrBinHashKeyBuilder;
23d698f77c13d97c61109b861eac4d25b14a5de935bsalomon@google.comclass GrGLEffect;
24f9ad8867f2bcd8563862b0a5a90b473ad020d465tomhudson@google.comclass GrGLShaderBuilder;
25f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com
26edfe1aac5c6f3a3f3830e86ddea8dbceeb0e6df4bsalomon@google.com// optionally compile the experimental GS code. Set to GR_DEBUG
27edfe1aac5c6f3a3f3830e86ddea8dbceeb0e6df4bsalomon@google.com// so that debug build bots will execute the code.
28edfe1aac5c6f3a3f3830e86ddea8dbceeb0e6df4bsalomon@google.com#define GR_GL_EXPERIMENTAL_GS GR_DEBUG
29edfe1aac5c6f3a3f3830e86ddea8dbceeb0e6df4bsalomon@google.com
30f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com/**
31f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com * This class manages a GPU program and records per-program information.
32f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com * We can specify the attribute locations so that they are constant
33f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com * across our shaders. But the driver determines the uniform locations
34f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com * at link time. We don't need to remember the sampler uniform location
35f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com * because we will bind a texture slot to it and never change it
36f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com * Uniforms are program-local so we can't rely on fHWState to hold the
37f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com * previous uniform state after a program change.
38f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com */
399ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.comclass GrGLProgram : public GrRefCnt {
40f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.compublic:
419ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    SK_DECLARE_INST_COUNT(GrGLProgram)
424fa6694c587b3830932429766c99d08c8dd9b723bsalomon@google.com
439ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    struct Desc;
44f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com
45ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com    static GrGLProgram* Create(const GrGLContextInfo& gl,
46ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com                               const Desc& desc,
472eaaefd7e6a58339b3f93333f1e9cc92252cc303bsalomon@google.com                               const GrEffectStage* stages[]);
48ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com
499ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    virtual ~GrGLProgram();
50f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com
51ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com    /** Call to abandon GL objects owned by this program */
52ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com    void abandon();
53ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com
54f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com    /**
554285accf5af574e6c826d5d09f0359c6149fd717bsalomon@google.com     * The shader may modify the blend coefficients. Params are in/out
56f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com     */
57ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com    void overrideBlend(GrBlendCoeff* srcCoeff, GrBlendCoeff* dstCoeff) const;
58f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com
59ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com    const Desc& getDesc() { return fDesc; }
609ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com
61271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com    /**
6228f6ab4b6e63c7d1d8d46cc6998f91fbb39bfef9bsalomon@google.com     * Attribute indices. These should not overlap.
63271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com     */
649196130af83782fcac4334117142475a837dd74dbsalomon@google.com    static int PositionAttributeIdx() { return 0; }
6528f6ab4b6e63c7d1d8d46cc6998f91fbb39bfef9bsalomon@google.com    static int ColorAttributeIdx() { return 1; }
6628f6ab4b6e63c7d1d8d46cc6998f91fbb39bfef9bsalomon@google.com    static int CoverageAttributeIdx() { return 2; }
6728f6ab4b6e63c7d1d8d46cc6998f91fbb39bfef9bsalomon@google.com    static int EdgeAttributeIdx() { return 3; }
6828f6ab4b6e63c7d1d8d46cc6998f91fbb39bfef9bsalomon@google.com    static int TexCoordAttributeIdx(int tcIdx) { return 4 + tcIdx; }
69aeb2160b1dd34f8e640e8e56544fe407d4ff6311bsalomon@google.com
704285accf5af574e6c826d5d09f0359c6149fd717bsalomon@google.com    /**
71a469c28c3c16214733a25201a286970f57b3d944bsalomon@google.com     * This function uploads uniforms and calls each GrEffect's setData. It is called before a draw
72a469c28c3c16214733a25201a286970f57b3d944bsalomon@google.com     * occurs using the program after the program has already been bound.
734285accf5af574e6c826d5d09f0359c6149fd717bsalomon@google.com     */
74706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    void setData(const GrDrawState& drawState);
759196130af83782fcac4334117142475a837dd74dbsalomon@google.com
760d831725f6d3e68650c8d3cbcafd7f4986b4b2cctomhudson@google.com    // Parameters that affect code generation
77dbe49f735484f8862e378b63d0a074a301093dd0bsalomon@google.com    // This structs should be kept compact; it is input to an expensive hash key generator.
789ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    struct Desc {
799ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com        Desc() {
804285accf5af574e6c826d5d09f0359c6149fd717bsalomon@google.com            // since we use this as part of a key we can't have any uninitialized
814be283f3a82895530d1b70372cd48ddb1c663fd8bsalomon@google.com            // padding
829ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com            memset(this, 0, sizeof(Desc));
839ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com        }
849ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com
859ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com        // returns this as a uint32_t array to be used as a key in the program cache
869ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com        const uint32_t* asKey() const {
879ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com            return reinterpret_cast<const uint32_t*>(this);
884be283f3a82895530d1b70372cd48ddb1c663fd8bsalomon@google.com        }
894be283f3a82895530d1b70372cd48ddb1c663fd8bsalomon@google.com
904285accf5af574e6c826d5d09f0359c6149fd717bsalomon@google.com        // Specifies where the initial color comes from before the stages are applied.
9185b505bedc35369283ca3aa4449962622842b720bsalomon@google.com        enum ColorInput {
9285b505bedc35369283ca3aa4449962622842b720bsalomon@google.com            kSolidWhite_ColorInput,
9385b505bedc35369283ca3aa4449962622842b720bsalomon@google.com            kTransBlack_ColorInput,
9485b505bedc35369283ca3aa4449962622842b720bsalomon@google.com            kAttribute_ColorInput,
9585b505bedc35369283ca3aa4449962622842b720bsalomon@google.com            kUniform_ColorInput,
9686c1f71625970610e768d3bf26c933db2cd685babsalomon@google.com
9785b505bedc35369283ca3aa4449962622842b720bsalomon@google.com            kColorInputCnt
980d831725f6d3e68650c8d3cbcafd7f4986b4b2cctomhudson@google.com        };
990d831725f6d3e68650c8d3cbcafd7f4986b4b2cctomhudson@google.com        // Dual-src blending makes use of a secondary output color that can be
1004285accf5af574e6c826d5d09f0359c6149fd717bsalomon@google.com        // used as a per-pixel blend coefficient. This controls whether a
101271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com        // secondary source is output and what value it holds.
102271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com        enum DualSrcOutput {
103271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com            kNone_DualSrcOutput,
104271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com            kCoverage_DualSrcOutput,
105271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com            kCoverageISA_DualSrcOutput,
106271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com            kCoverageISC_DualSrcOutput,
1071e257a5db32e1c9e3b0dba80f43470816ef948afbsalomon@google.com
108271cffc77bd2fcb3458559e509634442517ca1e9bsalomon@google.com            kDualSrcOutputCnt
1090d831725f6d3e68650c8d3cbcafd7f4986b4b2cctomhudson@google.com        };
110f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com
1119381363050ec9d3e724076a8e9152bfa9a8de1d1tomhudson@google.com        GrDrawState::VertexEdgeType fVertexEdgeType;
112aeb2160b1dd34f8e640e8e56544fe407d4ff6311bsalomon@google.com
1134285accf5af574e6c826d5d09f0359c6149fd717bsalomon@google.com        // stripped of bits that don't affect program generation
1140d831725f6d3e68650c8d3cbcafd7f4986b4b2cctomhudson@google.com        GrVertexLayout fVertexLayout;
11597c88c255cff3dbb8343c5d090526fdbedad6dd6Scroggo
116dbe49f735484f8862e378b63d0a074a301093dd0bsalomon@google.com        /** Non-zero if this stage has an effect */
117dbe49f735484f8862e378b63d0a074a301093dd0bsalomon@google.com        GrGLEffect::EffectKey fEffectKeys[GrDrawState::kNumStages];
118f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com
119edfe1aac5c6f3a3f3830e86ddea8dbceeb0e6df4bsalomon@google.com        // To enable experimental geometry shader code (not for use in
120edfe1aac5c6f3a3f3830e86ddea8dbceeb0e6df4bsalomon@google.com        // production)
121edfe1aac5c6f3a3f3830e86ddea8dbceeb0e6df4bsalomon@google.com#if GR_GL_EXPERIMENTAL_GS
122edfe1aac5c6f3a3f3830e86ddea8dbceeb0e6df4bsalomon@google.com        bool fExperimentalGS;
123edfe1aac5c6f3a3f3830e86ddea8dbceeb0e6df4bsalomon@google.com#endif
124edfe1aac5c6f3a3f3830e86ddea8dbceeb0e6df4bsalomon@google.com
12585b505bedc35369283ca3aa4449962622842b720bsalomon@google.com        uint8_t fColorInput;        // casts to enum ColorInput
1262401ae8fd3c1f6282f571b5a7e0a499e9f4c09abbsalomon@google.com        uint8_t fCoverageInput;     // casts to enum CoverageInput
12785b505bedc35369283ca3aa4449962622842b720bsalomon@google.com        uint8_t fDualSrcOutput;     // casts to enum DualSrcOutput
1280d831725f6d3e68650c8d3cbcafd7f4986b4b2cctomhudson@google.com        int8_t fFirstCoverageStage;
1290d831725f6d3e68650c8d3cbcafd7f4986b4b2cctomhudson@google.com        SkBool8 fEmitsPointSize;
130f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com
1310d831725f6d3e68650c8d3cbcafd7f4986b4b2cctomhudson@google.com        uint8_t fColorFilterXfermode;  // casts to enum SkXfermode::Mode
1329ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    };
1339ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    GR_STATIC_ASSERT(!(sizeof(Desc) % 4));
134f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com
1352a2e3ef5b84de3347aedaf1f7dd93cfcdb53d7f1tomhudson@google.comprivate:
136f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com    struct StageUniforms;
137f06df1bb9ab201a78bfc906a9e95326c6e15a119bsalomon@google.com
138ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com    GrGLProgram(const GrGLContextInfo& gl,
139ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com                const Desc& desc,
1402eaaefd7e6a58339b3f93333f1e9cc92252cc303bsalomon@google.com                const GrEffectStage* stages[]);
141ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com
142ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com    bool succeeded() const { return 0 != fProgramID; }
143ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com
144ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com    /**
1454285accf5af574e6c826d5d09f0359c6149fd717bsalomon@google.com     *  This is the heavy initialization routine for building a GLProgram.
146ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com     */
1472eaaefd7e6a58339b3f93333f1e9cc92252cc303bsalomon@google.com    bool genProgram(const GrEffectStage* stages[]);
148ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com
1499ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    void genInputColor(GrGLShaderBuilder* builder, SkString* inColor);
1502a2e3ef5b84de3347aedaf1f7dd93cfcdb53d7f1tomhudson@google.com
1512eaaefd7e6a58339b3f93333f1e9cc92252cc303bsalomon@google.com    static GrGLEffect* GenStageCode(const GrEffectStage& stage,
152dbe49f735484f8862e378b63d0a074a301093dd0bsalomon@google.com                                    GrGLEffect::EffectKey key,
1532eaaefd7e6a58339b3f93333f1e9cc92252cc303bsalomon@google.com                                    StageUniforms* stageUniforms, // TODO: Eliminate this
1542eaaefd7e6a58339b3f93333f1e9cc92252cc303bsalomon@google.com                                    const char* fsInColor, // NULL means no incoming color
1552eaaefd7e6a58339b3f93333f1e9cc92252cc303bsalomon@google.com                                    const char* fsOutColor,
1562eaaefd7e6a58339b3f93333f1e9cc92252cc303bsalomon@google.com                                    const char* vsInCoord,
1572eaaefd7e6a58339b3f93333f1e9cc92252cc303bsalomon@google.com                                    GrGLShaderBuilder* builder);
1582a2e3ef5b84de3347aedaf1f7dd93cfcdb53d7f1tomhudson@google.com
159ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com    void genGeometryShader(GrGLShaderBuilder* segments) const;
1609ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com
161dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    typedef GrGLUniformManager::UniformHandle UniformHandle;
162dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com
1639ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    void genUniformCoverage(GrGLShaderBuilder* segments, SkString* inOutCoverage);
1649ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com
165d472620458e2383e6dd949f4e1aaf61160717ffebsalomon@google.com    // generates code to compute coverage based on edge AA. Returns true if edge coverage was
166d472620458e2383e6dd949f4e1aaf61160717ffebsalomon@google.com    // inserted in which case coverageVar will be updated to refer to a scalar. Otherwise,
167d472620458e2383e6dd949f4e1aaf61160717ffebsalomon@google.com    // coverageVar is set to an empty string.
168d472620458e2383e6dd949f4e1aaf61160717ffebsalomon@google.com    bool genEdgeCoverage(SkString* coverageVar, GrGLShaderBuilder* builder) const;
1699ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com
1709ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    // Creates a GL program ID, binds shader attributes to GL vertex attrs, and links the program
17117504f5d5ea2550d29d2118193627129beb7f8b2bsalomon@google.com    bool bindOutputsAttribsAndLinkProgram(const GrGLShaderBuilder& builder,
17217504f5d5ea2550d29d2118193627129beb7f8b2bsalomon@google.com                                          SkString texCoordAttrNames[GrDrawState::kMaxTexCoords],
1739ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com                                          bool bindColorOut,
1749ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com                                          bool bindDualSrcOut);
1759ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com
176dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    // Sets the texture units for samplers
177dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    void initSamplerUniforms();
1789ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com
179ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com    bool compileShaders(const GrGLShaderBuilder& builder);
1809ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com
1819ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    const char* adjustInColor(const SkString& inColor) const;
1829196130af83782fcac4334117142475a837dd74dbsalomon@google.com
183dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    struct StageUniforms {
1840982d35187da7e1ed6c0eba5951bbdadca8b33e7bsalomon@google.com        SkTArray<UniformHandle, true> fSamplerUniforms;
185f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com    };
186f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com
187dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    struct Uniforms {
188dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com        UniformHandle fViewMatrixUni;
189dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com        UniformHandle fColorUni;
190dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com        UniformHandle fCoverageUni;
191dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com        UniformHandle fColorFilterUni;
192706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com        // We use the render target height to provide a y-down frag coord when specifying
193706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com        // origin_upper_left is not supported.
194706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com        UniformHandle fRTHeight;
195dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com        StageUniforms fStages[GrDrawState::kNumStages];
196dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com        Uniforms() {
197dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com            fViewMatrixUni = GrGLUniformManager::kInvalidUniformHandle;
198dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com            fColorUni = GrGLUniformManager::kInvalidUniformHandle;
199dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com            fCoverageUni = GrGLUniformManager::kInvalidUniformHandle;
200dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com            fColorFilterUni = GrGLUniformManager::kInvalidUniformHandle;
201706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com            fRTHeight = GrGLUniformManager::kInvalidUniformHandle;
2029196130af83782fcac4334117142475a837dd74dbsalomon@google.com        }
203f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com    };
204f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com
2059ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    // IDs
2069ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    GrGLuint    fVShaderID;
2079ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    GrGLuint    fGShaderID;
2089ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    GrGLuint    fFShaderID;
2099ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    GrGLuint    fProgramID;
2109ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com
2119ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    // The matrix sent to GL is determined by both the client's matrix and
2129ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    // the size of the viewport.
213b9086a026844e4cfd08b219e49ce3f12294cba98bsalomon@google.com    SkMatrix  fViewMatrix;
2149ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    SkISize   fViewportSize;
2159ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com
2169ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    // these reflect the current values of uniforms
2179ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    // (GL uniform values travel with program)
2189ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    GrColor                     fColor;
2199ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    GrColor                     fCoverage;
2209ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    GrColor                     fColorFilterColor;
221706f66831a575bdc2b1ab1331b48b793cd487356bsalomon@google.com    int                         fRTHeight;
2229ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com
22346fba0d79335f17429bb71d87a04d93fb2ee992bbsalomon@google.com    GrGLEffect*                 fEffects[GrDrawState::kNumStages];
2249ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com
2259ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    Desc fDesc;
226ecb60aad5c6fe5b1dbcfc86ac00bfc9326103c8dbsalomon@google.com    const GrGLContextInfo&      fContextInfo;
2279ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com
228dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    GrGLUniformManager          fUniformManager;
229dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com    Uniforms                    fUniforms;
230dbbc4e2da93cef5c0cfb0b3c92ff6c2c80f6e67absalomon@google.com
2319ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    friend class GrGpuGL; // TODO: remove this by adding getters and moving functionality.
2329ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com
2339ba4fa6f0fb8ef496d81ccac36e780aa806fea83bsalomon@google.com    typedef GrRefCnt INHERITED;
234f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com};
235f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com
236f93e717c7f7ca679a80acbfda6a34013ae1e2b8djunov@google.com#endif
237