| Index: include/gpu/GrBackendProcessorFactory.h
|
| diff --git a/include/gpu/GrBackendEffectFactory.h b/include/gpu/GrBackendProcessorFactory.h
|
| similarity index 57%
|
| rename from include/gpu/GrBackendEffectFactory.h
|
| rename to include/gpu/GrBackendProcessorFactory.h
|
| index 936d632a7e6248496b159d950db906c61a7d70f0..b51a474739938ff3cc8327903eae0067ec0fc628 100644
|
| --- a/include/gpu/GrBackendEffectFactory.h
|
| +++ b/include/gpu/GrBackendProcessorFactory.h
|
| @@ -5,8 +5,8 @@
|
| * found in the LICENSE file.
|
| */
|
|
|
| -#ifndef GrBackendEffectFactory_DEFINED
|
| -#define GrBackendEffectFactory_DEFINED
|
| +#ifndef GrBackendProcessorFactory_DEFINED
|
| +#define GrBackendProcessorFactory_DEFINED
|
|
|
| #include "GrTypes.h"
|
| #include "SkTemplates.h"
|
| @@ -14,16 +14,17 @@
|
| #include "SkTypes.h"
|
| #include "SkTArray.h"
|
|
|
| -class GrGLEffect;
|
| +class GrGLProcessor;
|
| class GrGLCaps;
|
| -class GrEffect;
|
| +class GrProcessor;
|
|
|
| /**
|
| - * Used by effects to build their keys. It incorporates each per-effect key into a larger shader key.
|
| + * Used by effects to build their keys. It incorporates each per-processor key into a larger shader
|
| + * key.
|
| */
|
| -class GrEffectKeyBuilder {
|
| +class GrProcessorKeyBuilder {
|
| public:
|
| - GrEffectKeyBuilder(SkTArray<unsigned char, true>* data) : fData(data), fCount(0) {
|
| + GrProcessorKeyBuilder(SkTArray<unsigned char, true>* data) : fData(data), fCount(0) {
|
| SkASSERT(0 == fData->count() % sizeof(uint32_t));
|
| }
|
|
|
| @@ -48,13 +49,13 @@ private:
|
| };
|
|
|
| /**
|
| - * This class is used to pass the key that was created for a GrGLEffect back to it
|
| + * This class is used to pass the key that was created for a GrGLProcessor 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 {
|
| +class GrProcessorKey {
|
| public:
|
| - GrEffectKey(const uint32_t* key, int count) : fKey(key), fCount(count) {
|
| + GrProcessorKey(const uint32_t* key, int count) : fKey(key), fCount(count) {
|
| SkASSERT(0 == reinterpret_cast<intptr_t>(key) % sizeof(uint32_t));
|
| }
|
|
|
| @@ -73,14 +74,14 @@ private:
|
| };
|
|
|
| /**
|
| - * Given a GrEffect of a particular type, creates the corresponding graphics-backend-specific
|
| + * Given a GrProcessor 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
|
| - * construction. The ID of GrEffect::getFactory() is used as a type identifier. Thus, a GrEffect
|
| - * subclass must always return the same object from getFactory() and that factory object must be
|
| - * unique to the GrEffect subclass (and unique from any further derived subclasses).
|
| + * effect is accessed via GrProcessor::getFactory(). Each factory instance is assigned an ID at
|
| + * construction. The ID of GrProcessor::getFactory() is used as a type identifier. Thus, a
|
| + * GrProcessor subclass must always return the same object from getFactory() and that factory object
|
| + * must be unique to the GrProcessor subclass (and unique from any further derived subclasses).
|
| *
|
| - * Rather than subclassing this class themselves, it is recommended that GrEffect authors use
|
| + * Rather than subclassing this class themselves, it is recommended that GrProcessor authors use
|
| * the templated subclass GrTBackendEffectFactory by writing their getFactory() method as:
|
| *
|
| * const GrBackendEffectFactory& MyEffect::getFactory() const {
|
| @@ -89,20 +90,15 @@ private:
|
| *
|
| * Using GrTBackendEffectFactory places a few constraints on the effect. See that class's comments.
|
| */
|
| -class GrBackendEffectFactory : SkNoncopyable {
|
| +class GrBackendProcessorFactory : SkNoncopyable {
|
| public:
|
| /**
|
| - * 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
|
| + * Generates an effect's key. The key is based on the aspects of the GrProcessor object's
|
| + * configuration that affect GLSL code generation. Two GrProcessor instances that would cause
|
| * this->createGLInstance()->emitCode() to produce different code must produce different keys.
|
| */
|
| - virtual void getGLEffectKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) const = 0;
|
| -
|
| - /**
|
| - * Creates a GrGLEffect instance that is used both to generate code for the GrEffect in a GLSL
|
| - * program and to manage updating uniforms for the program when it is used.
|
| - */
|
| - virtual GrGLEffect* createGLInstance(const GrEffect&) const = 0;
|
| + virtual void getGLProcessorKey(const GrProcessor&, const GrGLCaps&,
|
| + GrProcessorKeyBuilder*) const = 0;
|
|
|
| /**
|
| * Produces a human-reable name for the effect.
|
| @@ -111,14 +107,14 @@ public:
|
|
|
| /**
|
| * A unique value for every instance of this factory. It is automatically incorporated into the
|
| - * effect's key. This allows keys generated by getGLEffectKey() to only be unique within a
|
| - * GrEffect subclass and not necessarily across subclasses.
|
| + * effect's key. This allows keys generated by getGLProcessorKey() to only be unique within a
|
| + * GrProcessor subclass and not necessarily across subclasses.
|
| */
|
| uint32_t effectClassID() const { return fEffectClassID; }
|
|
|
| protected:
|
| - GrBackendEffectFactory() : fEffectClassID(GenID()) {}
|
| - virtual ~GrBackendEffectFactory() {}
|
| + GrBackendProcessorFactory() : fEffectClassID(GenID()) {}
|
| + virtual ~GrBackendProcessorFactory() {}
|
|
|
| private:
|
| enum {
|
| @@ -131,7 +127,7 @@ private:
|
| // 1 to the returned value.
|
| uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&fCurrEffectClassID)) + 1;
|
| if (!id) {
|
| - SkFAIL("This should never wrap as it should only be called once for each GrEffect "
|
| + SkFAIL("This should never wrap as it should only be called once for each GrProcessor "
|
| "subclass.");
|
| }
|
| return id;
|
| @@ -141,4 +137,32 @@ private:
|
| static int32_t fCurrEffectClassID;
|
| };
|
|
|
| +class GrFragmentProcessor;
|
| +class GrGeometryProcessor;
|
| +class GrGLFragmentProcessor;
|
| +class GrGLGeometryProcessor;
|
| +
|
| +/**
|
| + * Backend processor factory cannot actually create anything, it is up to subclasses to implement
|
| + * a create binding which matches Gr to GL in a type safe way
|
| + */
|
| +
|
| +class GrBackendFragmentProcessorFactory : public GrBackendProcessorFactory {
|
| +public:
|
| + /**
|
| + * Creates a GrGLProcessor instance that is used both to generate code for the GrProcessor in a
|
| + * GLSL program and to manage updating uniforms for the program when it is used.
|
| + */
|
| + virtual GrGLFragmentProcessor* createGLInstance(const GrFragmentProcessor&) const = 0;
|
| +};
|
| +
|
| +class GrBackendGeometryProcessorFactory : public GrBackendProcessorFactory {
|
| +public:
|
| + /**
|
| + * Creates a GrGLProcessor instance that is used both to generate code for the GrProcessor in a
|
| + * GLSL program and to manage updating uniforms for the program when it is used.
|
| + */
|
| + virtual GrGLGeometryProcessor* createGLInstance(const GrGeometryProcessor&) const = 0;
|
| +};
|
| +
|
| #endif
|
|
|