Makes GrGLProgramDesc's key store the lengths as well as offsets of the effect keys.
Makes it possible to use GrBackendEffectFactories other than GrTBEF by moving meta-key generation out of GrTBEF.
Cleans up docs around GrBackendEffectFactory.
Committed: https://skia.googlesource.com/skia/+/c0ea398aff8254e31152cbb94c9ab6150428e252
R=robertphillips@google.com, jvanverth@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/379113004
diff --git a/src/gpu/gl/GrGLProgramEffects.h b/src/gpu/gl/GrGLProgramEffects.h
index 5a2fefd..c4d8843 100644
--- a/src/gpu/gl/GrGLProgramEffects.h
+++ b/src/gpu/gl/GrGLProgramEffects.h
@@ -9,9 +9,9 @@
#define GrGLProgramEffects_DEFINED
#include "GrBackendEffectFactory.h"
+#include "GrGLUniformManager.h"
#include "GrTexture.h"
#include "GrTextureAccess.h"
-#include "GrGLUniformManager.h"
class GrEffect;
class GrEffectStage;
@@ -31,11 +31,14 @@
typedef GrGLUniformManager::UniformHandle UniformHandle;
/**
- * These methods generate different portions of an effect's final key.
+ * This class emits some of the code inserted into the shaders for an effect. The code it
+ * creates may be dependent on properties of the effect that the effect itself doesn't use
+ * in its key (e.g. the pixel format of textures used). So this class inserts a meta-key for
+ * every effect using this function. It is also responsible for inserting the effect's class ID
+ * which must be different for every GrEffect subclass. It can fail if an effect uses too many
+ * textures, attributes, etc for the space allotted in the meta-key.
*/
- static EffectKey GenAttribKey(const GrDrawEffect&);
- static EffectKey GenTransformKey(const GrDrawEffect&);
- static EffectKey GenTextureKey(const GrDrawEffect&, const GrGLCaps&);
+ static bool GenEffectMetaKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
virtual ~GrGLProgramEffects();
@@ -98,6 +101,13 @@
typedef SkTArray<TextureSampler> TextureSamplerArray;
protected:
+ /**
+ * Helpers for GenEffectMetaKey.
+ */
+ static EffectKey GenAttribKey(const GrDrawEffect&);
+ static EffectKey GenTransformKey(const GrDrawEffect&);
+ static EffectKey GenTextureKey(const GrDrawEffect&, const GrGLCaps&);
+
GrGLProgramEffects(int reserveCount)
: fGLEffects(reserveCount)
, fSamplers(reserveCount) {