diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/gpu/GrBackendProcessorFactory.h | 32 | ||||
-rw-r--r-- | include/gpu/GrTBackendProcessorFactory.h | 86 |
2 files changed, 90 insertions, 28 deletions
diff --git a/include/gpu/GrBackendProcessorFactory.h b/include/gpu/GrBackendProcessorFactory.h index acbc12c192..dc0bbbe53f 100644 --- a/include/gpu/GrBackendProcessorFactory.h +++ b/include/gpu/GrBackendProcessorFactory.h @@ -68,14 +68,6 @@ private: */ class GrBackendProcessorFactory : SkNoncopyable { public: - /** - * 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. - */ - virtual void getGLProcessorKey(const GrProcessor&, const GrGLCaps&, - GrProcessorKeyBuilder*) const = 0; - /** * Produces a human-reable name for the v. */ @@ -128,6 +120,15 @@ class GrGLXferProcessor; class GrBackendFragmentProcessorFactory : public GrBackendProcessorFactory { public: /** + * 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. + */ + virtual void getGLProcessorKey(const GrFragmentProcessor&, + const GrGLCaps&, + GrProcessorKeyBuilder*) const = 0; + + /** * 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. */ @@ -143,13 +144,26 @@ public: virtual GrGLXferProcessor* createGLInstance(const GrXferProcessor&) const = 0; }; +class GrBatchTracker; + class GrBackendGeometryProcessorFactory : public GrBackendProcessorFactory { public: /** + * 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. + */ + virtual void getGLProcessorKey(const GrGeometryProcessor&, + const GrBatchTracker&, + const GrGLCaps&, + GrProcessorKeyBuilder*) const = 0; + + /** * 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; + virtual GrGLGeometryProcessor* createGLInstance(const GrGeometryProcessor&, + const GrBatchTracker&) const = 0; }; #endif diff --git a/include/gpu/GrTBackendProcessorFactory.h b/include/gpu/GrTBackendProcessorFactory.h index a86fe38d92..98b5d6cb7e 100644 --- a/include/gpu/GrTBackendProcessorFactory.h +++ b/include/gpu/GrTBackendProcessorFactory.h @@ -41,14 +41,6 @@ public: * 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& processor, - const GrGLCaps& caps, - GrProcessorKeyBuilder* b) const SK_OVERRIDE { - 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. */ @@ -77,24 +69,80 @@ protected: * typesafe and does not require any casting. */ template <class ProcessorClass> -class GrTBackendGeometryProcessorFactory - : public GrTBackendProcessorFactory<ProcessorClass, - GrBackendGeometryProcessorFactory, - GrGeometryProcessor, - GrGLGeometryProcessor> { +class GrTBackendGeometryProcessorFactory : public GrBackendGeometryProcessorFactory { +public: + typedef typename ProcessorClass::GLProcessor GLProcessor; + + /** 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 GrGeometryProcessor& processor, + const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE { + GLProcessor::GenKey(processor, bt, caps, b); + } + + + /** Returns a new instance of the appropriate *GL* implementation class + for the given GrProcessor; caller is responsible for deleting + the object. */ + virtual GrGLGeometryProcessor* createGLInstance(const GrGeometryProcessor& gp, + const GrBatchTracker& bt) const SK_OVERRIDE { + return SkNEW_ARGS(GLProcessor, (*this, gp, bt)); + } + + /** This class is a singleton. This function returns the single instance. */ + static const GrBackendGeometryProcessorFactory& getInstance() { + static SkAlignedSTStorage<1, GrTBackendGeometryProcessorFactory> gInstanceMem; + static const GrTBackendGeometryProcessorFactory* gInstance; + if (!gInstance) { + gInstance = SkNEW_PLACEMENT(gInstanceMem.get(), + GrTBackendGeometryProcessorFactory); + } + return *gInstance; + } protected: GrTBackendGeometryProcessorFactory() {} }; template <class ProcessorClass> -class GrTBackendFragmentProcessorFactory - : public GrTBackendProcessorFactory<ProcessorClass, - GrBackendFragmentProcessorFactory, - GrFragmentProcessor, - GrGLFragmentProcessor> { +class GrTBackendFragmentProcessorFactory : public GrBackendFragmentProcessorFactory { +public: + typedef typename ProcessorClass::GLProcessor GLProcessor; + + /** 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 GrFragmentProcessor& processor, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE { + 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 GrGLFragmentProcessor* createGLInstance(const GrFragmentProcessor& gp) const SK_OVERRIDE { + return SkNEW_ARGS(GLProcessor, (*this, gp)); + } + + /** This class is a singleton. This function returns the single instance. */ + static const GrBackendFragmentProcessorFactory& getInstance() { + static SkAlignedSTStorage<1, GrTBackendFragmentProcessorFactory> gInstanceMem; + static const GrTBackendFragmentProcessorFactory* gInstance; + if (!gInstance) { + gInstance = SkNEW_PLACEMENT(gInstanceMem.get(), + GrTBackendFragmentProcessorFactory); + } + return *gInstance; + } protected: GrTBackendFragmentProcessorFactory() {} }; - #endif |