Remove backend factories
BUG=skia:
Review URL: https://codereview.chromium.org/778453002
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index 3108b04..4008fe2 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 @@
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 @@
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 7168c83..15a5569 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 95fe8c9..7f61840 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 ddaa809..0df519d 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 @@
}
}
- 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 @@
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 @@
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 @@
, 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 27383a4..9e621d8 100644
--- a/src/gpu/GrGeometryProcessor.h
+++ b/src/gpu/GrGeometryProcessor.h
@@ -34,6 +34,8 @@
uint8_t fData[kMaxSize];
};
+class GrGLCaps;
+class GrGLGeometryProcessor;
class GrOptDrawState;
/**
@@ -55,7 +57,18 @@
, 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 @@
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 @@
typedef GrProcessor INHERITED;
};
-
#endif
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index c658612..f392b90 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 @@
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 @@
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 @@
}
}
- 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 @@
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 @@
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 @@
}
}
- 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 @@
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 @@
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 8aeef04..810c751 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 @@
}
};
-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 delete(void* target) {
GrProcessor_Globals::GetTLS()->release(target);
}
-
diff --git a/src/gpu/GrProgramDesc.h b/src/gpu/GrProgramDesc.h
index ef7be23..a20b99f 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 0bcfc75..ebbb8d7 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 27f2fa1..7b171a1 100644
--- a/src/gpu/effects/GrBezierEffect.h
+++ b/src/gpu/effects/GrBezierEffect.h
@@ -86,7 +86,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 51ba58e..804a087 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 @@
class GrGLBicubicEffect : public GrGLFragmentProcessor {
public:
- GrGLBicubicEffect(const GrBackendProcessorFactory& factory,
- const GrProcessor&);
+ GrGLBicubicEffect(const GrProcessor&);
virtual void emitCode(GrGLFPBuilder*,
const GrFragmentProcessor&,
@@ -49,8 +48,7 @@
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 @@
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 @@
: 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 8f11825..19fce03 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 @@
};
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 d487841..e146411 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 @@
: 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 @@
}
///////////////////////////////////////////////////////////////////////////////
+
+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 41ae1ac..d85e783 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 @@
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 c2874e0..6f93fb5 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 @@
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 @@
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 @@
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 @@
typedef GrGLFragmentProcessor INHERITED;
};
-GrGLConvexPolyEffect::GrGLConvexPolyEffect(const GrBackendProcessorFactory& factory,
- const GrProcessor&)
- : INHERITED (factory) {
+GrGLConvexPolyEffect::GrGLConvexPolyEffect(const GrProcessor&) {
fPrevEdges[0] = SK_ScalarNaN;
}
@@ -326,13 +324,19 @@
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 7464d54..fec7e82 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 @@
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 @@
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 6e1f3c4..e4ac4ce 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 @@
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 @@
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 @@
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() {
}
-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 e99e520..7fda369 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 @@
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 637d442..a132e86 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 @@
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 @@
}
}
-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 89fc935..a2b62ed 100644
--- a/src/gpu/effects/GrCustomCoordsTextureEffect.h
+++ b/src/gpu/effects/GrCustomCoordsTextureEffect.h
@@ -27,15 +27,17 @@
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 fec1551..be1b5e5 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 53f85907..f1f4a9f 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 @@
, 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 @@
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 @@
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 @@
, 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 @@
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 @@
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 @@
, 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 @@
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 a074d69..1dfa1b4 100644
--- a/src/gpu/effects/GrDistanceFieldTextureEffect.h
+++ b/src/gpu/effects/GrDistanceFieldTextureEffect.h
@@ -62,7 +62,7 @@
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 @@
#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 @@
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 @@
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 438fe2c..799d970 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 @@
}
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 @@
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 @@
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 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 ac4c784..64c85f7 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 698b705..3cd3588 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 @@
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 @@
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() {
}
-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 9996062..6d60609 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 @@
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 @@
bool convolveAlpha() const { return fConvolveAlpha; }
const GrTextureDomain& domain() const { return fDomain; }
- typedef GrGLMatrixConvolutionEffect GLProcessor;
+ virtual const char* name() const SK_OVERRIDE { return "MatrixConvolution"; }
- virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
+ virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) 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 37555ea..1ea93a9 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 @@
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 @@
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 @@
typedef GrGLFragmentProcessor INHERITED;
};
-GLCircleEffect::GLCircleEffect(const GrBackendProcessorFactory& factory,
- const GrProcessor&)
- : INHERITED (factory) {
+GLCircleEffect::GLCircleEffect(const GrProcessor&) {
fPrevRadius = -1.f;
}
@@ -183,9 +177,18 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
-class GLEllipseEffect;
+void CircleEffect::getGLProcessorKey(const GrGLCaps& caps,
+ GrProcessorKeyBuilder* b) const {
+ GLCircleEffect::GenKey(*this, caps, b);
+}
+
+GrGLFragmentProcessor* CircleEffect::createGLInstance() const {
+ return SkNEW_ARGS(GLCircleEffect, (*this));
+}
+
+//////////////////////////////////////////////////////////////////////////////
class EllipseEffect : public GrFragmentProcessor {
public:
@@ -193,17 +196,18 @@
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 @@
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 @@
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 @@
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 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 41e22cc..8f85365 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 1f50f9d..5c842a8 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 @@
///////////////////////////////////////////////////////////////////////////////
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 d210a81..d1b30cc 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 @@
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 7e58c1f..4c8e886 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 @@
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 @@
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 @@
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 @@
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 @@
typedef GrGLFragmentProcessor INHERITED;
};
-GLCircularRRectEffect::GLCircularRRectEffect(const GrBackendProcessorFactory& factory,
- const GrProcessor& )
- : INHERITED (factory) {
+GLCircularRRectEffect::GLCircularRRectEffect(const GrProcessor& ) {
fPrevRRect.setEmpty();
}
@@ -380,26 +373,35 @@
}
}
-//////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
-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"; }
+
+ virtual const char* name() const SK_OVERRIDE { return "EllipticalRRect"; }
+
+ virtual void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const SK_OVERRIDE;
+
+ virtual GrGLFragmentProcessor* createGLInstance() const SK_OVERRIDE;
const SkRRect& getRRect() const { return fRRect; }
-
GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
- typedef GLEllipticalRRectEffect GLProcessor;
-
- virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
-
private:
EllipticalRRectEffect(GrPrimitiveEdgeType, const SkRRect&);
@@ -427,13 +429,10 @@
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 @@
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 @@
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 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 eaaf9a0..d3901f3 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 a8eab3a..51822e9 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 @@
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 f2c8d16..4b9268d 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 @@
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 @@
GrTextureParams::FilterMode filterMode,
GrCoordSet coordSet)
: GrSingleTextureEffect(texture, matrix, filterMode, coordSet) {
+ this->initClassID<GrSimpleTextureEffect>();
}
GrSimpleTextureEffect(GrTexture* texture,
@@ -67,6 +67,7 @@
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 1de518c..c6a9a22 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 @@
class GrGLTextureDomainEffect : public GrGLFragmentProcessor {
public:
- GrGLTextureDomainEffect(const GrBackendProcessorFactory&, const GrProcessor&);
+ GrGLTextureDomainEffect(const GrProcessor&);
virtual void emitCode(GrGLFPBuilder*,
const GrFragmentProcessor&,
@@ -186,9 +184,7 @@
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 @@
, 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 19b07ad..9e21c4a 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -138,8 +138,6 @@
typedef GrSingleTextureEffect INHERITED;
};
-class GrGLTextureDomainEffect;
-
/**
* A basic texture effect that uses GrTextureDomain.
*/
@@ -155,11 +153,11 @@
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 87432d4..a477f1e 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 @@
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 @@
// 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 @@
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 @@
, 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 a172904..aa58cd3 100644
--- a/src/gpu/gl/GrGLGeometryProcessor.h
+++ b/src/gpu/gl/GrGLGeometryProcessor.h
@@ -18,11 +18,12 @@
* 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 6401e2b..6dccd33 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 @@
};
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 @@
// 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 474f702..6867a13 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 @@
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 @@
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 @@
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 2f4329a..fb26867 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -336,7 +336,7 @@
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 @@
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);