diff options
author | joshualitt <joshualitt@chromium.org> | 2014-10-10 14:11:59 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-10 14:11:59 -0700 |
commit | 89c7a2ec3e9f7e1b9705214f450bb12288799da9 (patch) | |
tree | 846fda99f953334024ec35a748bc307a3a1cb936 /include | |
parent | 93bee71a41701eb6cb55fe6df50f3a4081cc8a01 (diff) |
Revert of Opt state takes a GP instead of a GeometryStage (patchset #18 id:1500001 of https://codereview.chromium.org/637003003/)
Reason for revert:
Revert because this may be causing a break in a chrome gpu test
Original issue's description:
> Opt state takes a GP instead of a GeometryStage
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/71856d520461ae025a0332aa0ce9735a096d9baf
TBR=bsalomon@google.com,egdaniel@google.com,danakj@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/647183002
Diffstat (limited to 'include')
-rw-r--r-- | include/gpu/GrProcessor.h | 35 | ||||
-rw-r--r-- | include/gpu/GrProcessorStage.h | 44 |
2 files changed, 53 insertions, 26 deletions
diff --git a/include/gpu/GrProcessor.h b/include/gpu/GrProcessor.h index a5c834168b..c1755a8954 100644 --- a/include/gpu/GrProcessor.h +++ b/include/gpu/GrProcessor.h @@ -124,6 +124,12 @@ 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 @@ -153,6 +159,16 @@ 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 @@ -182,7 +198,9 @@ 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; @@ -198,12 +216,6 @@ 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; } @@ -212,16 +224,6 @@ 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. @@ -236,7 +238,6 @@ 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 c961572c1d..5cc06e78db 100644 --- a/include/gpu/GrProcessorStage.h +++ b/include/gpu/GrProcessorStage.h @@ -24,14 +24,16 @@ // 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 GrFragmentStage { +class GrProcessorStage { public: - explicit GrFragmentStage(const GrFragmentProcessor* proc) + explicit GrProcessorStage(const GrProcessor* proc) : fProc(SkRef(proc)) { fCoordChangeMatrixSet = false; } - GrFragmentStage(const GrFragmentStage& other) { + virtual ~GrProcessorStage() {} + + GrProcessorStage(const GrProcessorStage& other) { fCoordChangeMatrixSet = other.fCoordChangeMatrixSet; if (other.fCoordChangeMatrixSet) { fCoordChangeMatrix = other.fCoordChangeMatrix; @@ -39,7 +41,7 @@ public: fProc.initAndRef(other.fProc); } - static bool AreCompatible(const GrFragmentStage& a, const GrFragmentStage& b, + static bool AreCompatible(const GrProcessorStage& a, const GrProcessorStage& b, bool usingExplicitLocalCoords) { SkASSERT(a.fProc.get()); SkASSERT(b.fProc.get()); @@ -88,7 +90,7 @@ public: SkMatrix fCoordChangeMatrix; SkDEBUGCODE(mutable uint32_t fEffectUniqueID;) - friend class GrFragmentStage; + friend class GrProcessorStage; }; /** @@ -147,14 +149,38 @@ public: } } - const GrFragmentProcessor* getProcessor() const { return fProc.get(); } + virtual const GrProcessor* getProcessor() const = 0; void convertToPendingExec() { fProc.convertToPendingExec(); } protected: - bool fCoordChangeMatrixSet; - SkMatrix fCoordChangeMatrix; - GrProgramElementRef<const GrFragmentProcessor> fProc; + 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; }; #endif |