aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/GrXferProcessor.h
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-05-26 09:49:05 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-26 09:49:05 -0700
commit6a44c6a7d89b748fb040d41697a337d357d7fa22 (patch)
treeb579537e83e03bf1b982a4a823ab4a63f1f6a993 /include/gpu/GrXferProcessor.h
parent36ec383c579066520357605eb8726193f251187e (diff)
Move DstCoordTexture to GrXP, rename and remove the word "copy" from dstcopytexture names.
Diffstat (limited to 'include/gpu/GrXferProcessor.h')
-rw-r--r--include/gpu/GrXferProcessor.h72
1 files changed, 57 insertions, 15 deletions
diff --git a/include/gpu/GrXferProcessor.h b/include/gpu/GrXferProcessor.h
index 8458a620fe..a9faad016c 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;
+ 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 GrCaps& caps) const;
/**
@@ -343,8 +385,8 @@ public:
virtual void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI,
InvariantOutput*) const = 0;
- bool willNeedDstCopy(const GrCaps& caps, const GrProcOptInfo& colorPOI,
- const GrProcOptInfo& coveragePOI) const;
+ bool willNeedDstTexture(const GrCaps& 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 GrCaps& 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.