aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-21 20:57:59 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-21 20:57:59 +0000
commit289efe014ad7628de7cf2c5177a42cacd1e335ad (patch)
tree739008c94137e69e153d4d7cda5a52ecff943db5 /include/gpu
parent469d0dd944833444a363591be1ee6a76bdecf96d (diff)
Tunnel name requests through factory, forcing custom effect and custom prog stage to use same impl
Review URL: http://codereview.appspot.com/6220061/ git-svn-id: http://skia.googlecode.com/svn/trunk@4019 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/gpu')
-rw-r--r--include/gpu/GrCustomStage.h13
-rw-r--r--include/gpu/GrProgramStageFactory.h13
2 files changed, 19 insertions, 7 deletions
diff --git a/include/gpu/GrCustomStage.h b/include/gpu/GrCustomStage.h
index fd844251d8..9db4244d05 100644
--- a/include/gpu/GrCustomStage.h
+++ b/include/gpu/GrCustomStage.h
@@ -15,7 +15,10 @@
class GrContext;
/** Provides custom vertex shader, fragment shader, uniform data for a
- particular stage of the Ganesh shading pipeline. */
+ particular stage of the Ganesh shading pipeline.
+ Subclasses must have a function that produces a human-readable name:
+ static const char* Name();
+ */
class GrCustomStage : public GrRefCnt {
public:
@@ -24,10 +27,6 @@ public:
GrCustomStage();
virtual ~GrCustomStage();
- /** Human-meaningful string to identify this effect; may be embedded
- in generated shader code. */
- virtual const char* name() const = 0;
-
/** If given an input texture that is/is not opaque, is this
stage guaranteed to produce an opaque output? */
virtual bool isOpaque(bool inputTextureIsOpaque) const;
@@ -60,6 +59,10 @@ public:
of the stageKey produced by the GrProgramStageFactory. */
virtual bool isEqual(const GrCustomStage *) const = 0;
+ /** Human-meaningful string to identify this effect; may be embedded
+ in generated shader code. */
+ const char* name() const { return this->getFactory().name(); }
+
private:
typedef GrRefCnt INHERITED;
diff --git a/include/gpu/GrProgramStageFactory.h b/include/gpu/GrProgramStageFactory.h
index e5f05f74d5..1ce0393bb9 100644
--- a/include/gpu/GrProgramStageFactory.h
+++ b/include/gpu/GrProgramStageFactory.h
@@ -37,6 +37,8 @@ public:
return !(*this == b);
}
+ virtual const char* name() const = 0;
+
protected:
enum {
kIllegalStageClassID = 0,
@@ -66,7 +68,12 @@ class GrTProgramStageFactory : public GrProgramStageFactory {
public:
typedef typename StageClass::GLProgramStage GLProgramStage;
-
+
+ /** Returns a human-readable name that is accessible via GrCustomStage or
+ GrGLProgramStage and is consistent between the two of them.
+ */
+ virtual const char* name() const SK_OVERRIDE { return StageClass::Name(); }
+
/** Returns an value that idenitifes the shader code generated by
a GrCustomStage. This enables caching of generated shaders. Part of the
id identifies the GrCustomShader subclass. The remainder is based
@@ -88,9 +95,11 @@ public:
the object. */
virtual GLProgramStage* createGLInstance(
const GrCustomStage* stage) const SK_OVERRIDE {
- return new GLProgramStage(stage);
+ return new GLProgramStage(*this, stage);
}
+ /** This class is a singleton. This function returns the single instance.
+ */
static const GrProgramStageFactory& getInstance() {
static SkAlignedSTStorage<1, GrTProgramStageFactory> gInstanceMem;
static const GrTProgramStageFactory* gInstance;