diff options
author | 2014-07-21 08:03:14 -0700 | |
---|---|---|
committer | 2014-07-21 08:03:14 -0700 | |
commit | 63e99f7a03b2ac90ae7a00232674fd39c0bdcc68 (patch) | |
tree | 9fcb7021404fdae422202dfff1e4a4e12106fb8c /include/gpu | |
parent | 3f8540346df30f2b681bcffd42edac15d609aec4 (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')
-rw-r--r-- | include/gpu/GrBackendEffectFactory.h | 27 | ||||
-rw-r--r-- | include/gpu/GrEffect.h | 5 | ||||
-rw-r--r-- | include/gpu/GrTBackendEffectFactory.h | 3 |
3 files changed, 28 insertions, 7 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 diff --git a/include/gpu/GrEffect.h b/include/gpu/GrEffect.h index 781a29d289..8cb870ee15 100644 --- a/include/gpu/GrEffect.h +++ b/include/gpu/GrEffect.h @@ -71,9 +71,8 @@ public: from getFactory()). A return value of true from isEqual() should not be used to test whether the effects would - generate the same shader code. To test for identical code generation use the EffectKey - computed by the GrBackendEffectFactory: - effectA.getFactory().glEffectKey(effectA) == effectB.getFactory().glEffectKey(effectB). + generate the same shader code. To test for identical code generation use the effects' keys + computed by the GrBackendEffectFactory. */ bool isEqual(const GrEffect& other) const { if (&this->getFactory() != &other.getFactory()) { diff --git a/include/gpu/GrTBackendEffectFactory.h b/include/gpu/GrTBackendEffectFactory.h index 251e8c7768..450eb68ee5 100644 --- a/include/gpu/GrTBackendEffectFactory.h +++ b/include/gpu/GrTBackendEffectFactory.h @@ -49,8 +49,7 @@ public: virtual void getGLEffectKey(const GrDrawEffect& drawEffect, const GrGLCaps& caps, GrEffectKeyBuilder* b) const SK_OVERRIDE { - EffectKey effectKey = GLEffect::GenKey(drawEffect, caps); - b->add32(effectKey); + GLEffect::GenKey(drawEffect, caps, b); } /** Returns a new instance of the appropriate *GL* implementation class |