Make GrGLProgram be available to GrGLProgramDataManager
GL APIs such as glProgramPathFragmentInputGenNV need the explicit program id in
order to set the program resources. For GrGLProgramDataManager to call the APIs,
the program id needs to be available to the GrGLProgramDataManager.
One GrGLProgramDataManager is used to explicitly manage the resources of one
GrGLProgram. Refactor the classes to reflect this: make GrGLProgram create and
own GrGLProgramDataManager. This way the program id can be made available through
GrGLProgram backpointer.
In order to do this, remove the population of the program link results
information for uniforms in GrGLProgramDataManager during shader generation.
Instead, accumulate the info to the uniform list of GrGLShaderBuilder. After the
generation, compilation and link is successful, this info can be used to
construct both GrGLProgram and GrGLProgramDataManager.
Changes names of functions to create UniformHandles and convert them to list
indices. This tries to highlight that they're different lists, even though at
the moment they match index-wise. E.g the contract is that handles can be
created based on the shader builder state, and the object can later be set with
the handle and the manager that was created with the builder.
This is needed to support NV_path_rendering for GLES.
R=bsalomon@google.com
Author: kkinnunen@nvidia.com
Review URL: https://codereview.chromium.org/426553011
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index edb24a7..fb49685 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -37,6 +37,8 @@
public:
SK_DECLARE_INST_COUNT(GrGLProgram)
+ typedef GrGLShaderBuilder::BuiltinUniformHandles BuiltinUniformHandles;
+
static GrGLProgram* Create(GrGpuGL* gpu,
const GrGLProgramDesc& desc,
const GrEffectStage* colorStages[],
@@ -59,9 +61,9 @@
/**
* Gets the GL program ID for this program.
*/
- GrGLuint programID() const { return fBuilderOutput.fProgramID; }
+ GrGLuint programID() const { return fProgramID; }
- bool hasVertexShader() const { return fBuilderOutput.fHasVertexShader; }
+ bool hasVertexShader() const { return fHasVertexShader; }
/**
* Some GL state that is relevant to programs is not stored per-program. In particular color
@@ -165,8 +167,7 @@
GrGLProgram(GrGpuGL*,
const GrGLProgramDesc&,
- GrGLProgramDataManager*,
- const GrGLShaderBuilder::GenProgramOutput&);
+ const GrGLShaderBuilder&);
// Sets the texture units for samplers.
void initSamplerUniforms();
@@ -188,12 +189,17 @@
GrColor fCoverage;
int fDstCopyTexUnit;
- GrGLShaderBuilder::GenProgramOutput fBuilderOutput;
+ BuiltinUniformHandles fBuiltinUniformHandles;
+ SkAutoTUnref<GrGLProgramEffects> fColorEffects;
+ SkAutoTUnref<GrGLProgramEffects> fCoverageEffects;
+ GrGLuint fProgramID;
+ bool fHasVertexShader;
+ int fTexCoordSetCnt;
GrGLProgramDesc fDesc;
GrGpuGL* fGpu;
- SkAutoTUnref<GrGLProgramDataManager> fProgramDataManager;
+ GrGLProgramDataManager fProgramDataManager;
typedef SkRefCnt INHERITED;
};