Chromium Code Reviews| Index: include/gpu/GrXferProcessor.h |
| diff --git a/include/gpu/GrXferProcessor.h b/include/gpu/GrXferProcessor.h |
| index fa9dca211e8fcd24ea0fb81c4c8b743da09a33f8..3dcc12a3748386c9a4dd78665bc94cc7b487e03f 100644 |
| --- a/include/gpu/GrXferProcessor.h |
| +++ b/include/gpu/GrXferProcessor.h |
| @@ -108,6 +108,47 @@ enum GrXferBarrierType { |
| class GrXferProcessor : public GrProcessor { |
| public: |
| /** |
| + * A texture that contains the dst pixel values and an integer coord offset from device space |
| + * to the space of the texture. Depending on GPU capabilities a DstTexture may be used by a |
| + * GrXferProcessor for blending in the fragment shader. |
| + */ |
| + class DstTexture { |
| + public: |
| + DstTexture() { fOffset.set(0, 0); } |
| + |
| + DstTexture(const DstTexture& other) { |
| + *this = other; |
| + } |
| + |
| + DstTexture(GrTexture* texture, const SkIPoint& offset) |
| + : fTexture(SkSafeRef(texture)) |
| + , fOffset(offset) { |
| + } |
| + |
| + DstTexture& operator=(const DstTexture& other) { |
| + fTexture.reset(SkSafeRef(other.fTexture.get())); |
| + fOffset = other.fOffset; |
| + return *this; |
| + } |
| + |
| + const SkIPoint& offset() const { return fOffset; } |
| + |
| + void setOffset(const SkIPoint& offset) { fOffset = offset; } |
| + void setOffset(int ox, int oy) { fOffset.set(ox, oy); } |
| + |
| + GrTexture* texture() const { return fTexture.get(); } |
| + |
| + GrTexture* setTexture(GrTexture* texture) { |
| + fTexture.reset(SkSafeRef(texture)); |
| + return texture; |
| + } |
| + |
| + private: |
| + SkAutoTUnref<GrTexture> fTexture; |
| + SkIPoint fOffset; |
| + }; |
| + |
| + /** |
| * Sets a unique key on the GrProcessorKeyBuilder calls onGetGLProcessorKey(...) to get the |
| * specific subclass's key. |
| */ |
| @@ -207,15 +248,15 @@ public: |
| * shader. If the returned texture is NULL then the XP is either not reading the dst or we have |
| * extentions that support framebuffer fetching and thus don't need a copy of the dst texture. |
| */ |
| - const GrTexture* getDstCopyTexture() const { return fDstCopy.getTexture(); } |
| + const GrTexture* getDstTexture() const { return fDstTexture.getTexture(); } |
| /** |
| - * Returns the offset into the DstCopyTexture to use when reading it in the shader. This value |
| - * is only valid if getDstCopyTexture() != NULL. |
| + * Returns the offset in device coords to use when accessing the dst texture to get the dst |
| + * pixel color in the shader. This value is only valid if getDstTexture() != NULL. |
| */ |
| - const SkIPoint& dstCopyTextureOffset() const { |
| - SkASSERT(this->getDstCopyTexture()); |
| - return fDstCopyTextureOffset; |
| + const SkIPoint& dstTextureOffset() const { |
| + SkASSERT(this->getDstTexture()); |
| + return fDstTextureOffset; |
| } |
| /** |
| @@ -246,10 +287,10 @@ public: |
| if (this->fReadsCoverage != that.fReadsCoverage) { |
| return false; |
| } |
| - if (this->fDstCopy.getTexture() != that.fDstCopy.getTexture()) { |
| + if (this->fDstTexture.getTexture() != that.fDstTexture.getTexture()) { |
| return false; |
| } |
| - if (this->fDstCopyTextureOffset != that.fDstCopyTextureOffset) { |
| + if (this->fDstTextureOffset != that.fDstTextureOffset) { |
| return false; |
| } |
| return this->onIsEqual(that); |
| @@ -257,7 +298,7 @@ public: |
| protected: |
| GrXferProcessor(); |
| - GrXferProcessor(const GrDeviceCoordTexture* dstCopy, bool willReadDstColor); |
| + GrXferProcessor(const DstTexture*, bool willReadDstColor); |
| private: |
| virtual OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, |
| @@ -294,8 +335,8 @@ private: |
| bool fWillReadDstColor; |
| bool fReadsCoverage; |
| - SkIPoint fDstCopyTextureOffset; |
| - GrTextureAccess fDstCopy; |
| + SkIPoint fDstTextureOffset; |
|
egdaniel
2015/05/18 19:07:13
Do we want to keep saving the Offset and Texture s
|
| + GrTextureAccess fDstTexture; |
| typedef GrFragmentProcessor INHERITED; |
| }; |
| @@ -317,9 +358,10 @@ GR_MAKE_BITFIELD_OPS(GrXferProcessor::OptFlags); |
| */ |
| class GrXPFactory : public SkRefCnt { |
| public: |
| + typedef GrXferProcessor::DstTexture DstTexture; |
| GrXferProcessor* createXferProcessor(const GrProcOptInfo& colorPOI, |
| const GrProcOptInfo& coveragePOI, |
| - const GrDeviceCoordTexture* dstCopy, |
| + const DstTexture*, |
| const GrDrawTargetCaps& caps) const; |
| /** |
| @@ -343,8 +385,8 @@ public: |
| virtual void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI, |
| InvariantOutput*) const = 0; |
| - bool willNeedDstCopy(const GrDrawTargetCaps& caps, const GrProcOptInfo& colorPOI, |
| - const GrProcOptInfo& coveragePOI) const; |
| + bool willNeedDstTexture(const GrDrawTargetCaps& caps, const GrProcOptInfo& colorPOI, |
| + const GrProcOptInfo& coveragePOI) const; |
| bool isEqual(const GrXPFactory& that) const { |
| if (this->classID() != that.classID()) { |
| @@ -374,7 +416,7 @@ private: |
| virtual GrXferProcessor* onCreateXferProcessor(const GrDrawTargetCaps& caps, |
| const GrProcOptInfo& colorPOI, |
| const GrProcOptInfo& coveragePOI, |
| - const GrDeviceCoordTexture* dstCopy) const = 0; |
| + const DstTexture*) const = 0; |
| /** |
| * Returns true if the XP generated by this factory will explicitly read dst in the fragment |
| * shader. |