From b762cb548bbc260f9b6f3a816bd92e4b2c07df95 Mon Sep 17 00:00:00 2001 From: bsalomon Date: Wed, 15 Oct 2014 11:25:21 -0700 Subject: [PATCH] More effect->processor cleanup R=joshualitt@google.com Review URL: https://codereview.chromium.org/660563003 --- include/gpu/GrBackendProcessorFactory.h | 31 +++++++++++++------------- include/gpu/GrProcessor.h | 8 +++---- include/gpu/GrTBackendProcessorFactory.h | 38 ++++++++++++++++---------------- src/gpu/gl/GrGLProcessor.h | 2 +- 4 files changed, 40 insertions(+), 39 deletions(-) diff --git a/include/gpu/GrBackendProcessorFactory.h b/include/gpu/GrBackendProcessorFactory.h index b51a474..6544b30 100644 --- a/include/gpu/GrBackendProcessorFactory.h +++ b/include/gpu/GrBackendProcessorFactory.h @@ -19,8 +19,8 @@ class GrGLCaps; class GrProcessor; /** - * Used by effects to build their keys. It incorporates each per-processor key into a larger shader - * key. + * Used by processors to build their keys. It incorporates each per-processor key into a larger shader + * key. */ class GrProcessorKeyBuilder { public: @@ -45,7 +45,7 @@ public: private: SkTArray* fData; // unowned ptr to the larger key. - int fCount; // number of uint32_ts added to fData by the effect. + int fCount; // number of uint32_ts added to fData by the processor. }; /** @@ -59,41 +59,42 @@ public: SkASSERT(0 == reinterpret_cast(key) % sizeof(uint32_t)); } - /** Gets the uint32_t values that the effect inserted into the key. */ + /** Gets the uint32_t values that the processor 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. */ + /** Gets the number of uint32_t values that the processor 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. + int fCount; // number of uint32_ts inserted by the processor into its key. }; /** * 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 GrProcessor::getFactory(). Each factory instance is assigned an ID at + * processor object. It also tracks equivalence of shaders generated via a key. The factory for an + * processor 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 GrProcessor authors use - * the templated subclass GrTBackendEffectFactory by writing their getFactory() method as: + * the templated subclass GrTBackendProcessorFactory by writing their getFactory() method as: * - * const GrBackendEffectFactory& MyEffect::getFactory() const { - * return GrTBackendEffectFactory::getInstance(); + * const GrBackendProcessorFactory& MyProcessor::getFactory() const { + * return GrTBackendProcessorFactory::getInstance(); * } * - * Using GrTBackendEffectFactory places a few constraints on the effect. See that class's comments. + * Using GrTBackendProcessorFactory places a few constraints on the processor. See that class's + * comments. */ class GrBackendProcessorFactory : SkNoncopyable { public: /** - * Generates an effect's key. The key is based on the aspects of the GrProcessor object's + * Generates an processor'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. */ @@ -101,13 +102,13 @@ public: GrProcessorKeyBuilder*) const = 0; /** - * Produces a human-reable name for the effect. + * Produces a human-reable name for the v. */ virtual const char* name() const = 0; /** * A unique value for every instance of this factory. It is automatically incorporated into the - * effect's key. This allows keys generated by getGLProcessorKey() to only be unique within a + * processor'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; } diff --git a/include/gpu/GrProcessor.h b/include/gpu/GrProcessor.h index 63ab7ba..c860b32 100644 --- a/include/gpu/GrProcessor.h +++ b/include/gpu/GrProcessor.h @@ -153,15 +153,15 @@ public: /** This object, besides creating back-end-specific helper objects, is used for run-time-type- identification. The factory should be an instance of templated class, - GrTBackendEffectFactory. It is templated on the subclass of GrProcessor. The subclass must - have a nested type (or typedef) named GLProcessor which will be the subclass of + GrTBackendProcessorFactory. It is templated on the subclass of GrProcessor. The subclass + must have a nested type (or typedef) named GLProcessor which will be the subclass of GrGLProcessor created by the factory. Example: class MyCustomProcessor : public GrProcessor { ... - virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE { - return GrTBackendEffectFactory::getInstance(); + virtual const GrBackendProcessorFactory& getFactory() const SK_OVERRIDE { + return GrTBackendProcessorFactory::getInstance(); } ... }; diff --git a/include/gpu/GrTBackendProcessorFactory.h b/include/gpu/GrTBackendProcessorFactory.h index 78a6332..a86fe38 100644 --- a/include/gpu/GrTBackendProcessorFactory.h +++ b/include/gpu/GrTBackendProcessorFactory.h @@ -11,49 +11,49 @@ #include "GrBackendProcessorFactory.h" /** - * Implements GrBackendEffectFactory for a GrProcessor subclass as a singleton. This can be used by - * most GrProcessor subclasses to implement the GrProcessor::getFactory() method: + * Implements GrBackendProcessorFactory for a GrProcessor subclass as a singleton. This can be used + * by most GrProcessor subclasses to implement the GrProcessor::getFactory() method: * - * const GrBackendEffectFactory& MyEffect::getFactory() const { - * return GrTBackendEffectFactory::getInstance(); + * const GrBackendProcessorFactory& MyProcessor::getFactory() const { + * return GrTBackendProcessorFactory::getInstance(); * } * * Using this class requires that the GrProcessor subclass always produces the same GrGLProcessor * subclass. Additionally, it adds the following requirements to the GrProcessor and GrGLProcessor * subclasses: * - * 1. The GrGLProcessor used by GrProcessor subclass MyEffect must be named or typedef'ed to - * MyEffect::GLProcessor. - * 2. MyEffect::GLProcessor must have a static function: - * EffectKey GenKey(const GrProcessor, const GrGLCaps&) + * 1. The GrGLProcessor used by GrProcessor subclass MyProcessor must be named or typedef'ed to + * MyProcessor::GLProcessor. + * 2. MyProcessor::GLProcessor must have a static function: + void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder* b) * which generates a key that maps 1 to 1 with code variations emitted by - * MyEffect::GLProcessor::emitCode(). - * 3. MyEffect must have a static function: + * MyProcessor::GLProcessor::emitCode(). + * 3. MyProcessor must have a static function: * const char* Name() - * which returns a human-readable name for the effect. + * which returns a human-readable name for the processor. */ template class GrTBackendProcessorFactory : public BackEnd { public: typedef typename ProcessorClass::GLProcessor GLProcessor; - /** Returns a human-readable name for the effect. Implemented using GLProcessor::Name as + /** Returns a human-readable name for the processor. Implemented using GLProcessor::Name as * described in this class's comment. */ virtual const char* name() const SK_OVERRIDE { return ProcessorClass::Name(); } /** Implemented using GLProcessor::GenKey as described in this class's comment. */ - virtual void getGLProcessorKey(const GrProcessor& effect, + virtual void getGLProcessorKey(const GrProcessor& processor, const GrGLCaps& caps, GrProcessorKeyBuilder* b) const SK_OVERRIDE { - GLProcessor::GenKey(effect, caps, b); + GLProcessor::GenKey(processor, caps, b); } /** Returns a new instance of the appropriate *GL* implementation class for the given GrProcessor; caller is responsible for deleting the object. */ - virtual GLProcessorBase* createGLInstance(const ProcessorBase& effect) const SK_OVERRIDE { - return SkNEW_ARGS(GLProcessor, (*this, effect)); + virtual GLProcessorBase* createGLInstance(const ProcessorBase& processor) const SK_OVERRIDE { + return SkNEW_ARGS(GLProcessor, (*this, processor)); } /** This class is a singleton. This function returns the single instance. */ @@ -72,9 +72,9 @@ protected: }; /* - * Every effect so far derives from one of the following subclasses of GrTBackendProcessorFactory. - * All of this machinery is necessary to ensure that creatGLInstace is typesafe and does not - * require any casting + * Every processor so far derives from one of the following subclasses of + * GrTBackendProcessorFactory. All of this machinery is necessary to ensure that creatGLInstace is + * typesafe and does not require any casting. */ template class GrTBackendGeometryProcessorFactory diff --git a/src/gpu/gl/GrGLProcessor.h b/src/gpu/gl/GrGLProcessor.h index 0487077..331607a 100644 --- a/src/gpu/gl/GrGLProcessor.h +++ b/src/gpu/gl/GrGLProcessor.h @@ -22,7 +22,7 @@ that their GrGLProcessors would emit the same GLSL code. The GrGLProcessor subclass must also have a constructor of the form: - EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrProcessor&) + EffectSubclass::EffectSubclass(const GrBackendProcessorFactory&, const GrProcessor&) These objects are created by the factory object returned by the GrProcessor::getFactory(). */ -- 2.7.4