diff options
author | joshualitt <joshualitt@chromium.org> | 2014-12-04 11:35:33 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-04 11:35:34 -0800 |
commit | eb2a6761654307e8aeeeaabdd63c6bf9ab0411e9 (patch) | |
tree | 9567dc32598c1c0df5f5cf4a3d6594c61b95fd93 /src/gpu | |
parent | e109145bf31d63963b3f78c6af6e404d5464a55b (diff) |
Remove backend factories
BUG=skia:
Review URL: https://codereview.chromium.org/778453002
Diffstat (limited to 'src/gpu')
42 files changed, 537 insertions, 427 deletions
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp index 3108b0472e..4008fe23d3 100644 --- a/src/gpu/GrAAConvexPathRenderer.cpp +++ b/src/gpu/GrAAConvexPathRenderer.cpp @@ -11,20 +11,17 @@ #include "GrContext.h" #include "GrDrawState.h" #include "GrDrawTargetCaps.h" +#include "GrGeometryProcessor.h" #include "GrInvariantOutput.h" #include "GrProcessor.h" #include "GrPathUtils.h" -#include "GrTBackendProcessorFactory.h" #include "SkString.h" #include "SkStrokeRec.h" #include "SkTraceEvent.h" - -#include "gl/builders/GrGLProgramBuilder.h" #include "gl/GrGLProcessor.h" #include "gl/GrGLSL.h" #include "gl/GrGLGeometryProcessor.h" - -#include "GrGeometryProcessor.h" +#include "gl/builders/GrGLProgramBuilder.h" GrAAConvexPathRenderer::GrAAConvexPathRenderer() { } @@ -516,21 +513,15 @@ public: virtual ~QuadEdgeEffect() {} - static const char* Name() { return "QuadEdge"; } + virtual const char* name() const SK_OVERRIDE { return "QuadEdge"; } const GrAttribute* inPosition() const { return fInPosition; } const GrAttribute* inQuadEdge() const { return fInQuadEdge; } - virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE { - return GrTBackendGeometryProcessorFactory<QuadEdgeEffect>::getInstance(); - } - class GLProcessor : public GrGLGeometryProcessor { public: - GLProcessor(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) - : INHERITED (factory) {} + GLProcessor(const GrGeometryProcessor&, + const GrBatchTracker&) {} virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>(); @@ -586,8 +577,19 @@ public: typedef GrGLGeometryProcessor INHERITED; }; + virtual void getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE { + GLProcessor::GenKey(*this, bt, caps, b); + } + + virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE { + return SkNEW_ARGS(GLProcessor, (*this, bt)); + } + private: QuadEdgeEffect() { + this->initClassID<QuadEdgeEffect>(); fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType)); fInQuadEdge = &this->addVertexAttrib(GrAttribute("inQuadEdge", kVec4f_GrVertexAttribType)); } diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp index 7168c83884..15a5569b30 100644 --- a/src/gpu/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/GrAAHairLinePathRenderer.cpp @@ -15,7 +15,6 @@ #include "GrIndexBuffer.h" #include "GrPathUtils.h" #include "GrProcessor.h" -#include "GrTBackendProcessorFactory.h" #include "SkGeometry.h" #include "SkStroke.h" #include "SkTemplates.h" diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp index 95fe8c9b7f..7f61840d73 100644 --- a/src/gpu/GrAARectRenderer.cpp +++ b/src/gpu/GrAARectRenderer.cpp @@ -10,7 +10,6 @@ #include "GrGeometryProcessor.h" #include "GrGpu.h" #include "GrInvariantOutput.h" -#include "GrTBackendProcessorFactory.h" #include "SkColorPriv.h" #include "gl/GrGLProcessor.h" #include "gl/GrGLGeometryProcessor.h" diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp index ddaa809f06..0df519dd8f 100644 --- a/src/gpu/GrDefaultGeoProcFactory.cpp +++ b/src/gpu/GrDefaultGeoProcFactory.cpp @@ -9,7 +9,6 @@ #include "GrDrawState.h" #include "GrInvariantOutput.h" -#include "GrTBackendProcessorFactory.h" #include "gl/GrGLGeometryProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" @@ -62,11 +61,7 @@ public: } } - static const char* Name() { return "DefaultGeometryProcessor"; } - - virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE { - return GrTBackendGeometryProcessorFactory<DefaultGeoProc>::getInstance(); - } + virtual const char* name() const SK_OVERRIDE { return "DefaultGeometryProcessor"; } const GrAttribute* inPosition() const { return fInPosition; } const GrAttribute* inColor() const { return fInColor; } @@ -75,10 +70,8 @@ public: class GLProcessor : public GrGLGeometryProcessor { public: - GLProcessor(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) - : INHERITED (factory) {} + GLProcessor(const GrGeometryProcessor&, + const GrBatchTracker&) {} virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { const DefaultGeoProc& gp = args.fGP.cast<DefaultGeoProc>(); @@ -127,6 +120,16 @@ public: typedef GrGLGeometryProcessor INHERITED; }; + virtual void getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE { + GLProcessor::GenKey(*this, bt, caps, b); + } + + virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE { + return SkNEW_ARGS(GLProcessor, (*this, bt)); + } + private: DefaultGeoProc(uint32_t gpTypeFlags) : fInPosition(NULL) @@ -134,6 +137,7 @@ private: , fInLocalCoords(NULL) , fInCoverage(NULL) , fFlags(gpTypeFlags) { + this->initClassID<DefaultGeoProc>(); bool hasColor = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kColor_GPType); bool hasLocalCoord = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kLocalCoord_GPType); bool hasCoverage = SkToBool(gpTypeFlags & GrDefaultGeoProcFactory::kCoverage_GPType); diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h index 27383a4df4..9e621d82a0 100644 --- a/src/gpu/GrGeometryProcessor.h +++ b/src/gpu/GrGeometryProcessor.h @@ -34,6 +34,8 @@ private: uint8_t fData[kMaxSize]; }; +class GrGLCaps; +class GrGLGeometryProcessor; class GrOptDrawState; /** @@ -55,7 +57,18 @@ public: , fHasVertexCoverage(false) , fHasLocalCoords(false) {} - virtual const GrBackendGeometryProcessorFactory& getFactory() const = 0; + virtual const char* name() const = 0; + + /** Implemented using GLProcessor::GenKey as described in this class's comment. */ + virtual void getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const = 0; + + + /** 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 GrBatchTracker& bt) const = 0; /* * This is a safeguard to prevent GPs from going beyond platform specific attribute limits. @@ -91,7 +104,7 @@ public: would generate the same shader code. To test for identical code generation use the processors' keys computed by the GrBackendEffectFactory. */ bool isEqual(const GrGeometryProcessor& that) const { - if (&this->getFactory() != &that.getFactory() || !this->hasSameTextureAccesses(that)) { + if (this->classID() != that.classID() || !this->hasSameTextureAccesses(that)) { return false; } return this->onIsEqual(that); @@ -143,5 +156,4 @@ private: typedef GrProcessor INHERITED; }; - #endif diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index c6586120a9..f392b909d7 100644 --- a/src/gpu/GrOvalRenderer.cpp +++ b/src/gpu/GrOvalRenderer.cpp @@ -7,24 +7,20 @@ #include "GrOvalRenderer.h" -#include "gl/builders/GrGLProgramBuilder.h" -#include "gl/GrGLProcessor.h" -#include "gl/GrGLSL.h" -#include "gl/GrGLGeometryProcessor.h" #include "GrProcessor.h" -#include "GrTBackendProcessorFactory.h" - #include "GrDrawState.h" #include "GrDrawTarget.h" +#include "GrGeometryProcessor.h" #include "GrGpu.h" #include "GrInvariantOutput.h" - #include "SkRRect.h" #include "SkStrokeRec.h" #include "SkTLazy.h" - -#include "GrGeometryProcessor.h" #include "effects/GrRRectEffect.h" +#include "gl/GrGLProcessor.h" +#include "gl/GrGLSL.h" +#include "gl/GrGLGeometryProcessor.h" +#include "gl/builders/GrGLProgramBuilder.h" namespace { // TODO(joshualitt) add per vertex colors @@ -78,23 +74,16 @@ public: const GrAttribute* inPosition() const { return fInPosition; } const GrAttribute* inCircleEdge() const { return fInCircleEdge; } - - virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE { - return GrTBackendGeometryProcessorFactory<CircleEdgeEffect>::getInstance(); - } - virtual ~CircleEdgeEffect() {} - static const char* Name() { return "CircleEdge"; } + virtual const char* name() const SK_OVERRIDE { return "CircleEdge"; } inline bool isStroked() const { return fStroke; } class GLProcessor : public GrGLGeometryProcessor { public: - GLProcessor(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) - : INHERITED (factory) {} + GLProcessor(const GrGeometryProcessor&, + const GrBatchTracker&) {} virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { const CircleEdgeEffect& ce = args.fGP.cast<CircleEdgeEffect>(); @@ -140,9 +129,19 @@ public: typedef GrGLGeometryProcessor INHERITED; }; + virtual void getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE { + GLProcessor::GenKey(*this, bt, caps, b); + } + + virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE { + return SkNEW_ARGS(GLProcessor, (*this, bt)); + } private: CircleEdgeEffect(bool stroke) { + this->initClassID<CircleEdgeEffect>(); fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType)); fInCircleEdge = &this->addVertexAttrib(GrAttribute("inCircleEdge", kVec4f_GrVertexAttribType)); @@ -201,14 +200,9 @@ public: } } - virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE { - return GrTBackendGeometryProcessorFactory<EllipseEdgeEffect>::getInstance(); - } - virtual ~EllipseEdgeEffect() {} - static const char* Name() { return "EllipseEdge"; } - + virtual const char* name() const SK_OVERRIDE { return "EllipseEdge"; } const GrAttribute* inPosition() const { return fInPosition; } const GrAttribute* inEllipseOffset() const { return fInEllipseOffset; } @@ -218,10 +212,8 @@ public: class GLProcessor : public GrGLGeometryProcessor { public: - GLProcessor(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) - : INHERITED (factory) {} + GLProcessor(const GrGeometryProcessor&, + const GrBatchTracker&) {} virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { const EllipseEdgeEffect& ee = args.fGP.cast<EllipseEdgeEffect>(); @@ -290,8 +282,19 @@ public: typedef GrGLGeometryProcessor INHERITED; }; + virtual void getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE { + GLProcessor::GenKey(*this, bt, caps, b); + } + + virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE { + return SkNEW_ARGS(GLProcessor, (*this, bt)); + } + private: EllipseEdgeEffect(bool stroke) { + this->initClassID<EllipseEdgeEffect>(); fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType)); fInEllipseOffset = &this->addVertexAttrib(GrAttribute("inEllipseOffset", kVec2f_GrVertexAttribType)); @@ -360,13 +363,9 @@ public: } } - virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE { - return GrTBackendGeometryProcessorFactory<DIEllipseEdgeEffect>::getInstance(); - } - virtual ~DIEllipseEdgeEffect() {} - static const char* Name() { return "DIEllipseEdge"; } + virtual const char* name() const SK_OVERRIDE { return "DIEllipseEdge"; } const GrAttribute* inPosition() const { return fInPosition; } const GrAttribute* inEllipseOffsets0() const { return fInEllipseOffsets0; } @@ -376,10 +375,8 @@ public: class GLProcessor : public GrGLGeometryProcessor { public: - GLProcessor(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) - : INHERITED (factory) {} + GLProcessor(const GrGeometryProcessor&, + const GrBatchTracker&) {} virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { const DIEllipseEdgeEffect& ee = args.fGP.cast<DIEllipseEdgeEffect>(); @@ -463,8 +460,19 @@ public: typedef GrGLGeometryProcessor INHERITED; }; + virtual void getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE { + GLProcessor::GenKey(*this, bt, caps, b); + } + + virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE { + return SkNEW_ARGS(GLProcessor, (*this, bt)); + } + private: DIEllipseEdgeEffect(Mode mode) { + this->initClassID<DIEllipseEdgeEffect>(); fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType)); fInEllipseOffsets0 = &this->addVertexAttrib(GrAttribute("inEllipseOffsets0", kVec2f_GrVertexAttribType)); diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp index 8aeef04b48..810c751f1c 100644 --- a/src/gpu/GrProcessor.cpp +++ b/src/gpu/GrProcessor.cpp @@ -6,7 +6,6 @@ */ #include "GrProcessor.h" -#include "GrBackendProcessorFactory.h" #include "GrContext.h" #include "GrCoordTransform.h" #include "GrGeometryData.h" @@ -16,6 +15,9 @@ #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS +class GrFragmentProcessor; +class GrGeometryProcessor; + /* * Originally these were both in the processor unit test header, but then it seemed to cause linker * problems on android. @@ -109,17 +111,13 @@ private: } }; -int32_t GrBackendProcessorFactory::fCurrProcessorClassID = - GrBackendProcessorFactory::kIllegalProcessorClassID; +int32_t GrProcessor::gCurrProcessorClassID = + GrProcessor::kIllegalProcessorClassID; /////////////////////////////////////////////////////////////////////////////// GrProcessor::~GrProcessor() {} -const char* GrProcessor::name() const { - return this->getFactory().name(); -} - void GrProcessor::addTextureAccess(const GrTextureAccess* access) { fTextureAccesses.push_back(access); this->addGpuResource(access->getProgramTexture()); @@ -181,4 +179,3 @@ void* GrGeometryData::operator new(size_t size) { void GrGeometryData::operator delete(void* target) { GrProcessor_Globals::GetTLS()->release(target); } - diff --git a/src/gpu/GrProgramDesc.h b/src/gpu/GrProgramDesc.h index ef7be23cf3..a20b99f749 100644 --- a/src/gpu/GrProgramDesc.h +++ b/src/gpu/GrProgramDesc.h @@ -8,7 +8,6 @@ #ifndef GrProgramDesc_DEFINED #define GrProgramDesc_DEFINED -#include "GrBackendProcessorFactory.h" #include "GrColor.h" #include "GrTypesPriv.h" #include "SkChecksum.h" diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp index 0bcfc75bef..ebbb8d7f88 100644 --- a/src/gpu/effects/GrBezierEffect.cpp +++ b/src/gpu/effects/GrBezierEffect.cpp @@ -7,16 +7,14 @@ #include "GrBezierEffect.h" -#include "gl/builders/GrGLProgramBuilder.h" #include "gl/GrGLProcessor.h" #include "gl/GrGLSL.h" #include "gl/GrGLGeometryProcessor.h" -#include "GrTBackendProcessorFactory.h" +#include "gl/builders/GrGLProgramBuilder.h" class GrGLConicEffect : public GrGLGeometryProcessor { public: - GrGLConicEffect(const GrBackendProcessorFactory&, - const GrGeometryProcessor&, + GrGLConicEffect(const GrGeometryProcessor&, const GrBatchTracker&); virtual void emitCode(const EmitArgs&) SK_OVERRIDE; @@ -36,10 +34,8 @@ private: typedef GrGLGeometryProcessor INHERITED; }; -GrGLConicEffect::GrGLConicEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor& processor, - const GrBatchTracker& bt) - : INHERITED (factory) { +GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor, + const GrBatchTracker& bt) { const GrConicEffect& ce = processor.cast<GrConicEffect>(); fEdgeType = ce.getEdgeType(); } @@ -133,12 +129,19 @@ void GrGLConicEffect::GenKey(const GrGeometryProcessor& processor, GrConicEffect::~GrConicEffect() {} -const GrBackendGeometryProcessorFactory& GrConicEffect::getFactory() const { - return GrTBackendGeometryProcessorFactory<GrConicEffect>::getInstance(); +void GrConicEffect::getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GrGLConicEffect::GenKey(*this, bt, caps, b); +} + +GrGLGeometryProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt) const { + return SkNEW_ARGS(GrGLConicEffect, (*this, bt)); } GrConicEffect::GrConicEffect(GrPrimitiveEdgeType edgeType) : fEdgeType(edgeType) { + this->initClassID<GrConicEffect>(); fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType)); fInConicCoeffs = &this->addVertexAttrib(GrAttribute("inConicCoeffs", kVec4f_GrVertexAttribType)); @@ -172,8 +175,7 @@ GrGeometryProcessor* GrConicEffect::TestCreate(SkRandom* random, class GrGLQuadEffect : public GrGLGeometryProcessor { public: - GrGLQuadEffect(const GrBackendProcessorFactory&, - const GrGeometryProcessor&, + GrGLQuadEffect(const GrGeometryProcessor&, const GrBatchTracker&); virtual void emitCode(const EmitArgs&) SK_OVERRIDE; @@ -193,10 +195,8 @@ private: typedef GrGLGeometryProcessor INHERITED; }; -GrGLQuadEffect::GrGLQuadEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor& processor, - const GrBatchTracker& bt) - : INHERITED (factory) { +GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor, + const GrBatchTracker& bt) { const GrQuadEffect& ce = processor.cast<GrQuadEffect>(); fEdgeType = ce.getEdgeType(); } @@ -276,12 +276,19 @@ void GrGLQuadEffect::GenKey(const GrGeometryProcessor& processor, GrQuadEffect::~GrQuadEffect() {} -const GrBackendGeometryProcessorFactory& GrQuadEffect::getFactory() const { - return GrTBackendGeometryProcessorFactory<GrQuadEffect>::getInstance(); +void GrQuadEffect::getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GrGLQuadEffect::GenKey(*this, bt, caps, b); +} + +GrGLGeometryProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt) const { + return SkNEW_ARGS(GrGLQuadEffect, (*this, bt)); } GrQuadEffect::GrQuadEffect(GrPrimitiveEdgeType edgeType) : fEdgeType(edgeType) { + this->initClassID<GrQuadEffect>(); fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType)); fInHairQuadEdge = &this->addVertexAttrib(GrAttribute("inHairQuadEdge", kVec4f_GrVertexAttribType)); @@ -315,8 +322,7 @@ GrGeometryProcessor* GrQuadEffect::TestCreate(SkRandom* random, class GrGLCubicEffect : public GrGLGeometryProcessor { public: - GrGLCubicEffect(const GrBackendProcessorFactory&, - const GrGeometryProcessor&, + GrGLCubicEffect(const GrGeometryProcessor&, const GrBatchTracker&); virtual void emitCode(const EmitArgs&) SK_OVERRIDE; @@ -336,10 +342,8 @@ private: typedef GrGLGeometryProcessor INHERITED; }; -GrGLCubicEffect::GrGLCubicEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor& processor, - const GrBatchTracker&) - : INHERITED (factory) { +GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor, + const GrBatchTracker&) { const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); fEdgeType = ce.getEdgeType(); } @@ -460,12 +464,19 @@ void GrGLCubicEffect::GenKey(const GrGeometryProcessor& processor, GrCubicEffect::~GrCubicEffect() {} -const GrBackendGeometryProcessorFactory& GrCubicEffect::getFactory() const { - return GrTBackendGeometryProcessorFactory<GrCubicEffect>::getInstance(); +void GrCubicEffect::getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GrGLCubicEffect::GenKey(*this, bt, caps, b); +} + +GrGLGeometryProcessor* GrCubicEffect::createGLInstance(const GrBatchTracker& bt) const { + return SkNEW_ARGS(GrGLCubicEffect, (*this, bt)); } GrCubicEffect::GrCubicEffect(GrPrimitiveEdgeType edgeType) : fEdgeType(edgeType) { + this->initClassID<GrCubicEffect>(); fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType)); fInCubicCoeffs = &this->addVertexAttrib(GrAttribute("inCubicCoeffs", kVec4f_GrVertexAttribType)); diff --git a/src/gpu/effects/GrBezierEffect.h b/src/gpu/effects/GrBezierEffect.h index 27f2fa1aa2..7b171a17ca 100644 --- a/src/gpu/effects/GrBezierEffect.h +++ b/src/gpu/effects/GrBezierEffect.h @@ -86,7 +86,7 @@ public: virtual ~GrConicEffect(); - static const char* Name() { return "Conic"; } + virtual const char* name() const SK_OVERRIDE { return "Conic"; } inline const GrAttribute* inPosition() const { return fInPosition; } inline const GrAttribute* inConicCoeffs() const { return fInConicCoeffs; } @@ -94,9 +94,11 @@ public: inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); } inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } - typedef GrGLConicEffect GLProcessor; + virtual void getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE; - virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE; + virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE; private: GrConicEffect(GrPrimitiveEdgeType); @@ -157,7 +159,7 @@ public: virtual ~GrQuadEffect(); - static const char* Name() { return "Quad"; } + virtual const char* name() const SK_OVERRIDE { return "Quad"; } inline const GrAttribute* inPosition() const { return fInPosition; } inline const GrAttribute* inHairQuadEdge() const { return fInHairQuadEdge; } @@ -165,9 +167,11 @@ public: inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); } inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } - typedef GrGLQuadEffect GLProcessor; + virtual void getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE; - virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE; + virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE; private: GrQuadEffect(GrPrimitiveEdgeType); @@ -230,7 +234,7 @@ public: virtual ~GrCubicEffect(); - static const char* Name() { return "Cubic"; } + virtual const char* name() const SK_OVERRIDE { return "Cubic"; } inline const GrAttribute* inPosition() const { return fInPosition; } inline const GrAttribute* inCubicCoeffs() const { return fInCubicCoeffs; } @@ -238,9 +242,11 @@ public: inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); } inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } - typedef GrGLCubicEffect GLProcessor; + virtual void getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE; - virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE; + virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE; private: GrCubicEffect(GrPrimitiveEdgeType); diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp index 51ba58efd5..804a087b16 100644 --- a/src/gpu/effects/GrBicubicEffect.cpp +++ b/src/gpu/effects/GrBicubicEffect.cpp @@ -5,9 +5,9 @@ * found in the LICENSE file. */ -#include "gl/builders/GrGLProgramBuilder.h" #include "GrBicubicEffect.h" #include "GrInvariantOutput.h" +#include "gl/builders/GrGLProgramBuilder.h" #define DS(x) SkDoubleToScalar(x) @@ -21,8 +21,7 @@ const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = { class GrGLBicubicEffect : public GrGLFragmentProcessor { public: - GrGLBicubicEffect(const GrBackendProcessorFactory& factory, - const GrProcessor&); + GrGLBicubicEffect(const GrProcessor&); virtual void emitCode(GrGLFPBuilder*, const GrFragmentProcessor&, @@ -49,8 +48,7 @@ private: typedef GrGLFragmentProcessor INHERITED; }; -GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendProcessorFactory& factory, const GrProcessor&) - : INHERITED(factory) { +GrGLBicubicEffect::GrGLBicubicEffect(const GrProcessor&) { } void GrGLBicubicEffect::emitCode(GrGLFPBuilder* builder, @@ -140,6 +138,7 @@ GrBicubicEffect::GrBicubicEffect(GrTexture* texture, const SkShader::TileMode tileModes[2]) : INHERITED(texture, matrix, GrTextureParams(tileModes, GrTextureParams::kNone_FilterMode)) , fDomain(GrTextureDomain::IgnoredDomain()) { + this->initClassID<GrBicubicEffect>(); convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coefficients); } @@ -150,14 +149,20 @@ GrBicubicEffect::GrBicubicEffect(GrTexture* texture, : INHERITED(texture, matrix, GrTextureParams(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode)) , fDomain(domain, GrTextureDomain::kClamp_Mode) { + this->initClassID<GrBicubicEffect>(); convert_row_major_scalar_coeffs_to_column_major_floats(fCoefficients, coefficients); } GrBicubicEffect::~GrBicubicEffect() { } -const GrBackendFragmentProcessorFactory& GrBicubicEffect::getFactory() const { - return GrTBackendFragmentProcessorFactory<GrBicubicEffect>::getInstance(); +void GrBicubicEffect::getGLProcessorKey(const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GrGLBicubicEffect::GenKey(*this, caps, b); +} + +GrGLFragmentProcessor* GrBicubicEffect::createGLInstance() const { + return SkNEW_ARGS(GrGLBicubicEffect, (*this)); } bool GrBicubicEffect::onIsEqual(const GrFragmentProcessor& sBase) const { diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h index 8f11825704..19fce03c7f 100644 --- a/src/gpu/effects/GrBicubicEffect.h +++ b/src/gpu/effects/GrBicubicEffect.h @@ -11,7 +11,6 @@ #include "GrSingleTextureEffect.h" #include "GrTextureDomain.h" #include "gl/GrGLProcessor.h" -#include "GrTBackendProcessorFactory.h" class GrGLBicubicEffect; class GrInvariantOutput; @@ -24,12 +23,13 @@ public: }; virtual ~GrBicubicEffect(); - static const char* Name() { return "Bicubic"; } const float* coefficients() const { return fCoefficients; } - typedef GrGLBicubicEffect GLProcessor; + virtual const char* name() const SK_OVERRIDE { return "Bicubic"; } - virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; + virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE; + + virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; const GrTextureDomain& domain() const { return fDomain; } diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index d487841789..e146411e32 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -8,17 +8,14 @@ #include "GrConfigConversionEffect.h" #include "GrContext.h" #include "GrInvariantOutput.h" -#include "GrTBackendProcessorFactory.h" #include "GrSimpleTextureEffect.h" +#include "SkMatrix.h" #include "gl/GrGLProcessor.h" #include "gl/builders/GrGLProgramBuilder.h" -#include "SkMatrix.h" class GrGLConfigConversionEffect : public GrGLFragmentProcessor { public: - GrGLConfigConversionEffect(const GrBackendProcessorFactory& factory, - const GrProcessor& processor) - : INHERITED (factory) { + GrGLConfigConversionEffect(const GrProcessor& processor) { const GrConfigConversionEffect& configConversionEffect = processor.cast<GrConfigConversionEffect>(); fSwapRedAndBlue = configConversionEffect.swapsRedAndBlue(); @@ -109,16 +106,13 @@ GrConfigConversionEffect::GrConfigConversionEffect(GrTexture* texture, : GrSingleTextureEffect(texture, matrix) , fSwapRedAndBlue(swapRedAndBlue) , fPMConversion(pmConversion) { + this->initClassID<GrConfigConversionEffect>(); SkASSERT(kRGBA_8888_GrPixelConfig == texture->config() || kBGRA_8888_GrPixelConfig == texture->config()); // Why did we pollute our texture cache instead of using a GrSingleTextureEffect? SkASSERT(swapRedAndBlue || kNone_PMConversion != pmConversion); } -const GrBackendFragmentProcessorFactory& GrConfigConversionEffect::getFactory() const { - return GrTBackendFragmentProcessorFactory<GrConfigConversionEffect>::getInstance(); -} - bool GrConfigConversionEffect::onIsEqual(const GrFragmentProcessor& s) const { const GrConfigConversionEffect& other = s.cast<GrConfigConversionEffect>(); return other.fSwapRedAndBlue == fSwapRedAndBlue && @@ -152,6 +146,16 @@ GrFragmentProcessor* GrConfigConversionEffect::TestCreate(SkRandom* random, } /////////////////////////////////////////////////////////////////////////////// + +void GrConfigConversionEffect::getGLProcessorKey(const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GrGLConfigConversionEffect::GenKey(*this, caps, b); +} + +GrGLFragmentProcessor* GrConfigConversionEffect::createGLInstance() const { + return SkNEW_ARGS(GrGLConfigConversionEffect, (*this)); +} + void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context, PMConversion* pmToUPMRule, PMConversion* upmToPMRule) { diff --git a/src/gpu/effects/GrConfigConversionEffect.h b/src/gpu/effects/GrConfigConversionEffect.h index 41ae1aca81..d85e783c27 100644 --- a/src/gpu/effects/GrConfigConversionEffect.h +++ b/src/gpu/effects/GrConfigConversionEffect.h @@ -11,7 +11,6 @@ #include "GrSingleTextureEffect.h" class GrFragmentStage; -class GrGLConfigConversionEffect; class GrInvariantOutput; /** @@ -38,10 +37,11 @@ public: static const GrFragmentProcessor* Create(GrTexture*, bool swapRedAndBlue, PMConversion, const SkMatrix&); - static const char* Name() { return "Config Conversion"; } - typedef GrGLConfigConversionEffect GLProcessor; + virtual const char* name() const SK_OVERRIDE { return "Config Conversion"; } - virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; + virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE; + + virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; bool swapsRedAndBlue() const { return fSwapRedAndBlue; } PMConversion pmConversion() const { return fPMConversion; } diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp index c2874e0045..6f93fb5277 100644 --- a/src/gpu/effects/GrConvexPolyEffect.cpp +++ b/src/gpu/effects/GrConvexPolyEffect.cpp @@ -5,36 +5,34 @@ * found in the LICENSE file. */ -#include "gl/builders/GrGLProgramBuilder.h" #include "GrConvexPolyEffect.h" #include "GrInvariantOutput.h" +#include "SkPath.h" #include "gl/GrGLProcessor.h" #include "gl/GrGLSL.h" -#include "GrTBackendProcessorFactory.h" - -#include "SkPath.h" +#include "gl/builders/GrGLProgramBuilder.h" ////////////////////////////////////////////////////////////////////////////// -class GLAARectEffect; - class AARectEffect : public GrFragmentProcessor { public: - typedef GLAARectEffect GLProcessor; - const SkRect& getRect() const { return fRect; } - static const char* Name() { return "AARect"; } - static GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, const SkRect& rect) { return SkNEW_ARGS(AARectEffect, (edgeType, rect)); } GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } - virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; + virtual const char* name() const SK_OVERRIDE { return "AARect"; } + + virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE; + + virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; private: - AARectEffect(GrPrimitiveEdgeType edgeType, const SkRect& rect) : fRect(rect), fEdgeType(edgeType) { + AARectEffect(GrPrimitiveEdgeType edgeType, const SkRect& rect) + : fRect(rect), fEdgeType(edgeType) { + this->initClassID<AARectEffect>(); this->setWillReadFragmentPosition(); } @@ -85,7 +83,7 @@ GrFragmentProcessor* AARectEffect::TestCreate(SkRandom* random, class GLAARectEffect : public GrGLFragmentProcessor { public: - GLAARectEffect(const GrBackendProcessorFactory&, const GrProcessor&); + GLAARectEffect(const GrProcessor&); virtual void emitCode(GrGLFPBuilder* builder, const GrFragmentProcessor& fp, @@ -104,9 +102,7 @@ private: typedef GrGLFragmentProcessor INHERITED; }; -GLAARectEffect::GLAARectEffect(const GrBackendProcessorFactory& factory, - const GrProcessor& effect) - : INHERITED (factory) { +GLAARectEffect::GLAARectEffect(const GrProcessor& effect) { fPrevRect.fLeft = SK_ScalarNaN; } @@ -169,15 +165,19 @@ void GLAARectEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, b->add32(aare.getEdgeType()); } -const GrBackendFragmentProcessorFactory& AARectEffect::getFactory() const { - return GrTBackendFragmentProcessorFactory<AARectEffect>::getInstance(); +void AARectEffect::getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const { + GLAARectEffect::GenKey(*this, caps, b); +} + +GrGLFragmentProcessor* AARectEffect::createGLInstance() const { + return SkNEW_ARGS(GLAARectEffect, (*this)); } ////////////////////////////////////////////////////////////////////////////// class GrGLConvexPolyEffect : public GrGLFragmentProcessor { public: - GrGLConvexPolyEffect(const GrBackendProcessorFactory&, const GrProcessor&); + GrGLConvexPolyEffect(const GrProcessor&); virtual void emitCode(GrGLFPBuilder* builder, const GrFragmentProcessor& fp, @@ -196,9 +196,7 @@ private: typedef GrGLFragmentProcessor INHERITED; }; -GrGLConvexPolyEffect::GrGLConvexPolyEffect(const GrBackendProcessorFactory& factory, - const GrProcessor&) - : INHERITED (factory) { +GrGLConvexPolyEffect::GrGLConvexPolyEffect(const GrProcessor&) { fPrevEdges[0] = SK_ScalarNaN; } @@ -326,13 +324,19 @@ void GrConvexPolyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) cons inout->mulByUnknownAlpha(); } -const GrBackendFragmentProcessorFactory& GrConvexPolyEffect::getFactory() const { - return GrTBackendFragmentProcessorFactory<GrConvexPolyEffect>::getInstance(); +void GrConvexPolyEffect::getGLProcessorKey(const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GrGLConvexPolyEffect::GenKey(*this, caps, b); +} + +GrGLFragmentProcessor* GrConvexPolyEffect::createGLInstance() const { + return SkNEW_ARGS(GrGLConvexPolyEffect, (*this)); } GrConvexPolyEffect::GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, const SkScalar edges[]) : fEdgeType(edgeType) , fEdgeCount(n) { + this->initClassID<GrConvexPolyEffect>(); // Factory function should have already ensured this. SkASSERT(n <= kMaxEdges); memcpy(fEdges, edges, 3 * n * sizeof(SkScalar)); diff --git a/src/gpu/effects/GrConvexPolyEffect.h b/src/gpu/effects/GrConvexPolyEffect.h index 7464d5447f..fec7e82b0e 100644 --- a/src/gpu/effects/GrConvexPolyEffect.h +++ b/src/gpu/effects/GrConvexPolyEffect.h @@ -9,10 +9,10 @@ #define GrConvexPolyEffect_DEFINED #include "GrDrawTargetCaps.h" +#include "GrFragmentProcessor.h" #include "GrProcessor.h" #include "GrTypesPriv.h" -class GrGLConvexPolyEffect; class GrInvariantOutput; class SkPath; @@ -61,7 +61,7 @@ public: virtual ~GrConvexPolyEffect(); - static const char* Name() { return "ConvexPoly"; } + virtual const char* name() const SK_OVERRIDE { return "ConvexPoly"; } GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } @@ -69,9 +69,9 @@ public: const SkScalar* getEdges() const { return fEdges; } - typedef GrGLConvexPolyEffect GLProcessor; + virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE; - virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; + virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; private: GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, const SkScalar edges[]); diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp index 6e1f3c4ce7..e4ac4ce381 100644 --- a/src/gpu/effects/GrConvolutionEffect.cpp +++ b/src/gpu/effects/GrConvolutionEffect.cpp @@ -5,19 +5,18 @@ * found in the LICENSE file. */ -#include "gl/builders/GrGLProgramBuilder.h" #include "GrConvolutionEffect.h" #include "gl/GrGLProcessor.h" #include "gl/GrGLSL.h" #include "gl/GrGLTexture.h" -#include "GrTBackendProcessorFactory.h" +#include "gl/builders/GrGLProgramBuilder.h" // For brevity typedef GrGLProgramDataManager::UniformHandle UniformHandle; class GrGLConvolutionEffect : public GrGLFragmentProcessor { public: - GrGLConvolutionEffect(const GrBackendProcessorFactory&, const GrProcessor&); + GrGLConvolutionEffect(const GrProcessor&); virtual void emitCode(GrGLFPBuilder*, const GrFragmentProcessor&, @@ -45,9 +44,7 @@ private: typedef GrGLFragmentProcessor INHERITED; }; -GrGLConvolutionEffect::GrGLConvolutionEffect(const GrBackendProcessorFactory& factory, - const GrProcessor& processor) - : INHERITED(factory) { +GrGLConvolutionEffect::GrGLConvolutionEffect(const GrProcessor& processor) { const GrConvolutionEffect& c = processor.cast<GrConvolutionEffect>(); fRadius = c.radius(); fUseBounds = c.useBounds(); @@ -155,6 +152,7 @@ GrConvolutionEffect::GrConvolutionEffect(GrTexture* texture, bool useBounds, float bounds[2]) : Gr1DKernelEffect(texture, direction, radius), fUseBounds(useBounds) { + this->initClassID<GrConvolutionEffect>(); SkASSERT(radius <= kMaxKernelRadius); SkASSERT(kernel); int width = this->width(); @@ -171,6 +169,7 @@ GrConvolutionEffect::GrConvolutionEffect(GrTexture* texture, bool useBounds, float bounds[2]) : Gr1DKernelEffect(texture, direction, radius), fUseBounds(useBounds) { + this->initClassID<GrConvolutionEffect>(); SkASSERT(radius <= kMaxKernelRadius); int width = this->width(); @@ -194,8 +193,13 @@ GrConvolutionEffect::GrConvolutionEffect(GrTexture* texture, GrConvolutionEffect::~GrConvolutionEffect() { } -const GrBackendFragmentProcessorFactory& GrConvolutionEffect::getFactory() const { - return GrTBackendFragmentProcessorFactory<GrConvolutionEffect>::getInstance(); +void GrConvolutionEffect::getGLProcessorKey(const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GrGLConvolutionEffect::GenKey(*this, caps, b); +} + +GrGLFragmentProcessor* GrConvolutionEffect::createGLInstance() const { + return SkNEW_ARGS(GrGLConvolutionEffect, (*this)); } bool GrConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) const { diff --git a/src/gpu/effects/GrConvolutionEffect.h b/src/gpu/effects/GrConvolutionEffect.h index e99e520cf0..7fda3699c3 100644 --- a/src/gpu/effects/GrConvolutionEffect.h +++ b/src/gpu/effects/GrConvolutionEffect.h @@ -11,8 +11,6 @@ #include "Gr1DKernelEffect.h" #include "GrInvariantOutput.h" -class GrGLConvolutionEffect; - /** * A convolution effect. The kernel is specified as an array of 2 * half-width * + 1 weights. Each texel is multiplied by it's weight and summed to determine @@ -59,11 +57,11 @@ public: const float* bounds() const { return fBounds; } bool useBounds() const { return fUseBounds; } - static const char* Name() { return "Convolution"; } + virtual const char* name() const SK_OVERRIDE { return "Convolution"; } - typedef GrGLConvolutionEffect GLProcessor; + virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE; - virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; + virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; enum { // This was decided based on the min allowed value for the max texture diff --git a/src/gpu/effects/GrCustomCoordsTextureEffect.cpp b/src/gpu/effects/GrCustomCoordsTextureEffect.cpp index 637d442d13..a132e86cf9 100644 --- a/src/gpu/effects/GrCustomCoordsTextureEffect.cpp +++ b/src/gpu/effects/GrCustomCoordsTextureEffect.cpp @@ -7,20 +7,17 @@ #include "GrCustomCoordsTextureEffect.h" #include "GrInvariantOutput.h" -#include "gl/builders/GrGLProgramBuilder.h" +#include "GrTexture.h" #include "gl/GrGLProcessor.h" #include "gl/GrGLSL.h" #include "gl/GrGLTexture.h" #include "gl/GrGLGeometryProcessor.h" -#include "GrTBackendProcessorFactory.h" -#include "GrTexture.h" +#include "gl/builders/GrGLProgramBuilder.h" class GrGLCustomCoordsTextureEffect : public GrGLGeometryProcessor { public: - GrGLCustomCoordsTextureEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) - : INHERITED (factory) {} + GrGLCustomCoordsTextureEffect(const GrGeometryProcessor&, + const GrBatchTracker&) {} virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { const GrCustomCoordsTextureEffect& cte = @@ -74,6 +71,7 @@ GrCustomCoordsTextureEffect::GrCustomCoordsTextureEffect(GrTexture* texture, const GrTextureParams& params, bool hasColor) : fTextureAccess(texture, params), fInColor(NULL) { + this->initClassID<GrCustomCoordsTextureEffect>(); fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType)); if (hasColor) { fInColor = &this->addVertexAttrib(GrAttribute("inColor", kVec4ub_GrVertexAttribType)); @@ -99,10 +97,16 @@ void GrCustomCoordsTextureEffect::onComputeInvariantOutput(GrInvariantOutput* in } } -const GrBackendGeometryProcessorFactory& GrCustomCoordsTextureEffect::getFactory() const { - return GrTBackendGeometryProcessorFactory<GrCustomCoordsTextureEffect>::getInstance(); +void GrCustomCoordsTextureEffect::getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GrGLCustomCoordsTextureEffect::GenKey(*this, bt, caps, b); } +GrGLGeometryProcessor* +GrCustomCoordsTextureEffect::createGLInstance(const GrBatchTracker& bt) const { + return SkNEW_ARGS(GrGLCustomCoordsTextureEffect, (*this, bt)); +} /////////////////////////////////////////////////////////////////////////////// GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCustomCoordsTextureEffect); diff --git a/src/gpu/effects/GrCustomCoordsTextureEffect.h b/src/gpu/effects/GrCustomCoordsTextureEffect.h index 89fc9355f6..a2b62ed3b8 100644 --- a/src/gpu/effects/GrCustomCoordsTextureEffect.h +++ b/src/gpu/effects/GrCustomCoordsTextureEffect.h @@ -27,15 +27,17 @@ public: virtual ~GrCustomCoordsTextureEffect() {} - static const char* Name() { return "Texture"; } + virtual const char* name() const SK_OVERRIDE { return "Texture"; } const GrAttribute* inPosition() const { return fInPosition; } const GrAttribute* inColor() const { return fInColor; } const GrAttribute* inTextureCoords() const { return fInTextureCoords; } - typedef GrGLCustomCoordsTextureEffect GLProcessor; + virtual void getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE; - virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE; + virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE; private: GrCustomCoordsTextureEffect(GrTexture* texture, const GrTextureParams& params, bool hasColor); diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp index fec1551ef5..be1b5e5bb4 100644 --- a/src/gpu/effects/GrDashingEffect.cpp +++ b/src/gpu/effects/GrDashingEffect.cpp @@ -18,7 +18,6 @@ #include "GrInvariantOutput.h" #include "GrProcessor.h" #include "GrStrokeInfo.h" -#include "GrTBackendProcessorFactory.h" #include "SkGr.h" #include "gl/GrGLGeometryProcessor.h" #include "gl/GrGLProcessor.h" @@ -463,7 +462,7 @@ public: virtual ~DashingCircleEffect(); - static const char* Name() { return "DashingCircleEffect"; } + virtual const char* name() const SK_OVERRIDE { return "DashingCircleEffect"; } const GrAttribute* inPosition() const { return fInPosition; } @@ -477,9 +476,11 @@ public: SkScalar getIntervalLength() const { return fIntervalLength; } - typedef GLDashingCircleEffect GLProcessor; + virtual void getGLProcessorKey(const GrBatchTracker&, + const GrGLCaps&, + GrProcessorKeyBuilder* b) const SK_OVERRIDE; - virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE; + virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker&) const SK_OVERRIDE; private: DashingCircleEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info, SkScalar radius); @@ -504,9 +505,7 @@ private: class GLDashingCircleEffect : public GrGLGeometryProcessor { public: - GLDashingCircleEffect(const GrBackendProcessorFactory&, - const GrGeometryProcessor&, - const GrBatchTracker&); + GLDashingCircleEffect(const GrGeometryProcessor&, const GrBatchTracker&); virtual void emitCode(const EmitArgs&) SK_OVERRIDE; @@ -527,10 +526,8 @@ private: typedef GrGLGeometryProcessor INHERITED; }; -GLDashingCircleEffect::GLDashingCircleEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) - : INHERITED (factory) { +GLDashingCircleEffect::GLDashingCircleEffect(const GrGeometryProcessor&, + const GrBatchTracker&) { fPrevRadius = SK_ScalarMin; fPrevCenterX = SK_ScalarMin; fPrevIntervalLength = SK_ScalarMax; @@ -618,13 +615,20 @@ void DashingCircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) con inout->mulByUnknownAlpha(); } -const GrBackendGeometryProcessorFactory& DashingCircleEffect::getFactory() const { - return GrTBackendGeometryProcessorFactory<DashingCircleEffect>::getInstance(); +void DashingCircleEffect::getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GLDashingCircleEffect::GenKey(*this, bt, caps, b); +} + +GrGLGeometryProcessor* DashingCircleEffect::createGLInstance(const GrBatchTracker& bt) const { + return SkNEW_ARGS(GLDashingCircleEffect, (*this, bt)); } DashingCircleEffect::DashingCircleEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info, SkScalar radius) : fEdgeType(edgeType) { + this->initClassID<DashingCircleEffect>(); fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType)); fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttribType)); SkScalar onLen = info.fIntervals[0]; @@ -685,7 +689,7 @@ public: virtual ~DashingLineEffect(); - static const char* Name() { return "DashingEffect"; } + virtual const char* name() const SK_OVERRIDE { return "DashingEffect"; } const GrAttribute* inPosition() const { return fInPosition; } @@ -697,9 +701,11 @@ public: SkScalar getIntervalLength() const { return fIntervalLength; } - typedef GLDashingLineEffect GLProcessor; + virtual void getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE; - virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE; + virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE; private: DashingLineEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info, SkScalar strokeWidth); @@ -723,9 +729,7 @@ private: class GLDashingLineEffect : public GrGLGeometryProcessor { public: - GLDashingLineEffect(const GrBackendProcessorFactory&, - const GrGeometryProcessor&, - const GrBatchTracker&); + GLDashingLineEffect(const GrGeometryProcessor&, const GrBatchTracker&); virtual void emitCode(const EmitArgs&) SK_OVERRIDE; @@ -746,10 +750,8 @@ private: typedef GrGLGeometryProcessor INHERITED; }; -GLDashingLineEffect::GLDashingLineEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) - : INHERITED (factory) { +GLDashingLineEffect::GLDashingLineEffect(const GrGeometryProcessor&, + const GrBatchTracker&) { fPrevRect.fLeft = SK_ScalarNaN; fPrevIntervalLength = SK_ScalarMax; } @@ -851,13 +853,20 @@ void DashingLineEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const inout->mulByUnknownAlpha(); } -const GrBackendGeometryProcessorFactory& DashingLineEffect::getFactory() const { - return GrTBackendGeometryProcessorFactory<DashingLineEffect>::getInstance(); +void DashingLineEffect::getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GLDashingLineEffect::GenKey(*this, bt, caps, b); +} + +GrGLGeometryProcessor* DashingLineEffect::createGLInstance(const GrBatchTracker& bt) const { + return SkNEW_ARGS(GLDashingLineEffect, (*this, bt)); } DashingLineEffect::DashingLineEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info, SkScalar strokeWidth) : fEdgeType(edgeType) { + this->initClassID<DashingLineEffect>(); fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType)); fInCoord = &this->addVertexAttrib(GrAttribute("inCoord", kVec2f_GrVertexAttribType)); SkScalar onLen = info.fIntervals[0]; diff --git a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp index 53f85907e4..f1f4a9fbb1 100755 --- a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp +++ b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp @@ -7,26 +7,22 @@ #include "GrDistanceFieldTextureEffect.h" #include "GrInvariantOutput.h" -#include "gl/builders/GrGLProgramBuilder.h" +#include "GrTexture.h" +#include "SkDistanceFieldGen.h" #include "gl/GrGLProcessor.h" #include "gl/GrGLSL.h" #include "gl/GrGLTexture.h" #include "gl/GrGLGeometryProcessor.h" -#include "GrTBackendProcessorFactory.h" -#include "GrTexture.h" - -#include "SkDistanceFieldGen.h" +#include "gl/builders/GrGLProgramBuilder.h" // Assuming a radius of the diagonal of the fragment, hence a factor of sqrt(2)/2 #define SK_DistanceFieldAAFactor "0.7071" class GrGLDistanceFieldTextureEffect : public GrGLGeometryProcessor { public: - GrGLDistanceFieldTextureEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, + GrGLDistanceFieldTextureEffect(const GrGeometryProcessor&, const GrBatchTracker&) - : INHERITED (factory) - , fTextureSize(SkISize::Make(-1,-1)) + : fTextureSize(SkISize::Make(-1,-1)) #ifdef SK_GAMMA_APPLY_TO_A8 , fLuminance(-1.0f) #endif @@ -185,6 +181,7 @@ GrDistanceFieldTextureEffect::GrDistanceFieldTextureEffect(GrTexture* texture, , fFlags(flags & kNonLCD_DistanceFieldEffectMask) , fInColor(NULL) { SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); + this->initClassID<GrDistanceFieldTextureEffect>(); fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType)); if (flags & kColorAttr_DistanceFieldEffectFlag) { fInColor = &this->addVertexAttrib(GrAttribute("inColor", kVec4ub_GrVertexAttribType)); @@ -211,8 +208,15 @@ void GrDistanceFieldTextureEffect::onComputeInvariantOutput(GrInvariantOutput* i inout->mulByUnknownAlpha(); } -const GrBackendGeometryProcessorFactory& GrDistanceFieldTextureEffect::getFactory() const { - return GrTBackendGeometryProcessorFactory<GrDistanceFieldTextureEffect>::getInstance(); +void GrDistanceFieldTextureEffect::getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GrGLDistanceFieldTextureEffect::GenKey(*this, bt, caps, b); +} + +GrGLGeometryProcessor* +GrDistanceFieldTextureEffect::createGLInstance(const GrBatchTracker& bt) const { + return SkNEW_ARGS(GrGLDistanceFieldTextureEffect, (*this, bt)); } /////////////////////////////////////////////////////////////////////////////// @@ -258,11 +262,9 @@ GrGeometryProcessor* GrDistanceFieldTextureEffect::TestCreate(SkRandom* random, class GrGLDistanceFieldNoGammaTextureEffect : public GrGLGeometryProcessor { public: - GrGLDistanceFieldNoGammaTextureEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, + GrGLDistanceFieldNoGammaTextureEffect(const GrGeometryProcessor&, const GrBatchTracker&) - : INHERITED(factory) - , fTextureSize(SkISize::Make(-1, -1)) {} + : fTextureSize(SkISize::Make(-1, -1)) {} virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { const GrDistanceFieldNoGammaTextureEffect& dfTexEffect = @@ -383,6 +385,7 @@ GrDistanceFieldNoGammaTextureEffect::GrDistanceFieldNoGammaTextureEffect(GrTextu , fFlags(flags & kNonLCD_DistanceFieldEffectMask) , fInColor(NULL) { SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); + this->initClassID<GrDistanceFieldNoGammaTextureEffect>(); fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType)); if (flags & kColorAttr_DistanceFieldEffectFlag) { fInColor = &this->addVertexAttrib(GrAttribute("inColor", kVec4ub_GrVertexAttribType)); @@ -403,8 +406,15 @@ void GrDistanceFieldNoGammaTextureEffect::onComputeInvariantOutput(GrInvariantOu inout->mulByUnknownAlpha(); } -const GrBackendGeometryProcessorFactory& GrDistanceFieldNoGammaTextureEffect::getFactory() const { - return GrTBackendGeometryProcessorFactory<GrDistanceFieldNoGammaTextureEffect>::getInstance(); +void GrDistanceFieldNoGammaTextureEffect::getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GrGLDistanceFieldNoGammaTextureEffect::GenKey(*this, bt, caps, b); +} + +GrGLGeometryProcessor* +GrDistanceFieldNoGammaTextureEffect::createGLInstance(const GrBatchTracker& bt) const { + return SkNEW_ARGS(GrGLDistanceFieldNoGammaTextureEffect, (*this, bt)); } /////////////////////////////////////////////////////////////////////////////// @@ -437,11 +447,9 @@ GrGeometryProcessor* GrDistanceFieldNoGammaTextureEffect::TestCreate(SkRandom* r class GrGLDistanceFieldLCDTextureEffect : public GrGLGeometryProcessor { public: - GrGLDistanceFieldLCDTextureEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, + GrGLDistanceFieldLCDTextureEffect(const GrGeometryProcessor&, const GrBatchTracker&) - : INHERITED (factory) - , fTextureSize(SkISize::Make(-1,-1)) + : fTextureSize(SkISize::Make(-1,-1)) , fTextColor(GrColor_ILLEGAL) {} virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { @@ -635,6 +643,7 @@ GrDistanceFieldLCDTextureEffect::GrDistanceFieldLCDTextureEffect( , fTextColor(textColor) , fFlags(flags & kLCD_DistanceFieldEffectMask){ SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_DistanceFieldEffectFlag)); + this->initClassID<GrDistanceFieldLCDTextureEffect>(); fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVertexAttribType)); fInTextureCoords = &this->addVertexAttrib(GrAttribute("inTextureCoords", kVec2f_GrVertexAttribType)); @@ -652,8 +661,15 @@ void GrDistanceFieldLCDTextureEffect::onComputeInvariantOutput(GrInvariantOutput inout->mulByUnknownColor(); } -const GrBackendGeometryProcessorFactory& GrDistanceFieldLCDTextureEffect::getFactory() const { - return GrTBackendGeometryProcessorFactory<GrDistanceFieldLCDTextureEffect>::getInstance(); +void GrDistanceFieldLCDTextureEffect::getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GrGLDistanceFieldLCDTextureEffect::GenKey(*this, bt, caps, b); +} + +GrGLGeometryProcessor* +GrDistanceFieldLCDTextureEffect::createGLInstance(const GrBatchTracker& bt) const { + return SkNEW_ARGS(GrGLDistanceFieldLCDTextureEffect, (*this, bt)); } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/effects/GrDistanceFieldTextureEffect.h b/src/gpu/effects/GrDistanceFieldTextureEffect.h index a074d69f63..1dfa1b4711 100644 --- a/src/gpu/effects/GrDistanceFieldTextureEffect.h +++ b/src/gpu/effects/GrDistanceFieldTextureEffect.h @@ -62,7 +62,7 @@ public: virtual ~GrDistanceFieldTextureEffect() {} - static const char* Name() { return "DistanceFieldTexture"; } + virtual const char* name() const SK_OVERRIDE { return "DistanceFieldTexture"; } const GrAttribute* inPosition() const { return fInPosition; } const GrAttribute* inColor() const { return fInColor; } @@ -72,9 +72,11 @@ public: #endif uint32_t getFlags() const { return fFlags; } - typedef GrGLDistanceFieldTextureEffect GLProcessor; + virtual void getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE; - virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE; + virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE; private: GrDistanceFieldTextureEffect(GrTexture* texture, const GrTextureParams& params, @@ -118,16 +120,18 @@ public: virtual ~GrDistanceFieldNoGammaTextureEffect() {} - static const char* Name() { return "DistanceFieldTexture"; } + virtual const char* name() const SK_OVERRIDE { return "DistanceFieldTexture"; } const GrAttribute* inPosition() const { return fInPosition; } const GrAttribute* inColor() const { return fInColor; } const GrAttribute* inTextureCoords() const { return fInTextureCoords; } uint32_t getFlags() const { return fFlags; } - typedef GrGLDistanceFieldNoGammaTextureEffect GLProcessor; + virtual void getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE; - virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE; + virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE; private: GrDistanceFieldNoGammaTextureEffect(GrTexture* texture, const GrTextureParams& params, @@ -165,16 +169,18 @@ public: virtual ~GrDistanceFieldLCDTextureEffect() {} - static const char* Name() { return "DistanceFieldLCDTexture"; } + virtual const char* name() const SK_OVERRIDE { return "DistanceFieldLCDTexture"; } const GrAttribute* inPosition() const { return fInPosition; } const GrAttribute* inTextureCoords() const { return fInTextureCoords; } GrColor getTextColor() const { return fTextColor; } uint32_t getFlags() const { return fFlags; } - typedef GrGLDistanceFieldLCDTextureEffect GLProcessor; + virtual void getGLProcessorKey(const GrBatchTracker& bt, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE; - virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE; + virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_OVERRIDE; private: GrDistanceFieldLCDTextureEffect(GrTexture* texture, const GrTextureParams& params, diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp index 438fe2c60a..799d970601 100644 --- a/src/gpu/effects/GrDitherEffect.cpp +++ b/src/gpu/effects/GrDitherEffect.cpp @@ -5,19 +5,16 @@ * found in the LICENSE file. */ -#include "gl/builders/GrGLProgramBuilder.h" #include "GrDitherEffect.h" +#include "GrFragmentProcessor.h" #include "GrInvariantOutput.h" +#include "SkRect.h" #include "gl/GrGLProcessor.h" #include "gl/GrGLSL.h" -#include "GrTBackendProcessorFactory.h" - -#include "SkRect.h" +#include "gl/builders/GrGLProgramBuilder.h" ////////////////////////////////////////////////////////////////////////////// -class GLDitherEffect; - class DitherEffect : public GrFragmentProcessor { public: static GrFragmentProcessor* Create() { @@ -26,16 +23,16 @@ public: } virtual ~DitherEffect() {}; - static const char* Name() { return "Dither"; } - typedef GLDitherEffect GLProcessor; + virtual const char* name() const SK_OVERRIDE { return "Dither"; } - virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE { - return GrTBackendFragmentProcessorFactory<DitherEffect>::getInstance(); - } + virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE; + + virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; private: DitherEffect() { + this->initClassID<DitherEffect>(); this->setWillReadFragmentPosition(); } @@ -68,7 +65,7 @@ GrFragmentProcessor* DitherEffect::TestCreate(SkRandom*, class GLDitherEffect : public GrGLFragmentProcessor { public: - GLDitherEffect(const GrBackendProcessorFactory&, const GrProcessor&); + GLDitherEffect(const GrProcessor&); virtual void emitCode(GrGLFPBuilder* builder, const GrFragmentProcessor& fp, @@ -81,9 +78,7 @@ private: typedef GrGLFragmentProcessor INHERITED; }; -GLDitherEffect::GLDitherEffect(const GrBackendProcessorFactory& factory, - const GrProcessor&) - : INHERITED (factory) { +GLDitherEffect::GLDitherEffect(const GrProcessor&) { } void GLDitherEffect::emitCode(GrGLFPBuilder* builder, @@ -111,4 +106,13 @@ void GLDitherEffect::emitCode(GrGLFPBuilder* builder, ////////////////////////////////////////////////////////////////////////////// +void DitherEffect::getGLProcessorKey(const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GLDitherEffect::GenKey(*this, caps, b); +} + +GrGLFragmentProcessor* DitherEffect::createGLInstance() const { + return SkNEW_ARGS(GLDitherEffect, (*this)); +} + GrFragmentProcessor* GrDitherEffect::Create() { return DitherEffect::Create(); } diff --git a/src/gpu/effects/GrDitherEffect.h b/src/gpu/effects/GrDitherEffect.h index ac4c784406..64c85f7bf4 100644 --- a/src/gpu/effects/GrDitherEffect.h +++ b/src/gpu/effects/GrDitherEffect.h @@ -11,7 +11,7 @@ #include "GrTypes.h" #include "GrTypesPriv.h" -class GrProcessor; +class GrFragmentProcessor; namespace GrDitherEffect { /** diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp index 698b7050ef..3cd3588a4c 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp +++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp @@ -4,17 +4,15 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include "gl/builders/GrGLProgramBuilder.h" #include "GrMatrixConvolutionEffect.h" #include "gl/GrGLProcessor.h" #include "gl/GrGLSL.h" #include "gl/GrGLTexture.h" -#include "GrTBackendProcessorFactory.h" +#include "gl/builders/GrGLProgramBuilder.h" class GrGLMatrixConvolutionEffect : public GrGLFragmentProcessor { public: - GrGLMatrixConvolutionEffect(const GrBackendProcessorFactory& factory, - const GrProcessor&); + GrGLMatrixConvolutionEffect(const GrProcessor&); virtual void emitCode(GrGLFPBuilder*, const GrFragmentProcessor&, const char* outputColor, @@ -42,9 +40,7 @@ private: typedef GrGLFragmentProcessor INHERITED; }; -GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendProcessorFactory& factory, - const GrProcessor& processor) - : INHERITED(factory) { +GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrProcessor& processor) { const GrMatrixConvolutionEffect& m = processor.cast<GrMatrixConvolutionEffect>(); fKernelSize = m.kernelSize(); fConvolveAlpha = m.convolveAlpha(); @@ -160,6 +156,7 @@ GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrTexture* texture, fBias(SkScalarToFloat(bias) / 255.0f), fConvolveAlpha(convolveAlpha), fDomain(GrTextureDomain::MakeTexelDomain(texture, bounds), tileMode) { + this->initClassID<GrMatrixConvolutionEffect>(); for (int i = 0; i < kernelSize.width() * kernelSize.height(); i++) { fKernel[i] = SkScalarToFloat(kernel[i]); } @@ -170,8 +167,13 @@ GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrTexture* texture, GrMatrixConvolutionEffect::~GrMatrixConvolutionEffect() { } -const GrBackendFragmentProcessorFactory& GrMatrixConvolutionEffect::getFactory() const { - return GrTBackendFragmentProcessorFactory<GrMatrixConvolutionEffect>::getInstance(); +void GrMatrixConvolutionEffect::getGLProcessorKey(const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GrGLMatrixConvolutionEffect::GenKey(*this, caps, b); +} + +GrGLFragmentProcessor* GrMatrixConvolutionEffect::createGLInstance() const { + return SkNEW_ARGS(GrGLMatrixConvolutionEffect, (*this)); } bool GrMatrixConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) const { diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.h b/src/gpu/effects/GrMatrixConvolutionEffect.h index 999606213d..6d60609e31 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.h +++ b/src/gpu/effects/GrMatrixConvolutionEffect.h @@ -16,8 +16,6 @@ // Allows for a 5x5 kernel (or 25x1, for that matter). #define MAX_KERNEL_SIZE 25 -class GrGLMatrixConvolutionEffect; - class GrMatrixConvolutionEffect : public GrSingleTextureEffect { public: static GrFragmentProcessor* Create(GrTexture* texture, @@ -53,7 +51,6 @@ public: virtual ~GrMatrixConvolutionEffect(); - static const char* Name() { return "MatrixConvolution"; } const SkIRect& bounds() const { return fBounds; } const SkISize& kernelSize() const { return fKernelSize; } const float* kernelOffset() const { return fKernelOffset; } @@ -63,9 +60,11 @@ public: bool convolveAlpha() const { return fConvolveAlpha; } const GrTextureDomain& domain() const { return fDomain; } - typedef GrGLMatrixConvolutionEffect GLProcessor; + virtual const char* name() const SK_OVERRIDE { return "MatrixConvolution"; } + + virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE; - virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; + virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; private: GrMatrixConvolutionEffect(GrTexture*, diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp index 37555eac51..1ea93a927b 100644 --- a/src/gpu/effects/GrOvalEffect.cpp +++ b/src/gpu/effects/GrOvalEffect.cpp @@ -5,35 +5,34 @@ * found in the LICENSE file. */ -#include "gl/builders/GrGLProgramBuilder.h" #include "GrOvalEffect.h" + +#include "GrFragmentProcessor.h" #include "GrInvariantOutput.h" +#include "SkRect.h" #include "gl/GrGLProcessor.h" #include "gl/GrGLSL.h" -#include "GrTBackendProcessorFactory.h" - -#include "SkRect.h" +#include "gl/builders/GrGLProgramBuilder.h" ////////////////////////////////////////////////////////////////////////////// -class GLCircleEffect; - class CircleEffect : public GrFragmentProcessor { public: static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPoint& center, SkScalar radius); virtual ~CircleEffect() {}; - static const char* Name() { return "Circle"; } + + virtual const char* name() const SK_OVERRIDE { return "Circle"; } + + virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE; + + virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; const SkPoint& getCenter() const { return fCenter; } SkScalar getRadius() const { return fRadius; } GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } - typedef GLCircleEffect GLProcessor; - - virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; - private: CircleEffect(GrPrimitiveEdgeType, const SkPoint& center, SkScalar radius); @@ -60,14 +59,11 @@ void CircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { inout->mulByUnknownAlpha(); } -const GrBackendFragmentProcessorFactory& CircleEffect::getFactory() const { - return GrTBackendFragmentProcessorFactory<CircleEffect>::getInstance(); -} - CircleEffect::CircleEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkScalar r) : fCenter(c) , fRadius(r) , fEdgeType(edgeType) { + this->initClassID<CircleEffect>(); this->setWillReadFragmentPosition(); } @@ -99,7 +95,7 @@ GrFragmentProcessor* CircleEffect::TestCreate(SkRandom* random, class GLCircleEffect : public GrGLFragmentProcessor { public: - GLCircleEffect(const GrBackendProcessorFactory&, const GrProcessor&); + GLCircleEffect(const GrProcessor&); virtual void emitCode(GrGLFPBuilder* builder, const GrFragmentProcessor& fp, @@ -120,9 +116,7 @@ private: typedef GrGLFragmentProcessor INHERITED; }; -GLCircleEffect::GLCircleEffect(const GrBackendProcessorFactory& factory, - const GrProcessor&) - : INHERITED (factory) { +GLCircleEffect::GLCircleEffect(const GrProcessor&) { fPrevRadius = -1.f; } @@ -183,9 +177,18 @@ void GLCircleEffect::setData(const GrGLProgramDataManager& pdman, const GrProces } } -////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////////////////////// + +void CircleEffect::getGLProcessorKey(const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GLCircleEffect::GenKey(*this, caps, b); +} + +GrGLFragmentProcessor* CircleEffect::createGLInstance() const { + return SkNEW_ARGS(GLCircleEffect, (*this)); +} -class GLEllipseEffect; +////////////////////////////////////////////////////////////////////////////// class EllipseEffect : public GrFragmentProcessor { public: @@ -193,17 +196,18 @@ public: SkScalar ry); virtual ~EllipseEffect() {}; - static const char* Name() { return "Ellipse"; } + + virtual const char* name() const SK_OVERRIDE { return "Ellipse"; } + + virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE; + + virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; const SkPoint& getCenter() const { return fCenter; } SkVector getRadii() const { return fRadii; } GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } - typedef GLEllipseEffect GLProcessor; - - virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; - private: EllipseEffect(GrPrimitiveEdgeType, const SkPoint& center, SkScalar rx, SkScalar ry); @@ -232,14 +236,11 @@ void EllipseEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { inout->mulByUnknownAlpha(); } -const GrBackendFragmentProcessorFactory& EllipseEffect::getFactory() const { - return GrTBackendFragmentProcessorFactory<EllipseEffect>::getInstance(); -} - EllipseEffect::EllipseEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkScalar rx, SkScalar ry) : fCenter(c) , fRadii(SkVector::Make(rx, ry)) , fEdgeType(edgeType) { + this->initClassID<EllipseEffect>(); this->setWillReadFragmentPosition(); } @@ -272,7 +273,7 @@ GrFragmentProcessor* EllipseEffect::TestCreate(SkRandom* random, class GLEllipseEffect : public GrGLFragmentProcessor { public: - GLEllipseEffect(const GrBackendProcessorFactory&, const GrProcessor&); + GLEllipseEffect(const GrProcessor&); virtual void emitCode(GrGLFPBuilder* builder, const GrFragmentProcessor& fp, @@ -293,9 +294,7 @@ private: typedef GrGLFragmentProcessor INHERITED; }; -GLEllipseEffect::GLEllipseEffect(const GrBackendProcessorFactory& factory, - const GrProcessor& effect) - : INHERITED (factory) { +GLEllipseEffect::GLEllipseEffect(const GrProcessor& effect) { fPrevRadii.fX = -1.f; } @@ -365,6 +364,17 @@ void GLEllipseEffect::setData(const GrGLProgramDataManager& pdman, const GrProce } } +/////////////////////////////////////////////////////////////////////////////////////////////////// + +void EllipseEffect::getGLProcessorKey(const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GLEllipseEffect::GenKey(*this, caps, b); +} + +GrGLFragmentProcessor* EllipseEffect::createGLInstance() const { + return SkNEW_ARGS(GLEllipseEffect, (*this)); +} + ////////////////////////////////////////////////////////////////////////////// GrFragmentProcessor* GrOvalEffect::Create(GrPrimitiveEdgeType edgeType, const SkRect& oval) { diff --git a/src/gpu/effects/GrOvalEffect.h b/src/gpu/effects/GrOvalEffect.h index 41e22cc00c..8f85365731 100644 --- a/src/gpu/effects/GrOvalEffect.h +++ b/src/gpu/effects/GrOvalEffect.h @@ -11,7 +11,7 @@ #include "GrTypes.h" #include "GrTypesPriv.h" -class GrProcessor; +class GrFragmentProcessor; struct SkRect; namespace GrOvalEffect { diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp index 1f50f9d524..5c842a890a 100644 --- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp +++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp @@ -7,11 +7,9 @@ #include "GrPorterDuffXferProcessor.h" -#include "GrBackendProcessorFactory.h" #include "GrDrawState.h" #include "GrInvariantOutput.h" #include "GrProcessor.h" -#include "GrTBackendProcessorFactory.h" #include "GrTypes.h" #include "GrXferProcessor.h" #include "gl/GrGLProcessor.h" @@ -20,8 +18,7 @@ class GrGLPorterDuffXferProcessor : public GrGLXferProcessor { public: - GrGLPorterDuffXferProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&) - : INHERITED(factory) {} + GrGLPorterDuffXferProcessor(const GrProcessor&) {} virtual ~GrGLPorterDuffXferProcessor() {} @@ -46,13 +43,20 @@ private: /////////////////////////////////////////////////////////////////////////////// GrPorterDuffXferProcessor::GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend) - : fSrcBlend(srcBlend), fDstBlend(dstBlend) {} + : fSrcBlend(srcBlend), fDstBlend(dstBlend) { + this->initClassID<GrPorterDuffXferProcessor>(); +} GrPorterDuffXferProcessor::~GrPorterDuffXferProcessor() { } -const GrBackendFragmentProcessorFactory& GrPorterDuffXferProcessor::getFactory() const { - return GrTBackendFragmentProcessorFactory<GrPorterDuffXferProcessor>::getInstance(); +void GrPorterDuffXferProcessor::getGLProcessorKey(const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GrGLPorterDuffXferProcessor::GenKey(*this, caps, b); +} + +GrGLFragmentProcessor* GrPorterDuffXferProcessor::createGLInstance() const { + return SkNEW_ARGS(GrGLPorterDuffXferProcessor, (*this)); } void GrPorterDuffXferProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const { diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.h b/src/gpu/effects/GrPorterDuffXferProcessor.h index d210a81755..d1b30cc931 100644 --- a/src/gpu/effects/GrPorterDuffXferProcessor.h +++ b/src/gpu/effects/GrPorterDuffXferProcessor.h @@ -12,9 +12,7 @@ #include "GrXferProcessor.h" #include "SkXfermode.h" -class GrBackendFragmentProcessorFactory; class GrDrawState; -class GrGLPorterDuffXferProcessor; class GrInvariantOutput; class GrPorterDuffXferProcessor : public GrXferProcessor { @@ -25,10 +23,12 @@ public: virtual ~GrPorterDuffXferProcessor(); - virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; + virtual const char* name() const { return "Porter Duff"; } - typedef GrGLPorterDuffXferProcessor GLProcessor; - static const char* Name() { return "Porter Duff"; } + virtual void getGLProcessorKey(const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE; + + virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; private: GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend); diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp index 7e58c1fe28..4c8e88636e 100644 --- a/src/gpu/effects/GrRRectEffect.cpp +++ b/src/gpu/effects/GrRRectEffect.cpp @@ -5,25 +5,22 @@ * found in the LICENSE file. */ -#include "gl/builders/GrGLProgramBuilder.h" #include "GrRRectEffect.h" -#include "gl/GrGLProcessor.h" -#include "gl/GrGLSL.h" #include "GrConvexPolyEffect.h" +#include "GrFragmentProcessor.h" #include "GrInvariantOutput.h" #include "GrOvalEffect.h" -#include "GrTBackendProcessorFactory.h" - #include "SkRRect.h" +#include "gl/GrGLProcessor.h" +#include "gl/GrGLSL.h" +#include "gl/builders/GrGLProgramBuilder.h" // The effects defined here only handle rrect radii >= kRadiusMin. static const SkScalar kRadiusMin = SK_ScalarHalf; ////////////////////////////////////////////////////////////////////////////// -class GLCircularRRectEffect; - class CircularRRectEffect : public GrFragmentProcessor { public: @@ -50,7 +47,12 @@ public: const SkRRect&); virtual ~CircularRRectEffect() {}; - static const char* Name() { return "CircularRRect"; } + + virtual const char* name() const SK_OVERRIDE { return "CircularRRect"; } + + virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE; + + virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; const SkRRect& getRRect() const { return fRRect; } @@ -58,10 +60,6 @@ public: GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } - typedef GLCircularRRectEffect GLProcessor; - - virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; - private: CircularRRectEffect(GrPrimitiveEdgeType, uint32_t circularCornerFlags, const SkRRect&); @@ -91,15 +89,12 @@ void CircularRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) con inout->mulByUnknownAlpha(); } -const GrBackendFragmentProcessorFactory& CircularRRectEffect::getFactory() const { - return GrTBackendFragmentProcessorFactory<CircularRRectEffect>::getInstance(); -} - CircularRRectEffect::CircularRRectEffect(GrPrimitiveEdgeType edgeType, uint32_t circularCornerFlags, const SkRRect& rrect) : fRRect(rrect) , fEdgeType(edgeType) , fCircularCornerFlags(circularCornerFlags) { + this->initClassID<CircularRRectEffect>(); this->setWillReadFragmentPosition(); } @@ -135,7 +130,7 @@ GrFragmentProcessor* CircularRRectEffect::TestCreate(SkRandom* random, class GLCircularRRectEffect : public GrGLFragmentProcessor { public: - GLCircularRRectEffect(const GrBackendProcessorFactory&, const GrProcessor&); + GLCircularRRectEffect(const GrProcessor&); virtual void emitCode(GrGLFPBuilder* builder, const GrFragmentProcessor& fp, @@ -155,9 +150,7 @@ private: typedef GrGLFragmentProcessor INHERITED; }; -GLCircularRRectEffect::GLCircularRRectEffect(const GrBackendProcessorFactory& factory, - const GrProcessor& ) - : INHERITED (factory) { +GLCircularRRectEffect::GLCircularRRectEffect(const GrProcessor& ) { fPrevRRect.setEmpty(); } @@ -380,25 +373,34 @@ void GLCircularRRectEffect::setData(const GrGLProgramDataManager& pdman, } } -////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////// -class GLEllipticalRRectEffect; +void CircularRRectEffect::getGLProcessorKey(const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GLCircularRRectEffect::GenKey(*this, caps, b); +} + +GrGLFragmentProcessor* CircularRRectEffect::createGLInstance() const { + return SkNEW_ARGS(GLCircularRRectEffect, (*this)); +} + +////////////////////////////////////////////////////////////////////////////// class EllipticalRRectEffect : public GrFragmentProcessor { public: static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRRect&); virtual ~EllipticalRRectEffect() {}; - static const char* Name() { return "EllipticalRRect"; } - const SkRRect& getRRect() const { return fRRect; } + virtual const char* name() const SK_OVERRIDE { return "EllipticalRRect"; } + virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE; - GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } + virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; - typedef GLEllipticalRRectEffect GLProcessor; + const SkRRect& getRRect() const { return fRRect; } - virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; + GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } private: EllipticalRRectEffect(GrPrimitiveEdgeType, const SkRRect&); @@ -427,13 +429,10 @@ void EllipticalRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c inout->mulByUnknownAlpha(); } -const GrBackendFragmentProcessorFactory& EllipticalRRectEffect::getFactory() const { - return GrTBackendFragmentProcessorFactory<EllipticalRRectEffect>::getInstance(); -} - EllipticalRRectEffect::EllipticalRRectEffect(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) : fRRect(rrect) - , fEdgeType(edgeType){ + , fEdgeType(edgeType) { + this->initClassID<EllipticalRRectEffect>(); this->setWillReadFragmentPosition(); } @@ -488,7 +487,7 @@ GrFragmentProcessor* EllipticalRRectEffect::TestCreate(SkRandom* random, class GLEllipticalRRectEffect : public GrGLFragmentProcessor { public: - GLEllipticalRRectEffect(const GrBackendProcessorFactory&, const GrProcessor&); + GLEllipticalRRectEffect(const GrProcessor&); virtual void emitCode(GrGLFPBuilder* builder, const GrFragmentProcessor& effect, @@ -508,9 +507,7 @@ private: typedef GrGLFragmentProcessor INHERITED; }; -GLEllipticalRRectEffect::GLEllipticalRRectEffect(const GrBackendProcessorFactory& factory, - const GrProcessor& effect) - : INHERITED (factory) { +GLEllipticalRRectEffect::GLEllipticalRRectEffect(const GrProcessor& effect) { fPrevRRect.setEmpty(); } @@ -634,6 +631,17 @@ void GLEllipticalRRectEffect::setData(const GrGLProgramDataManager& pdman, } } +//////////////////////////////////////////////////////////////////////////////////////////////////// + +void EllipticalRRectEffect::getGLProcessorKey(const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GLEllipticalRRectEffect::GenKey(*this, caps, b); +} + +GrGLFragmentProcessor* EllipticalRRectEffect::createGLInstance() const { + return SkNEW_ARGS(GLEllipticalRRectEffect, (*this)); +} + ////////////////////////////////////////////////////////////////////////////// GrFragmentProcessor* GrRRectEffect::Create(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) { diff --git a/src/gpu/effects/GrRRectEffect.h b/src/gpu/effects/GrRRectEffect.h index eaaf9a0726..d3901f3933 100644 --- a/src/gpu/effects/GrRRectEffect.h +++ b/src/gpu/effects/GrRRectEffect.h @@ -11,6 +11,7 @@ #include "GrTypes.h" #include "GrTypesPriv.h" +class GrFragmentProcessor; class GrProcessor; class SkRRect; diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp index a8eab3a771..51822e9b9b 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.cpp +++ b/src/gpu/effects/GrSimpleTextureEffect.cpp @@ -7,8 +7,8 @@ #include "GrSimpleTextureEffect.h" #include "GrInvariantOutput.h" -#include "GrTBackendProcessorFactory.h" #include "GrTexture.h" +#include "gl/GrGLCaps.h" #include "gl/GrGLProcessor.h" #include "gl/GrGLSL.h" #include "gl/GrGLTexture.h" @@ -16,9 +16,7 @@ class GrGLSimpleTextureEffect : public GrGLFragmentProcessor { public: - GrGLSimpleTextureEffect(const GrBackendProcessorFactory& factory, const GrProcessor&) - : INHERITED (factory) { - } + GrGLSimpleTextureEffect(const GrProcessor&) {} virtual void emitCode(GrGLFPBuilder* builder, const GrFragmentProcessor& fp, @@ -45,8 +43,13 @@ void GrSimpleTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c this->updateInvariantOutputForModulation(inout); } -const GrBackendFragmentProcessorFactory& GrSimpleTextureEffect::getFactory() const { - return GrTBackendFragmentProcessorFactory<GrSimpleTextureEffect>::getInstance(); +void GrSimpleTextureEffect::getGLProcessorKey(const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GrGLSimpleTextureEffect::GenKey(*this, caps, b); +} + +GrGLFragmentProcessor* GrSimpleTextureEffect::createGLInstance() const { + return SkNEW_ARGS(GrGLSimpleTextureEffect, (*this)); } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h index f2c8d16a86..4b9268df24 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.h +++ b/src/gpu/effects/GrSimpleTextureEffect.h @@ -10,7 +10,6 @@ #include "GrSingleTextureEffect.h" -class GrGLSimpleTextureEffect; class GrInvariantOutput; /** @@ -48,11 +47,11 @@ public: virtual ~GrSimpleTextureEffect() {} - static const char* Name() { return "Texture"; } + virtual const char* name() const SK_OVERRIDE { return "SimpleTexture"; } - typedef GrGLSimpleTextureEffect GLProcessor; + virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE; - virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; + virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; private: GrSimpleTextureEffect(GrTexture* texture, @@ -60,6 +59,7 @@ private: GrTextureParams::FilterMode filterMode, GrCoordSet coordSet) : GrSingleTextureEffect(texture, matrix, filterMode, coordSet) { + this->initClassID<GrSimpleTextureEffect>(); } GrSimpleTextureEffect(GrTexture* texture, @@ -67,6 +67,7 @@ private: const GrTextureParams& params, GrCoordSet coordSet) : GrSingleTextureEffect(texture, matrix, params, coordSet) { + this->initClassID<GrSimpleTextureEffect>(); } virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE { return true; } diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp index 1de518c170..c6a9a22a94 100644 --- a/src/gpu/effects/GrTextureDomain.cpp +++ b/src/gpu/effects/GrTextureDomain.cpp @@ -5,14 +5,12 @@ * found in the LICENSE file. */ -#include "gl/builders/GrGLProgramBuilder.h" #include "GrTextureDomain.h" #include "GrInvariantOutput.h" #include "GrSimpleTextureEffect.h" -#include "GrTBackendProcessorFactory.h" -#include "gl/GrGLProcessor.h" #include "SkFloatingPoint.h" - +#include "gl/GrGLProcessor.h" +#include "gl/builders/GrGLProgramBuilder.h" GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index) : fIndex(index) { @@ -168,7 +166,7 @@ void GrTextureDomain::GLDomain::setData(const GrGLProgramDataManager& pdman, class GrGLTextureDomainEffect : public GrGLFragmentProcessor { public: - GrGLTextureDomainEffect(const GrBackendProcessorFactory&, const GrProcessor&); + GrGLTextureDomainEffect(const GrProcessor&); virtual void emitCode(GrGLFPBuilder*, const GrFragmentProcessor&, @@ -186,9 +184,7 @@ private: typedef GrGLFragmentProcessor INHERITED; }; -GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendProcessorFactory& factory, - const GrProcessor&) - : INHERITED(factory) { +GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrProcessor&) { } void GrGLTextureDomainEffect::emitCode(GrGLFPBuilder* builder, @@ -252,14 +248,20 @@ GrTextureDomainEffect::GrTextureDomainEffect(GrTexture* texture, , fTextureDomain(domain, mode) { SkASSERT(mode != GrTextureDomain::kRepeat_Mode || filterMode == GrTextureParams::kNone_FilterMode); + this->initClassID<GrTextureDomainEffect>(); } GrTextureDomainEffect::~GrTextureDomainEffect() { } -const GrBackendFragmentProcessorFactory& GrTextureDomainEffect::getFactory() const { - return GrTBackendFragmentProcessorFactory<GrTextureDomainEffect>::getInstance(); +void GrTextureDomainEffect::getGLProcessorKey(const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const { + GrGLTextureDomainEffect::GenKey(*this, caps, b); +} + +GrGLFragmentProcessor* GrTextureDomainEffect::createGLInstance() const { + return SkNEW_ARGS(GrGLTextureDomainEffect, (*this)); } bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const { diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h index 19b07adfb0..9e21c4a48e 100644 --- a/src/gpu/effects/GrTextureDomain.h +++ b/src/gpu/effects/GrTextureDomain.h @@ -138,8 +138,6 @@ protected: typedef GrSingleTextureEffect INHERITED; }; -class GrGLTextureDomainEffect; - /** * A basic texture effect that uses GrTextureDomain. */ @@ -155,11 +153,11 @@ public: virtual ~GrTextureDomainEffect(); - static const char* Name() { return "TextureDomain"; } + virtual const char* name() const SK_OVERRIDE { return "TextureDomain"; } - typedef GrGLTextureDomainEffect GLProcessor; + virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE; - virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; + virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE; const GrTextureDomain& textureDomain() const { return fTextureDomain; } diff --git a/src/gpu/effects/GrYUVtoRGBEffect.cpp b/src/gpu/effects/GrYUVtoRGBEffect.cpp index 87432d4668..a477f1e786 100644 --- a/src/gpu/effects/GrYUVtoRGBEffect.cpp +++ b/src/gpu/effects/GrYUVtoRGBEffect.cpp @@ -5,14 +5,13 @@ * found in the LICENSE file. */ -#include "gl/builders/GrGLProgramBuilder.h" #include "GrYUVtoRGBEffect.h" #include "GrCoordTransform.h" #include "GrInvariantOutput.h" #include "GrProcessor.h" #include "gl/GrGLProcessor.h" -#include "GrTBackendProcessorFactory.h" +#include "gl/builders/GrGLProgramBuilder.h" namespace { @@ -23,11 +22,7 @@ public: return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture, colorSpace)); } - static const char* Name() { return "YUV to RGB"; } - - virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE { - return GrTBackendFragmentProcessorFactory<YUVtoRGBEffect>::getInstance(); - } + virtual const char* name() const SK_OVERRIDE { return "YUV to RGB"; } SkYUVColorSpace getColorSpace() const { return fColorSpace; @@ -41,10 +36,7 @@ public: // this class always generates the same code. static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {} - GLProcessor(const GrBackendProcessorFactory& factory, - const GrProcessor&) - : INHERITED(factory) { - } + GLProcessor(const GrProcessor&) {} virtual void emitCode(GrGLFPBuilder* builder, const GrFragmentProcessor&, @@ -86,6 +78,15 @@ public: typedef GrGLFragmentProcessor INHERITED; }; + virtual void getGLProcessorKey(const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE { + GLProcessor::GenKey(*this, caps, b); + } + + virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE { + return SkNEW_ARGS(GLProcessor, (*this)); + } + private: YUVtoRGBEffect(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture, SkYUVColorSpace colorSpace) @@ -95,6 +96,7 @@ private: , fUAccess(uTexture) , fVAccess(vTexture) , fColorSpace(colorSpace) { + this->initClassID<YUVtoRGBEffect>(); this->addCoordTransform(&fCoordTransform); this->addTextureAccess(&fYAccess); this->addTextureAccess(&fUAccess); diff --git a/src/gpu/gl/GrGLGeometryProcessor.h b/src/gpu/gl/GrGLGeometryProcessor.h index a172904ac6..aa58cd3d97 100644 --- a/src/gpu/gl/GrGLGeometryProcessor.h +++ b/src/gpu/gl/GrGLGeometryProcessor.h @@ -18,11 +18,12 @@ class GrGLGPBuilder; * from this class. Since paths don't have vertices, this class is only meant to be used internally * by skia, for special cases. */ -class GrGLGeometryProcessor : public GrGLProcessor { +class GrGLGeometryProcessor { public: - GrGLGeometryProcessor(const GrBackendProcessorFactory& factory) - : INHERITED(factory) {} + GrGLGeometryProcessor() {} + virtual ~GrGLGeometryProcessor() {} + typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray; struct EmitArgs { EmitArgs(GrGLGPBuilder* pb, const GrGeometryProcessor& gp, diff --git a/src/gpu/gl/GrGLProcessor.h b/src/gpu/gl/GrGLProcessor.h index 6401e2b324..6dccd33bac 100644 --- a/src/gpu/gl/GrGLProcessor.h +++ b/src/gpu/gl/GrGLProcessor.h @@ -8,8 +8,8 @@ #ifndef GrGLProcessor_DEFINED #define GrGLProcessor_DEFINED -#include "GrBackendProcessorFactory.h" #include "GrGLProgramDataManager.h" +#include "GrProcessor.h" #include "GrTextureAccess.h" /** @file @@ -26,13 +26,9 @@ These objects are created by the factory object returned by the GrProcessor::getFactory(). */ - +// TODO delete this and make TextureSampler its own thing class GrGLProcessor { public: - GrGLProcessor(const GrBackendProcessorFactory& factory) - : fFactory(factory) { - } - typedef GrGLProgramDataManager::UniformHandle UniformHandle; /** @@ -67,27 +63,20 @@ public: }; typedef SkTArray<TextureSampler> TextureSamplerArray; - - virtual ~GrGLProcessor() {} - - const char* name() const { return fFactory.name(); } - - static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {} - -protected: - const GrBackendProcessorFactory& fFactory; }; class GrGLFPBuilder; -class GrGLFragmentProcessor : public GrGLProcessor { +class GrGLFragmentProcessor { public: - GrGLFragmentProcessor(const GrBackendProcessorFactory& factory) - : INHERITED(factory) { - } + GrGLFragmentProcessor() {} virtual ~GrGLFragmentProcessor() {} + typedef GrGLProgramDataManager::UniformHandle UniformHandle; + typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray; + typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray; + /** Called when the program stage should insert its code into the shaders. The code in each shader will be in its own block ({}) and so locally scoped names will not collide across stages. @@ -122,15 +111,15 @@ public: // TODO update this to pass in GrFragmentProcessor virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) {} + static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {} + private: typedef GrGLProcessor INHERITED; }; class GrGLXferProcessor : public GrGLFragmentProcessor { public: - GrGLXferProcessor(const GrBackendProcessorFactory& factory) - : INHERITED(factory) { - } + GrGLXferProcessor() {} virtual ~GrGLXferProcessor() {} diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp index 474f7026e4..6867a1329b 100644 --- a/src/gpu/gl/GrGLProgramDesc.cpp +++ b/src/gpu/gl/GrGLProgramDesc.cpp @@ -7,7 +7,6 @@ #include "GrGLProgramDesc.h" #include "GrGLProcessor.h" -#include "GrBackendProcessorFactory.h" #include "GrProcessor.h" #include "GrGpuGL.h" #include "GrOptDrawState.h" @@ -125,7 +124,7 @@ static bool get_meta_key(const GrProcessor& proc, GrProcessorKeyBuilder* b) { size_t processorKeySize = b->size(); uint32_t textureKey = gen_texture_key(proc, caps); - uint32_t classID = proc.getFactory().classID(); + uint32_t classID = proc.classID(); // Currently we allow 16 bits for each of the above portions of the meta-key. Fail if they // don't fit. @@ -167,8 +166,7 @@ bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState, if (optState.hasGeometryProcessor()) { const GrGeometryProcessor& gp = *optState.getGeometryProcessor(); GrProcessorKeyBuilder b(&desc->fKey); - const GrBackendGeometryProcessorFactory& factory = gp.getFactory(); - factory.getGLProcessorKey(gp, optState.getBatchTracker(), gpu->glCaps(), &b); + gp.getGLProcessorKey(optState.getBatchTracker(), gpu->glCaps(), &b); if (!get_meta_key(gp, gpu->glCaps(), 0, gen_attrib_key(gp), &b)) { desc->fKey.reset(); return false; @@ -179,8 +177,7 @@ bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState, const GrPendingFragmentStage& fps = optState.getFragmentStage(s); const GrFragmentProcessor& fp = *fps.getProcessor(); GrProcessorKeyBuilder b(&desc->fKey); - const GrBackendFragmentProcessorFactory& factory = fp.getFactory(); - factory.getGLProcessorKey(fp, gpu->glCaps(), &b); + fp.getGLProcessorKey(gpu->glCaps(), &b); if (!get_meta_key(*fps.getProcessor(), gpu->glCaps(), gen_transform_key(fps, requiresLocalCoordAttrib), 0, &b)) { desc->fKey.reset(); diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index 2f4329ae04..fb26867cf6 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -336,7 +336,7 @@ void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& fs, GrGLInstalledFragProc* ifp = SkNEW(GrGLInstalledFragProc); const GrFragmentProcessor& fp = *fs.getProcessor(); - ifp->fGLProc.reset(fp.getFactory().createGLInstance(fp)); + ifp->fGLProc.reset(fp.createGLInstance()); SkSTArray<4, GrGLProcessor::TextureSampler> samplers(fp.numTextures()); this->emitSamplers(fp, &samplers, ifp); @@ -360,7 +360,7 @@ void GrGLProgramBuilder::emitAndInstallProc(const GrGeometryProcessor& gp, fGeometryProcessor = SkNEW(GrGLInstalledGeoProc); const GrBatchTracker& bt = fOptState.getBatchTracker(); - fGeometryProcessor->fGLProc.reset(gp.getFactory().createGLInstance(gp, bt)); + fGeometryProcessor->fGLProc.reset(gp.createGLInstance(bt)); SkSTArray<4, GrGLProcessor::TextureSampler> samplers(gp.numTextures()); this->emitSamplers(gp, &samplers, fGeometryProcessor); |