diff options
author | joshualitt <joshualitt@google.com> | 2014-12-04 06:00:41 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-04 06:00:41 -0800 |
commit | 841a6b54c11137e210aa81e8b56e1763c3571cb8 (patch) | |
tree | fac39d5628255390df36a6fc7def7b4d13d8f30d | |
parent | b8eb85cd2fae475f17b713b6739ede545a78f647 (diff) |
Revert of create and thread batch tracker object (patchset #9 id:160001 of https://codereview.chromium.org/772513002/)
Reason for revert:
Breaking linux layout test
Original issue's description:
> create and thread batch tracker object
>
> I remove the factory on the next CL
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/c3a6eb23483e5d28073b509a5f637f41660de294
TBR=bsalomon@google.com,joshualitt@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/774133003
-rw-r--r-- | include/gpu/GrBackendProcessorFactory.h | 32 | ||||
-rw-r--r-- | include/gpu/GrTBackendProcessorFactory.h | 86 | ||||
-rw-r--r-- | src/gpu/GrAAConvexPathRenderer.cpp | 13 | ||||
-rw-r--r-- | src/gpu/GrDefaultGeoProcFactory.cpp | 13 | ||||
-rw-r--r-- | src/gpu/GrGeometryProcessor.h | 33 | ||||
-rw-r--r-- | src/gpu/GrOptDrawState.cpp | 12 | ||||
-rw-r--r-- | src/gpu/GrOptDrawState.h | 2 | ||||
-rw-r--r-- | src/gpu/GrOvalRenderer.cpp | 36 | ||||
-rw-r--r-- | src/gpu/effects/GrBezierEffect.cpp | 64 | ||||
-rw-r--r-- | src/gpu/effects/GrCustomCoordsTextureEffect.cpp | 11 | ||||
-rw-r--r-- | src/gpu/effects/GrDashingEffect.cpp | 48 | ||||
-rwxr-xr-x | src/gpu/effects/GrDistanceFieldTextureEffect.cpp | 38 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGeometryProcessor.h | 13 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProcessor.h | 23 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgram.cpp | 3 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgramDesc.cpp | 8 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.cpp | 5 |
17 files changed, 107 insertions, 333 deletions
diff --git a/include/gpu/GrBackendProcessorFactory.h b/include/gpu/GrBackendProcessorFactory.h index dc0bbbe53f..acbc12c192 100644 --- a/include/gpu/GrBackendProcessorFactory.h +++ b/include/gpu/GrBackendProcessorFactory.h @@ -68,6 +68,14 @@ private: */ class GrBackendProcessorFactory : SkNoncopyable { public: + /** + * Generates an processor's key. The key is based on the aspects of the GrProcessor object's + * configuration that affect GLSL code generation. Two GrProcessor instances that would cause + * this->createGLInstance()->emitCode() to produce different code must produce different keys. + */ + virtual void getGLProcessorKey(const GrProcessor&, const GrGLCaps&, + GrProcessorKeyBuilder*) const = 0; + /** * Produces a human-reable name for the v. */ @@ -120,15 +128,6 @@ class GrGLXferProcessor; class GrBackendFragmentProcessorFactory : public GrBackendProcessorFactory { public: /** - * Generates an processor's key. The key is based on the aspects of the GrProcessor object's - * configuration that affect GLSL code generation. Two GrProcessor instances that would cause - * this->createGLInstance()->emitCode() to produce different code must produce different keys. - */ - virtual void getGLProcessorKey(const GrFragmentProcessor&, - const GrGLCaps&, - GrProcessorKeyBuilder*) const = 0; - - /** * Creates a GrGLProcessor instance that is used both to generate code for the GrProcessor in a * GLSL program and to manage updating uniforms for the program when it is used. */ @@ -144,26 +143,13 @@ public: virtual GrGLXferProcessor* createGLInstance(const GrXferProcessor&) const = 0; }; -class GrBatchTracker; - class GrBackendGeometryProcessorFactory : public GrBackendProcessorFactory { public: /** - * Generates an processor's key. The key is based on the aspects of the GrProcessor object's - * configuration that affect GLSL code generation. Two GrProcessor instances that would cause - * this->createGLInstance()->emitCode() to produce different code must produce different keys. - */ - virtual void getGLProcessorKey(const GrGeometryProcessor&, - const GrBatchTracker&, - const GrGLCaps&, - GrProcessorKeyBuilder*) const = 0; - - /** * Creates a GrGLProcessor instance that is used both to generate code for the GrProcessor in a * GLSL program and to manage updating uniforms for the program when it is used. */ - virtual GrGLGeometryProcessor* createGLInstance(const GrGeometryProcessor&, - const GrBatchTracker&) const = 0; + virtual GrGLGeometryProcessor* createGLInstance(const GrGeometryProcessor&) const = 0; }; #endif diff --git a/include/gpu/GrTBackendProcessorFactory.h b/include/gpu/GrTBackendProcessorFactory.h index 98b5d6cb7e..a86fe38d92 100644 --- a/include/gpu/GrTBackendProcessorFactory.h +++ b/include/gpu/GrTBackendProcessorFactory.h @@ -41,6 +41,14 @@ public: * described in this class's comment. */ virtual const char* name() const SK_OVERRIDE { return ProcessorClass::Name(); } + + /** Implemented using GLProcessor::GenKey as described in this class's comment. */ + virtual void getGLProcessorKey(const GrProcessor& processor, + const GrGLCaps& caps, + GrProcessorKeyBuilder* b) const SK_OVERRIDE { + GLProcessor::GenKey(processor, caps, b); + } + /** Returns a new instance of the appropriate *GL* implementation class for the given GrProcessor; caller is responsible for deleting the object. */ @@ -69,80 +77,24 @@ protected: * typesafe and does not require any casting. */ template <class ProcessorClass> -class GrTBackendGeometryProcessorFactory : public GrBackendGeometryProcessorFactory { -public: - typedef typename ProcessorClass::GLProcessor GLProcessor; - - /** Returns a human-readable name for the processor. Implemented using GLProcessor::Name as - * described in this class's comment. */ - virtual const char* name() const SK_OVERRIDE { return ProcessorClass::Name(); } - - /** Implemented using GLProcessor::GenKey as described in this class's comment. */ - virtual void getGLProcessorKey(const GrGeometryProcessor& processor, - const GrBatchTracker& bt, - const GrGLCaps& caps, - GrProcessorKeyBuilder* b) const SK_OVERRIDE { - GLProcessor::GenKey(processor, bt, caps, b); - } - - - /** Returns a new instance of the appropriate *GL* implementation class - for the given GrProcessor; caller is responsible for deleting - the object. */ - virtual GrGLGeometryProcessor* createGLInstance(const GrGeometryProcessor& gp, - const GrBatchTracker& bt) const SK_OVERRIDE { - return SkNEW_ARGS(GLProcessor, (*this, gp, bt)); - } - - /** This class is a singleton. This function returns the single instance. */ - static const GrBackendGeometryProcessorFactory& getInstance() { - static SkAlignedSTStorage<1, GrTBackendGeometryProcessorFactory> gInstanceMem; - static const GrTBackendGeometryProcessorFactory* gInstance; - if (!gInstance) { - gInstance = SkNEW_PLACEMENT(gInstanceMem.get(), - GrTBackendGeometryProcessorFactory); - } - return *gInstance; - } +class GrTBackendGeometryProcessorFactory + : public GrTBackendProcessorFactory<ProcessorClass, + GrBackendGeometryProcessorFactory, + GrGeometryProcessor, + GrGLGeometryProcessor> { protected: GrTBackendGeometryProcessorFactory() {} }; template <class ProcessorClass> -class GrTBackendFragmentProcessorFactory : public GrBackendFragmentProcessorFactory { -public: - typedef typename ProcessorClass::GLProcessor GLProcessor; - - /** Returns a human-readable name for the processor. Implemented using GLProcessor::Name as - * described in this class's comment. */ - virtual const char* name() const SK_OVERRIDE { return ProcessorClass::Name(); } - - /** Implemented using GLProcessor::GenKey as described in this class's comment. */ - virtual void getGLProcessorKey(const GrFragmentProcessor& processor, - const GrGLCaps& caps, - GrProcessorKeyBuilder* b) const SK_OVERRIDE { - GLProcessor::GenKey(processor, caps, b); - } - - /** Returns a new instance of the appropriate *GL* implementation class - for the given GrProcessor; caller is responsible for deleting - the object. */ - virtual GrGLFragmentProcessor* createGLInstance(const GrFragmentProcessor& gp) const SK_OVERRIDE { - return SkNEW_ARGS(GLProcessor, (*this, gp)); - } - - /** This class is a singleton. This function returns the single instance. */ - static const GrBackendFragmentProcessorFactory& getInstance() { - static SkAlignedSTStorage<1, GrTBackendFragmentProcessorFactory> gInstanceMem; - static const GrTBackendFragmentProcessorFactory* gInstance; - if (!gInstance) { - gInstance = SkNEW_PLACEMENT(gInstanceMem.get(), - GrTBackendFragmentProcessorFactory); - } - return *gInstance; - } +class GrTBackendFragmentProcessorFactory + : public GrTBackendProcessorFactory<ProcessorClass, + GrBackendFragmentProcessorFactory, + GrFragmentProcessor, + GrGLFragmentProcessor> { protected: GrTBackendFragmentProcessorFactory() {} }; + #endif diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp index 3108b0472e..b5ad44adc0 100644 --- a/src/gpu/GrAAConvexPathRenderer.cpp +++ b/src/gpu/GrAAConvexPathRenderer.cpp @@ -527,9 +527,7 @@ public: class GLProcessor : public GrGLGeometryProcessor { public: - GLProcessor(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) + GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&) : INHERITED (factory) {} virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { @@ -573,14 +571,9 @@ public: fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage); } - static inline void GenKey(const GrGeometryProcessor&, - const GrBatchTracker&, - const GrGLCaps&, - GrProcessorKeyBuilder*) {} + static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {} - virtual void setData(const GrGLProgramDataManager&, - const GrGeometryProcessor&, - const GrBatchTracker&) SK_OVERRIDE {} + virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {} private: typedef GrGLGeometryProcessor INHERITED; diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp index ddaa809f06..ab28a579e7 100644 --- a/src/gpu/GrDefaultGeoProcFactory.cpp +++ b/src/gpu/GrDefaultGeoProcFactory.cpp @@ -75,9 +75,7 @@ public: class GLProcessor : public GrGLGeometryProcessor { public: - GLProcessor(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) + GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&) : INHERITED (factory) {} virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { @@ -111,17 +109,12 @@ public: fs->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage); } - static inline void GenKey(const GrGeometryProcessor& gp, - const GrBatchTracker&, - const GrGLCaps&, - GrProcessorKeyBuilder* b) { + static inline void GenKey(const GrProcessor& gp, const GrGLCaps&, GrProcessorKeyBuilder* b) { const DefaultGeoProc& def = gp.cast<DefaultGeoProc>(); b->add32(def.fFlags); } - virtual void setData(const GrGLProgramDataManager&, - const GrGeometryProcessor&, - const GrBatchTracker&) SK_OVERRIDE {} + virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {} private: typedef GrGLGeometryProcessor INHERITED; diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h index 27383a4df4..17344d2bb4 100644 --- a/src/gpu/GrGeometryProcessor.h +++ b/src/gpu/GrGeometryProcessor.h @@ -12,30 +12,6 @@ #include "GrProcessor.h" #include "GrShaderVar.h" -/* - * A struct for tracking batching decisions. While this lives on GrOptState, it is managed - * entirely by the derived classes of the GP. - */ -class GrBatchTracker { -public: - template <typename T> const T& cast() const { - SkASSERT(sizeof(T) <= kMaxSize); - return *reinterpret_cast<const T*>(fData); - } - - template <typename T> T* cast() { - SkASSERT(sizeof(T) <= kMaxSize); - return reinterpret_cast<T*>(fData); - } - - static const size_t kMaxSize = 32; - -private: - uint8_t fData[kMaxSize]; -}; - -class GrOptDrawState; - /** * A GrGeometryProcessor is used to perform computation in the vertex shader and * add support for custom vertex attributes. A GrGemeotryProcessor is typically @@ -97,15 +73,6 @@ public: return this->onIsEqual(that); } - struct InitBT { - bool fOutputColor; - bool fOutputCoverage; - GrColor fColor; - GrColor fCoverage; - }; - - virtual void initBatchTracker(GrBatchTracker*, const InitBT&) const {} - // TODO this is a total hack until the gp can own whether or not it uses uniform // color / coverage bool hasVertexColor() const { return fHasVertexColor; } diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp index 20057acee7..6eee0c25a3 100644 --- a/src/gpu/GrOptDrawState.cpp +++ b/src/gpu/GrOptDrawState.cpp @@ -117,17 +117,7 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, } this->setOutputStateInfo(drawState, blendOpt, caps); - - // let the GP init the batch tracker - if (drawState.hasGeometryProcessor()) { - GrGeometryProcessor::InitBT init; - init.fOutputColor = fDescInfo.fInputColorIsUsed; - init.fOutputCoverage = fDescInfo.fInputCoverageIsUsed; - init.fColor = this->getColor(); - init.fCoverage = this->getCoverage(); - fGeometryProcessor->initBatchTracker(&fBatchTracker, init); - } -} +}; void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds, GrDrawState::BlendOpt blendOpt, diff --git a/src/gpu/GrOptDrawState.h b/src/gpu/GrOptDrawState.h index 45501b49dd..25a3a49995 100644 --- a/src/gpu/GrOptDrawState.h +++ b/src/gpu/GrOptDrawState.h @@ -84,7 +84,6 @@ public: bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get()); } const GrGeometryProcessor* getGeometryProcessor() const { return fGeometryProcessor.get(); } - const GrBatchTracker& getBatchTracker() const { return fBatchTracker; } const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get(); } @@ -234,7 +233,6 @@ private: GrBlendCoeff fDstBlend; uint32_t fFlags; ProgramGeometryProcessor fGeometryProcessor; - GrBatchTracker fBatchTracker; ProgramXferProcessor fXferProcessor; FragmentStageArray fFragmentStages; GrGpu::DrawType fDrawType; diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index c6586120a9..a9dda840aa 100644 --- a/src/gpu/GrOvalRenderer.cpp +++ b/src/gpu/GrOvalRenderer.cpp @@ -91,9 +91,7 @@ public: class GLProcessor : public GrGLGeometryProcessor { public: - GLProcessor(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) + GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&) : INHERITED (factory) {} virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { @@ -124,17 +122,13 @@ public: fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage); } - static void GenKey(const GrGeometryProcessor& processor, - const GrBatchTracker&, - const GrGLCaps&, + static void GenKey(const GrProcessor& processor, const GrGLCaps&, GrProcessorKeyBuilder* b) { const CircleEdgeEffect& circleEffect = processor.cast<CircleEdgeEffect>(); b->add32(circleEffect.isStroked()); } - virtual void setData(const GrGLProgramDataManager&, - const GrGeometryProcessor&, - const GrBatchTracker&) SK_OVERRIDE {} + virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {} private: typedef GrGLGeometryProcessor INHERITED; @@ -218,9 +212,7 @@ public: class GLProcessor : public GrGLGeometryProcessor { public: - GLProcessor(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) + GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&) : INHERITED (factory) {} virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { @@ -273,17 +265,13 @@ public: fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage); } - static void GenKey(const GrGeometryProcessor& processor, - const GrBatchTracker&, - const GrGLCaps&, + static void GenKey(const GrProcessor& processor, const GrGLCaps&, GrProcessorKeyBuilder* b) { const EllipseEdgeEffect& ellipseEffect = processor.cast<EllipseEdgeEffect>(); b->add32(ellipseEffect.isStroked()); } - virtual void setData(const GrGLProgramDataManager&, - const GrGeometryProcessor&, - const GrBatchTracker&) SK_OVERRIDE { + virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE { } private: @@ -376,9 +364,7 @@ public: class GLProcessor : public GrGLGeometryProcessor { public: - GLProcessor(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) + GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&) : INHERITED (factory) {} virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { @@ -445,18 +431,14 @@ public: fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage); } - static void GenKey(const GrGeometryProcessor& processor, - const GrBatchTracker&, - const GrGLCaps&, + static void GenKey(const GrProcessor& processor, const GrGLCaps&, GrProcessorKeyBuilder* b) { const DIEllipseEdgeEffect& ellipseEffect = processor.cast<DIEllipseEdgeEffect>(); b->add32(ellipseEffect.getMode()); } - virtual void setData(const GrGLProgramDataManager&, - const GrGeometryProcessor&, - const GrBatchTracker&) SK_OVERRIDE { + virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE { } private: diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp index 0bcfc75bef..1b14d349dd 100644 --- a/src/gpu/effects/GrBezierEffect.cpp +++ b/src/gpu/effects/GrBezierEffect.cpp @@ -15,20 +15,13 @@ class GrGLConicEffect : public GrGLGeometryProcessor { public: - GrGLConicEffect(const GrBackendProcessorFactory&, - const GrGeometryProcessor&, - const GrBatchTracker&); + GrGLConicEffect(const GrBackendProcessorFactory&, const GrProcessor&); virtual void emitCode(const EmitArgs&) SK_OVERRIDE; - static inline void GenKey(const GrGeometryProcessor&, - const GrBatchTracker&, - const GrGLCaps&, - GrProcessorKeyBuilder*); + static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*); - virtual void setData(const GrGLProgramDataManager&, - const GrGeometryProcessor&, - const GrBatchTracker&) SK_OVERRIDE {} + virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {} private: GrPrimitiveEdgeType fEdgeType; @@ -37,10 +30,9 @@ private: }; GrGLConicEffect::GrGLConicEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor& processor, - const GrBatchTracker& bt) + const GrProcessor& effect) : INHERITED (factory) { - const GrConicEffect& ce = processor.cast<GrConicEffect>(); + const GrConicEffect& ce = effect.cast<GrConicEffect>(); fEdgeType = ce.getEdgeType(); } @@ -120,9 +112,7 @@ void GrGLConicEffect::emitCode(const EmitArgs& args) { fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage); } -void GrGLConicEffect::GenKey(const GrGeometryProcessor& processor, - const GrBatchTracker&, - const GrGLCaps&, +void GrGLConicEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, GrProcessorKeyBuilder* b) { const GrConicEffect& ce = processor.cast<GrConicEffect>(); uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; @@ -172,20 +162,13 @@ GrGeometryProcessor* GrConicEffect::TestCreate(SkRandom* random, class GrGLQuadEffect : public GrGLGeometryProcessor { public: - GrGLQuadEffect(const GrBackendProcessorFactory&, - const GrGeometryProcessor&, - const GrBatchTracker&); + GrGLQuadEffect(const GrBackendProcessorFactory&, const GrProcessor&); virtual void emitCode(const EmitArgs&) SK_OVERRIDE; - static inline void GenKey(const GrGeometryProcessor&, - const GrBatchTracker&, - const GrGLCaps&, - GrProcessorKeyBuilder*); + static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*); - virtual void setData(const GrGLProgramDataManager&, - const GrGeometryProcessor&, - const GrBatchTracker&) SK_OVERRIDE {} + virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {} private: GrPrimitiveEdgeType fEdgeType; @@ -194,10 +177,9 @@ private: }; GrGLQuadEffect::GrGLQuadEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor& processor, - const GrBatchTracker& bt) + const GrProcessor& effect) : INHERITED (factory) { - const GrQuadEffect& ce = processor.cast<GrQuadEffect>(); + const GrQuadEffect& ce = effect.cast<GrQuadEffect>(); fEdgeType = ce.getEdgeType(); } @@ -263,9 +245,7 @@ void GrGLQuadEffect::emitCode(const EmitArgs& args) { fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage); } -void GrGLQuadEffect::GenKey(const GrGeometryProcessor& processor, - const GrBatchTracker&, - const GrGLCaps&, +void GrGLQuadEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, GrProcessorKeyBuilder* b) { const GrQuadEffect& ce = processor.cast<GrQuadEffect>(); uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; @@ -315,20 +295,13 @@ GrGeometryProcessor* GrQuadEffect::TestCreate(SkRandom* random, class GrGLCubicEffect : public GrGLGeometryProcessor { public: - GrGLCubicEffect(const GrBackendProcessorFactory&, - const GrGeometryProcessor&, - const GrBatchTracker&); + GrGLCubicEffect(const GrBackendProcessorFactory&, const GrProcessor&); virtual void emitCode(const EmitArgs&) SK_OVERRIDE; - static inline void GenKey(const GrGeometryProcessor&, - const GrBatchTracker&, - const GrGLCaps&, - GrProcessorKeyBuilder*); + static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*); - virtual void setData(const GrGLProgramDataManager&, - const GrGeometryProcessor&, - const GrBatchTracker&) SK_OVERRIDE {} + virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {} private: GrPrimitiveEdgeType fEdgeType; @@ -337,8 +310,7 @@ private: }; GrGLCubicEffect::GrGLCubicEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor& processor, - const GrBatchTracker&) + const GrProcessor& processor) : INHERITED (factory) { const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); fEdgeType = ce.getEdgeType(); @@ -447,9 +419,7 @@ void GrGLCubicEffect::emitCode(const EmitArgs& args) { fsBuilder->codeAppendf("%s = vec4(%s);", args.fOutputCoverage, edgeAlpha.c_str()); } -void GrGLCubicEffect::GenKey(const GrGeometryProcessor& processor, - const GrBatchTracker&, - const GrGLCaps&, +void GrGLCubicEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, GrProcessorKeyBuilder* b) { const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; diff --git a/src/gpu/effects/GrCustomCoordsTextureEffect.cpp b/src/gpu/effects/GrCustomCoordsTextureEffect.cpp index 637d442d13..45c3008889 100644 --- a/src/gpu/effects/GrCustomCoordsTextureEffect.cpp +++ b/src/gpu/effects/GrCustomCoordsTextureEffect.cpp @@ -17,9 +17,7 @@ class GrGLCustomCoordsTextureEffect : public GrGLGeometryProcessor { public: - GrGLCustomCoordsTextureEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) + GrGLCustomCoordsTextureEffect(const GrBackendProcessorFactory& factory, const GrProcessor&) : INHERITED (factory) {} virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { @@ -51,12 +49,9 @@ public: } virtual void setData(const GrGLProgramDataManager&, - const GrGeometryProcessor&, - const GrBatchTracker&) SK_OVERRIDE {} + const GrProcessor&) SK_OVERRIDE {} - static inline void GenKey(const GrGeometryProcessor& proc, - const GrBatchTracker&, - const GrGLCaps&, + static inline void GenKey(const GrProcessor& proc, const GrGLCaps&, GrProcessorKeyBuilder* b) { const GrCustomCoordsTextureEffect& gp = proc.cast<GrCustomCoordsTextureEffect>(); diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp index fec1551ef5..95760e62e5 100644 --- a/src/gpu/effects/GrDashingEffect.cpp +++ b/src/gpu/effects/GrDashingEffect.cpp @@ -504,20 +504,13 @@ private: class GLDashingCircleEffect : public GrGLGeometryProcessor { public: - GLDashingCircleEffect(const GrBackendProcessorFactory&, - const GrGeometryProcessor&, - const GrBatchTracker&); + GLDashingCircleEffect(const GrBackendProcessorFactory&, const GrProcessor&); virtual void emitCode(const EmitArgs&) SK_OVERRIDE; - static inline void GenKey(const GrGeometryProcessor&, - const GrBatchTracker&, - const GrGLCaps&, - GrProcessorKeyBuilder*); + static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*); - virtual void setData(const GrGLProgramDataManager&, - const GrGeometryProcessor&, - const GrBatchTracker&) SK_OVERRIDE; + virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE; private: GrGLProgramDataManager::UniformHandle fParamUniform; @@ -528,8 +521,7 @@ private: }; GLDashingCircleEffect::GLDashingCircleEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) + const GrProcessor&) : INHERITED (factory) { fPrevRadius = SK_ScalarMin; fPrevCenterX = SK_ScalarMin; @@ -578,9 +570,8 @@ void GLDashingCircleEffect::emitCode(const EmitArgs& args) { fsBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage); } -void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman, - const GrGeometryProcessor& processor, - const GrBatchTracker&) { +void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman + , const GrProcessor& processor) { const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>(); SkScalar radius = dce.getRadius(); SkScalar centerX = dce.getCenterX(); @@ -593,9 +584,7 @@ void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman, } } -void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& processor, - const GrBatchTracker&, - const GrGLCaps&, +void GLDashingCircleEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, GrProcessorKeyBuilder* b) { const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>(); b->add32(dce.getEdgeType()); @@ -723,20 +712,13 @@ private: class GLDashingLineEffect : public GrGLGeometryProcessor { public: - GLDashingLineEffect(const GrBackendProcessorFactory&, - const GrGeometryProcessor&, - const GrBatchTracker&); + GLDashingLineEffect(const GrBackendProcessorFactory&, const GrProcessor&); virtual void emitCode(const EmitArgs&) SK_OVERRIDE; - static inline void GenKey(const GrGeometryProcessor&, - const GrBatchTracker&, - const GrGLCaps&, - GrProcessorKeyBuilder*); + static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*); - virtual void setData(const GrGLProgramDataManager&, - const GrGeometryProcessor&, - const GrBatchTracker&) SK_OVERRIDE; + virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE; private: GrGLProgramDataManager::UniformHandle fRectUniform; @@ -747,8 +729,7 @@ private: }; GLDashingLineEffect::GLDashingLineEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) + const GrProcessor&) : INHERITED (factory) { fPrevRect.fLeft = SK_ScalarNaN; fPrevIntervalLength = SK_ScalarMax; @@ -811,8 +792,7 @@ void GLDashingLineEffect::emitCode(const EmitArgs& args) { } void GLDashingLineEffect::setData(const GrGLProgramDataManager& pdman, - const GrGeometryProcessor& processor, - const GrBatchTracker&) { + const GrProcessor& processor) { const DashingLineEffect& de = processor.cast<DashingLineEffect>(); const SkRect& rect = de.getRect(); SkScalar intervalLength = de.getIntervalLength(); @@ -825,9 +805,7 @@ void GLDashingLineEffect::setData(const GrGLProgramDataManager& pdman, } } -void GLDashingLineEffect::GenKey(const GrGeometryProcessor& processor, - const GrBatchTracker&, - const GrGLCaps&, +void GLDashingLineEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, GrProcessorKeyBuilder* b) { const DashingLineEffect& de = processor.cast<DashingLineEffect>(); b->add32(de.getEdgeType()); diff --git a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp index 53f85907e4..5e1bc9968c 100755 --- a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp +++ b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp @@ -23,8 +23,7 @@ class GrGLDistanceFieldTextureEffect : public GrGLGeometryProcessor { public: GrGLDistanceFieldTextureEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) + const GrProcessor&) : INHERITED (factory) , fTextureSize(SkISize::Make(-1,-1)) #ifdef SK_GAMMA_APPLY_TO_A8 @@ -125,11 +124,10 @@ public: } virtual void setData(const GrGLProgramDataManager& pdman, - const GrGeometryProcessor& proc, - const GrBatchTracker&) SK_OVERRIDE { + const GrProcessor& effect) SK_OVERRIDE { SkASSERT(fTextureSizeUni.isValid()); - GrTexture* texture = proc.texture(0); + GrTexture* texture = effect.texture(0); if (texture->width() != fTextureSize.width() || texture->height() != fTextureSize.height()) { fTextureSize = SkISize::Make(texture->width(), texture->height()); @@ -139,7 +137,7 @@ public: } #ifdef SK_GAMMA_APPLY_TO_A8 const GrDistanceFieldTextureEffect& dfTexEffect = - proc.cast<GrDistanceFieldTextureEffect>(); + effect.cast<GrDistanceFieldTextureEffect>(); float luminance = dfTexEffect.getLuminance(); if (luminance != fLuminance) { pdman.set1f(fLuminanceUni, luminance); @@ -148,9 +146,7 @@ public: #endif } - static inline void GenKey(const GrGeometryProcessor& processor, - const GrBatchTracker&, - const GrGLCaps&, + static inline void GenKey(const GrProcessor& processor, const GrGLCaps&, GrProcessorKeyBuilder* b) { const GrDistanceFieldTextureEffect& dfTexEffect = processor.cast<GrDistanceFieldTextureEffect>(); @@ -259,8 +255,7 @@ GrGeometryProcessor* GrDistanceFieldTextureEffect::TestCreate(SkRandom* random, class GrGLDistanceFieldNoGammaTextureEffect : public GrGLGeometryProcessor { public: GrGLDistanceFieldNoGammaTextureEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) + const GrProcessor& effect) : INHERITED(factory) , fTextureSize(SkISize::Make(-1, -1)) {} @@ -343,11 +338,10 @@ public: } virtual void setData(const GrGLProgramDataManager& pdman, - const GrGeometryProcessor& proc, - const GrBatchTracker&) SK_OVERRIDE { + const GrProcessor& effect) SK_OVERRIDE { SkASSERT(fTextureSizeUni.isValid()); - GrTexture* texture = proc.texture(0); + GrTexture* texture = effect.texture(0); if (texture->width() != fTextureSize.width() || texture->height() != fTextureSize.height()) { fTextureSize = SkISize::Make(texture->width(), texture->height()); @@ -357,12 +351,10 @@ public: } } - static inline void GenKey(const GrGeometryProcessor& proc, - const GrBatchTracker&, - const GrGLCaps&, + static inline void GenKey(const GrProcessor& effect, const GrGLCaps&, GrProcessorKeyBuilder* b) { const GrDistanceFieldNoGammaTextureEffect& dfTexEffect = - proc.cast<GrDistanceFieldNoGammaTextureEffect>(); + effect.cast<GrDistanceFieldNoGammaTextureEffect>(); b->add32(dfTexEffect.getFlags()); } @@ -438,8 +430,7 @@ GrGeometryProcessor* GrDistanceFieldNoGammaTextureEffect::TestCreate(SkRandom* r class GrGLDistanceFieldLCDTextureEffect : public GrGLGeometryProcessor { public: GrGLDistanceFieldLCDTextureEffect(const GrBackendProcessorFactory& factory, - const GrGeometryProcessor&, - const GrBatchTracker&) + const GrProcessor&) : INHERITED (factory) , fTextureSize(SkISize::Make(-1,-1)) , fTextColor(GrColor_ILLEGAL) {} @@ -572,8 +563,7 @@ public: } virtual void setData(const GrGLProgramDataManager& pdman, - const GrGeometryProcessor& processor, - const GrBatchTracker&) SK_OVERRIDE { + const GrProcessor& processor) SK_OVERRIDE { SkASSERT(fTextureSizeUni.isValid()); SkASSERT(fTextColorUni.isValid()); @@ -604,9 +594,7 @@ public: } } - static inline void GenKey(const GrGeometryProcessor& processor, - const GrBatchTracker&, - const GrGLCaps&, + static inline void GenKey(const GrProcessor& processor, const GrGLCaps&, GrProcessorKeyBuilder* b) { const GrDistanceFieldLCDTextureEffect& dfTexEffect = processor.cast<GrDistanceFieldLCDTextureEffect>(); diff --git a/src/gpu/gl/GrGLGeometryProcessor.h b/src/gpu/gl/GrGLGeometryProcessor.h index a172904ac6..c3bee95266 100644 --- a/src/gpu/gl/GrGLGeometryProcessor.h +++ b/src/gpu/gl/GrGLGeometryProcessor.h @@ -10,7 +10,6 @@ #include "GrGLProcessor.h" -class GrBatchTracker; class GrGLGPBuilder; /** @@ -26,19 +25,16 @@ public: struct EmitArgs { EmitArgs(GrGLGPBuilder* pb, const GrGeometryProcessor& gp, - const GrBatchTracker& bt, const char* outputColor, const char* outputCoverage, const TextureSamplerArray& samplers) : fPB(pb) , fGP(gp) - , fBT(bt) , fOutputColor(outputColor) , fOutputCoverage(outputCoverage) , fSamplers(samplers) {} GrGLGPBuilder* fPB; const GrGeometryProcessor& fGP; - const GrBatchTracker& fBT; const char* fOutputColor; const char* fOutputCoverage; const TextureSamplerArray& fSamplers; @@ -49,15 +45,6 @@ public: */ virtual void emitCode(const EmitArgs&) = 0; - /** A GrGLGeometryProcessor instance can be reused with any GrGLGeometryProcessor that produces - the same stage key; this function reads data from a GrGLGeometryProcessor and uploads any - uniform variables required by the shaders created in emitCode(). The GrGeometryProcessor - parameter is guaranteed to be of the same type that created this GrGLGeometryProcessor and - to have an identical processor key as the one that created this GrGLGeometryProcessor. */ - virtual void setData(const GrGLProgramDataManager&, - const GrGeometryProcessor&, - const GrBatchTracker&) = 0; - private: typedef GrGLProcessor INHERITED; }; diff --git a/src/gpu/gl/GrGLProcessor.h b/src/gpu/gl/GrGLProcessor.h index 6401e2b324..ca4fa2459f 100644 --- a/src/gpu/gl/GrGLProcessor.h +++ b/src/gpu/gl/GrGLProcessor.h @@ -22,7 +22,7 @@ that their GrGLProcessors would emit the same GLSL code. The GrGLProcessor subclass must also have a constructor of the form: - ProcessorSubclass::ProcessorSubclass(const GrBackendProcessorFactory&, const GrProcessor&) + EffectSubclass::EffectSubclass(const GrBackendProcessorFactory&, const GrProcessor&) These objects are created by the factory object returned by the GrProcessor::getFactory(). */ @@ -70,6 +70,13 @@ public: virtual ~GrGLProcessor() {} + /** A GrGLProcessor instance can be reused with any GrProcessor that produces the same stage + key; this function reads data from a GrProcessor and uploads any uniform variables required + by the shaders created in emitCode(). The GrProcessor parameter is guaranteed to be of the + same type that created this GrGLProcessor and to have an identical effect key as the one + that created this GrGLProcessor. */ + virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) {} + const char* name() const { return fFactory.name(); } static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {} @@ -93,7 +100,7 @@ public: stages. @param builder Interface used to emit code in the shaders. - @param processor The processor that generated this program stage. + @param effect The effect that generated this program stage. @param key The key that was computed by GenKey() from the generating GrProcessor. @param outputColor A predefined vec4 in the FS in which the stage should place its output color (or coverage). @@ -101,27 +108,19 @@ public: NULL in which case the implied input is solid white (all ones). TODO: Better system for communicating optimization info (e.g. input color is solid white, trans black, known to be opaque, etc.) that allows - the processor to communicate back similar known info about its output. + the effect to communicate back similar known info about its output. @param samplers Contains one entry for each GrTextureAccess of the GrProcessor. These can be passed to the builder to emit texture reads in the generated code. TODO this should take a struct */ virtual void emitCode(GrGLFPBuilder* builder, - const GrFragmentProcessor&, + const GrFragmentProcessor& effect, const char* outputColor, const char* inputColor, const TransformedCoordsArray& coords, const TextureSamplerArray& samplers) = 0; - /** A GrGLFragmentProcessor instance can be reused with any GrFragmentProcessor that produces - the same stage key; this function reads data from a GrFragmentProcessor and uploads any - uniform variables required by the shaders created in emitCode(). The GrFragmentProcessor - parameter is guaranteed to be of the same type that created this GrGLFragmentProcessor and - to have an identical processor key as the one that created this GrGLFragmentProcessor. */ - // TODO update this to pass in GrFragmentProcessor - virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) {} - private: typedef GrGLProcessor INHERITED; }; diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index 29c44ac56c..3b04edb8c8 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -158,8 +158,7 @@ void GrGLProgram::setData(const GrOptDrawState& optState) { if (fGeometryProcessor.get()) { SkASSERT(optState.hasGeometryProcessor()); const GrGeometryProcessor& gp = *optState.getGeometryProcessor(); - const GrBatchTracker& bt = optState.getBatchTracker(); - fGeometryProcessor->fGLProc->setData(fProgramDataManager, gp, bt); + fGeometryProcessor->fGLProc->setData(fProgramDataManager, gp); this->bindTextures(fGeometryProcessor, gp); } this->setFragmentData(optState); diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp index 474f7026e4..f8dbbc26f9 100644 --- a/src/gpu/gl/GrGLProgramDesc.cpp +++ b/src/gpu/gl/GrGLProgramDesc.cpp @@ -123,6 +123,9 @@ static bool get_meta_key(const GrProcessor& proc, uint32_t transformKey, uint32_t attribKey, GrProcessorKeyBuilder* b) { + const GrBackendProcessorFactory& factory = proc.getFactory(); + factory.getGLProcessorKey(proc, caps, b); + size_t processorKeySize = b->size(); uint32_t textureKey = gen_texture_key(proc, caps); uint32_t classID = proc.getFactory().classID(); @@ -167,8 +170,6 @@ 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); if (!get_meta_key(gp, gpu->glCaps(), 0, gen_attrib_key(gp), &b)) { desc->fKey.reset(); return false; @@ -177,10 +178,7 @@ bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState, for (int s = 0; s < optState.numFragmentStages(); ++s) { 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); 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..aa9e40c3f2 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -359,13 +359,12 @@ void GrGLProgramBuilder::emitAndInstallProc(const GrGeometryProcessor& gp, SkASSERT(!fGeometryProcessor); fGeometryProcessor = SkNEW(GrGLInstalledGeoProc); - const GrBatchTracker& bt = fOptState.getBatchTracker(); - fGeometryProcessor->fGLProc.reset(gp.getFactory().createGLInstance(gp, bt)); + fGeometryProcessor->fGLProc.reset(gp.getFactory().createGLInstance(gp)); SkSTArray<4, GrGLProcessor::TextureSampler> samplers(gp.numTextures()); this->emitSamplers(gp, &samplers, fGeometryProcessor); - GrGLGeometryProcessor::EmitArgs args(this, gp, bt, outColor, outCoverage, samplers); + GrGLGeometryProcessor::EmitArgs args(this, gp, outColor, outCoverage, samplers); fGeometryProcessor->fGLProc->emitCode(args); // We have to check that effects and the code they emit are consistent, ie if an effect |