aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/GrBackendEffectFactory.h
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-07-21 08:03:14 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-21 08:03:14 -0700
commit63e99f7a03b2ac90ae7a00232674fd39c0bdcc68 (patch)
tree9fcb7021404fdae422202dfff1e4a4e12106fb8c /include/gpu/GrBackendEffectFactory.h
parent3f8540346df30f2b681bcffd42edac15d609aec4 (diff)
Allow GrGLEffects to produce variable length keys.
R=robertphillips@google.com, jvanverth@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/385713005
Diffstat (limited to 'include/gpu/GrBackendEffectFactory.h')
-rw-r--r--include/gpu/GrBackendEffectFactory.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/include/gpu/GrBackendEffectFactory.h b/include/gpu/GrBackendEffectFactory.h
index ef9e436401..e6362520fc 100644
--- a/include/gpu/GrBackendEffectFactory.h
+++ b/include/gpu/GrBackendEffectFactory.h
@@ -48,6 +48,31 @@ private:
};
/**
+ * This class is used to pass the key that was created for a GrGLEffect back to it
+ * when it emits code. It may allow the emit step to skip calculations that were
+ * performed when computing the key.
+ */
+class GrEffectKey {
+public:
+ GrEffectKey(const uint32_t* key, int count) : fKey(key), fCount(count) {
+ SkASSERT(0 == reinterpret_cast<intptr_t>(key) % sizeof(uint32_t));
+ }
+
+ /** Gets the uint32_t values that the effect inserted into the key. */
+ uint32_t get32(int index) const {
+ SkASSERT(index >=0 && index < fCount);
+ return fKey[index];
+ }
+
+ /** Gets the number of uint32_t values that the effect inserted into the key. */
+ int count32() const { return fCount; }
+
+private:
+ const uint32_t* fKey; // unowned ptr into the larger key.
+ int fCount; // number of uint32_ts inserted by the effect into its key.
+};
+
+/**
* Given a GrEffect of a particular type, creates the corresponding graphics-backend-specific
* effect object. It also tracks equivalence of shaders generated via a key. The factory for an
* effect is accessed via GrEffect::getFactory(). Each factory instance is assigned an ID at
@@ -66,8 +91,6 @@ private:
*/
class GrBackendEffectFactory : SkNoncopyable {
public:
- typedef uint32_t EffectKey;
-
/**
* Generates an effect's key. The key is based on the aspects of the GrEffect object's
* configuration that affect GLSL code generation. Two GrEffect instances that would cause