diff options
author | joshualitt <joshualitt@chromium.org> | 2014-10-10 17:47:00 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-10 17:47:00 -0700 |
commit | a5305a110ab5201d5dadd40cbe711582d5ac4996 (patch) | |
tree | 239878bf237402e4fb7d88081d4f1289c5824d2e /include | |
parent | ba5fb932a1b5666a861043735cfb055cc1b600c7 (diff) |
Opt state takes a GP instead of a GeometryStage
BUG=skia:
Committed: https://skia.googlesource.com/skia/+/71856d520461ae025a0332aa0ce9735a096d9baf
Review URL: https://codereview.chromium.org/637003003
Diffstat (limited to 'include')
-rw-r--r-- | include/gpu/GrProcessor.h | 35 | ||||
-rw-r--r-- | include/gpu/GrProcessorStage.h | 44 |
2 files changed, 26 insertions, 53 deletions
diff --git a/include/gpu/GrProcessor.h b/include/gpu/GrProcessor.h index c1755a8954..a5c834168b 100644 --- a/include/gpu/GrProcessor.h +++ b/include/gpu/GrProcessor.h @@ -124,12 +124,6 @@ public: in generated shader code. */ const char* name() const; - int numTransforms() const { return fCoordTransforms.count(); } - - /** Returns the coordinate transformation at index. index must be valid according to - numTransforms(). */ - const GrCoordTransform& coordTransform(int index) const { return *fCoordTransforms[index]; } - int numTextures() const { return fTextureAccesses.count(); } /** Returns the access pattern for the texture at index. index must be valid according to @@ -159,16 +153,6 @@ public: protected: /** - * Subclasses call this from their constructor to register coordinate transformations. The - * effect subclass manages the lifetime of the transformations (this function only stores a - * pointer). The GrCoordTransform is typically a member field of the GrProcessor subclass. When - * the matrix has perspective, the transformed coordinates will have 3 components. Otherwise - * they'll have 2. This must only be called from the constructor because GrProcessors are - * immutable. - */ - void addCoordTransform(const GrCoordTransform* coordTransform); - - /** * Subclasses call this from their constructor to register GrTextureAccesses. The effect * subclass manages the lifetime of the accesses (this function only stores a pointer). The * GrTextureAccess is typically a member field of the GrProcessor subclass. This must only be @@ -198,9 +182,7 @@ private: * Subclass implements this to support getConstantColorComponents(...). */ virtual void onComputeInvariantOutput(InvariantOutput* inout) const = 0; - friend class GrGeometryProcessor; // to set fRequiresVertexShader and build fVertexAttribTypes. - SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses; bool fWillReadFragmentPosition; @@ -216,6 +198,12 @@ public: virtual const GrBackendFragmentProcessorFactory& getFactory() const = 0; + int numTransforms() const { return fCoordTransforms.count(); } + + /** Returns the coordinate transformation at index. index must be valid according to + numTransforms(). */ + const GrCoordTransform& coordTransform(int index) const { return *fCoordTransforms[index]; } + /** Will this effect read the destination pixel value? */ bool willReadDstColor() const { return fWillReadDstColor; } @@ -224,6 +212,16 @@ public: protected: /** + * Fragment Processor subclasses call this from their constructor to register coordinate + * transformations. The processor subclass manages the lifetime of the transformations (this + * function only stores a pointer). The GrCoordTransform is typically a member field of the + * GrProcessor subclass. When the matrix has perspective, the transformed coordinates will have + * 3 components. Otherwise they'll have 2. This must only be called from the constructor because + * GrProcessors are immutable. + */ + void addCoordTransform(const GrCoordTransform*); + + /** * If the effect subclass will read the destination pixel value then it must call this function * from its constructor. Otherwise, when its generated backend-specific effect class attempts * to generate code that reads the destination pixel it will fail. @@ -238,6 +236,7 @@ protected: void setWillNotUseInputColor() { fWillUseInputColor = false; } private: + SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; bool fWillReadDstColor; bool fWillUseInputColor; diff --git a/include/gpu/GrProcessorStage.h b/include/gpu/GrProcessorStage.h index 5cc06e78db..c961572c1d 100644 --- a/include/gpu/GrProcessorStage.h +++ b/include/gpu/GrProcessorStage.h @@ -24,16 +24,14 @@ // is immutable, and only owns pending execution refs. This requries removing the common base // class from GrDrawState and GrOptDrawState called GrRODrawState and converting to GrOptDrawState // when draws are enqueued in the GrInOrderDrawBuffer. -class GrProcessorStage { +class GrFragmentStage { public: - explicit GrProcessorStage(const GrProcessor* proc) + explicit GrFragmentStage(const GrFragmentProcessor* proc) : fProc(SkRef(proc)) { fCoordChangeMatrixSet = false; } - virtual ~GrProcessorStage() {} - - GrProcessorStage(const GrProcessorStage& other) { + GrFragmentStage(const GrFragmentStage& other) { fCoordChangeMatrixSet = other.fCoordChangeMatrixSet; if (other.fCoordChangeMatrixSet) { fCoordChangeMatrix = other.fCoordChangeMatrix; @@ -41,7 +39,7 @@ public: fProc.initAndRef(other.fProc); } - static bool AreCompatible(const GrProcessorStage& a, const GrProcessorStage& b, + static bool AreCompatible(const GrFragmentStage& a, const GrFragmentStage& b, bool usingExplicitLocalCoords) { SkASSERT(a.fProc.get()); SkASSERT(b.fProc.get()); @@ -90,7 +88,7 @@ public: SkMatrix fCoordChangeMatrix; SkDEBUGCODE(mutable uint32_t fEffectUniqueID;) - friend class GrProcessorStage; + friend class GrFragmentStage; }; /** @@ -149,38 +147,14 @@ public: } } - virtual const GrProcessor* getProcessor() const = 0; + const GrFragmentProcessor* getProcessor() const { return fProc.get(); } void convertToPendingExec() { fProc.convertToPendingExec(); } protected: - bool fCoordChangeMatrixSet; - SkMatrix fCoordChangeMatrix; - GrProgramElementRef<const GrProcessor> fProc; -}; - -class GrFragmentStage : public GrProcessorStage { -public: - GrFragmentStage(const GrFragmentProcessor* fp) : GrProcessorStage(fp) {} - - virtual const GrFragmentProcessor* getProcessor() const { - return static_cast<const GrFragmentProcessor*>(fProc.get()); - } - - typedef GrFragmentProcessor Processor; - typedef GrGLFragmentProcessor GLProcessor; -}; - -class GrGeometryStage : public GrProcessorStage { -public: - GrGeometryStage(const GrGeometryProcessor* gp) : GrProcessorStage(gp) {} - - virtual const GrGeometryProcessor* getProcessor() const { - return static_cast<const GrGeometryProcessor*>(fProc.get()); - } - - typedef GrGeometryProcessor Processor; - typedef GrGLGeometryProcessor GLProcessor; + bool fCoordChangeMatrixSet; + SkMatrix fCoordChangeMatrix; + GrProgramElementRef<const GrFragmentProcessor> fProc; }; #endif |