aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-02-06 07:02:37 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-06 07:02:37 -0800
commit50785a3d10b53bea5beb6e18431a2449860be237 (patch)
tree32a67ea76db96f6f94f7d1ce54ff354da5c30e95 /include/gpu
parent5245cb427f982dbae365a52cf19256cfbcc6870a (diff)
Revert of Revert of Move DstCopy on gpu into the GrXferProcessor. (patchset #1 id:1 of https://codereview.chromium.org/901663007/)
Reason for revert: The revert didn't help the 10.9 bot. Unreverting by reverting the revert (which is basically relanding the original patch which itself was a revert of a revert). Revert. Original issue's description: > Revert of Move DstCopy on gpu into the GrXferProcessor. (patchset #11 id:200001 of https://codereview.chromium.org/885923002/) > > Reason for revert: > Testing to see if reverting fixes 10.9 bots. > > Original issue's description: > > Move DstCopy on gpu into the GrXferProcessor. > > > > BUG=skia: > > > > Committed: https://skia.googlesource.com/skia/+/74a11753604768bf461b80cabb66060e8564d82c > > > > Committed: https://skia.googlesource.com/skia/+/5e1378d0e075a323144ba14e0a4cbcca35eccc69 > > TBR=joshualitt@google.com,egdaniel@google.com > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/21b2c53218ab25f4268e3992e51d916076a2a7ee TBR=joshualitt@google.com,egdaniel@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/873723009
Diffstat (limited to 'include/gpu')
-rw-r--r--include/gpu/GrXferProcessor.h75
-rw-r--r--include/gpu/effects/GrPorterDuffXferProcessor.h25
2 files changed, 71 insertions, 29 deletions
diff --git a/include/gpu/GrXferProcessor.h b/include/gpu/GrXferProcessor.h
index 13e4d2633f..03d52a93d7 100644
--- a/include/gpu/GrXferProcessor.h
+++ b/include/gpu/GrXferProcessor.h
@@ -10,6 +10,7 @@
#include "GrColor.h"
#include "GrProcessor.h"
+#include "GrTexture.h"
#include "GrTypes.h"
#include "SkXfermode.h"
@@ -34,11 +35,10 @@ class GrProcOptInfo;
class GrXferProcessor : public GrProcessor {
public:
/**
- * Sets a unique key on the GrProcessorKeyBuilder that is directly associated with this xfer
- * processor's GL backend implementation.
- */
- virtual void getGLProcessorKey(const GrGLCaps& caps,
- GrProcessorKeyBuilder* b) const = 0;
+ * Sets a unique key on the GrProcessorKeyBuilder calls onGetGLProcessorKey(...) to get the
+ * specific subclass's key.
+ */
+ void getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const;
/** Returns a new instance of the appropriate *GL* implementation class
for the given GrXferProcessor; caller is responsible for deleting
@@ -103,9 +103,24 @@ public:
virtual void getBlendInfo(BlendInfo* blendInfo) const = 0;
- /** Will this prceossor read the destination pixel value? */
bool willReadDstColor() const { return fWillReadDstColor; }
+ /**
+ * Returns the texture to be used as the destination when reading the dst in the fragment
+ * 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(); }
+
+ /**
+ * Returns the offset into the DstCopyTexture to use when reading it in the shader. This value
+ * is only valid if getDstCopyTexture() != NULL.
+ */
+ const SkIPoint& dstCopyTextureOffset() const {
+ SkASSERT(this->getDstCopyTexture());
+ return fDstCopyTextureOffset;
+ }
+
/**
* Returns whether or not this xferProcossor will set a secondary output to be used with dual
* source blending.
@@ -123,29 +138,43 @@ public:
if (this->classID() != that.classID()) {
return false;
}
+ if (this->fWillReadDstColor != that.fWillReadDstColor) {
+ return false;
+ }
+ if (this->fDstCopy.getTexture() != that.fDstCopy.getTexture()) {
+ return false;
+ }
+ if (this->fDstCopyTextureOffset != that.fDstCopyTextureOffset) {
+ return false;
+ }
return this->onIsEqual(that);
}
protected:
- GrXferProcessor() : fWillReadDstColor(false) {}
+ GrXferProcessor();
+ GrXferProcessor(const GrDeviceCoordTexture* dstCopy, bool willReadDstColor);
+private:
/**
- * If the prceossor subclass will read the destination pixel value then it must call this
- * function from its constructor. Otherwise, when its generated backend-specific prceossor class
- * attempts to generate code that reads the destination pixel it will fail.
+ * Sets a unique key on the GrProcessorKeyBuilder that is directly associated with this xfer
+ * processor's GL backend implementation.
*/
- void setWillReadDstColor() { fWillReadDstColor = true; }
+ virtual void onGetGLProcessorKey(const GrGLCaps& caps,
+ GrProcessorKeyBuilder* b) const = 0;
-private:
virtual bool onIsEqual(const GrXferProcessor&) const = 0;
- bool fWillReadDstColor;
+ bool fWillReadDstColor;
+ SkIPoint fDstCopyTextureOffset;
+ GrTextureAccess fDstCopy;
typedef GrFragmentProcessor INHERITED;
};
GR_MAKE_BITFIELD_OPS(GrXferProcessor::OptFlags);
+///////////////////////////////////////////////////////////////////////////////
+
/**
* We install a GrXPFactory (XPF) early on in the pipeline before all the final draw information is
* known (e.g. whether there is fractional pixel coverage, will coverage be 1 or 4 channel, is the
@@ -159,8 +188,10 @@ GR_MAKE_BITFIELD_OPS(GrXferProcessor::OptFlags);
*/
class GrXPFactory : public SkRefCnt {
public:
- virtual GrXferProcessor* createXferProcessor(const GrProcOptInfo& colorPOI,
- const GrProcOptInfo& coveragePOI) const = 0;
+ GrXferProcessor* createXferProcessor(const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& coveragePOI,
+ const GrDeviceCoordTexture* dstCopy,
+ const GrDrawTargetCaps& caps) const;
/**
* This function returns true if the GrXferProcessor generated from this factory will be able to
@@ -202,10 +233,7 @@ public:
*/
virtual bool canTweakAlphaForCoverage() const = 0;
- /**
- * Returns true if the XP generated by this factory will read dst.
- */
- virtual bool willReadDst() const = 0;
+ bool willNeedDstCopy(const GrDrawTargetCaps& caps) const;
bool isEqual(const GrXPFactory& that) const {
if (this->classID() != that.classID()) {
@@ -232,6 +260,15 @@ protected:
uint32_t fClassID;
private:
+ virtual GrXferProcessor* onCreateXferProcessor(const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& coveragePOI,
+ const GrDeviceCoordTexture* dstCopy) const = 0;
+ /**
+ * Returns true if the XP generated by this factory will explicitly read dst in the fragment
+ * shader.
+ */
+ virtual bool willReadDstColor() const = 0;
+
virtual bool onIsEqual(const GrXPFactory&) const = 0;
static uint32_t GenClassID() {
diff --git a/include/gpu/effects/GrPorterDuffXferProcessor.h b/include/gpu/effects/GrPorterDuffXferProcessor.h
index af10fa23ec..e47ec1e904 100644
--- a/include/gpu/effects/GrPorterDuffXferProcessor.h
+++ b/include/gpu/effects/GrPorterDuffXferProcessor.h
@@ -12,21 +12,22 @@
#include "GrXferProcessor.h"
#include "SkXfermode.h"
+class GrDrawTargetCaps;
class GrProcOptInfo;
class GrPorterDuffXferProcessor : public GrXferProcessor {
public:
static GrXferProcessor* Create(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend,
- GrColor constant = 0) {
- return SkNEW_ARGS(GrPorterDuffXferProcessor, (srcBlend, dstBlend, constant));
+ GrColor constant, const GrDeviceCoordTexture* dstCopy,
+ bool willReadDstColor) {
+ return SkNEW_ARGS(GrPorterDuffXferProcessor, (srcBlend, dstBlend, constant, dstCopy,
+ willReadDstColor));
}
~GrPorterDuffXferProcessor() SK_OVERRIDE;
const char* name() const SK_OVERRIDE { return "Porter Duff"; }
- void getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const SK_OVERRIDE;
-
GrGLXferProcessor* createGLInstance() const SK_OVERRIDE;
bool hasSecondaryOutput() const SK_OVERRIDE;
@@ -75,7 +76,10 @@ public:
}
private:
- GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend, GrColor constant);
+ GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend, GrColor constant,
+ const GrDeviceCoordTexture* dstCopy, bool willReadDstColor);
+
+ void onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const SK_OVERRIDE;
bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE {
const GrPorterDuffXferProcessor& xp = xpBase.cast<GrPorterDuffXferProcessor>();
@@ -119,9 +123,6 @@ public:
return SkNEW_ARGS(GrPorterDuffXPFactory, (src, dst));
}
- GrXferProcessor* createXferProcessor(const GrProcOptInfo& colorPOI,
- const GrProcOptInfo& coveragePOI) const SK_OVERRIDE;
-
bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const SK_OVERRIDE;
bool canApplyCoverage(const GrProcOptInfo& colorPOI,
@@ -132,11 +133,15 @@ public:
void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI,
GrXPFactory::InvariantOutput*) const SK_OVERRIDE;
- bool willReadDst() const SK_OVERRIDE { return false; }
-
private:
GrPorterDuffXPFactory(GrBlendCoeff src, GrBlendCoeff dst);
+ GrXferProcessor* onCreateXferProcessor(const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& coveragePOI,
+ const GrDeviceCoordTexture* dstCopy) const SK_OVERRIDE;
+
+ bool willReadDstColor() const SK_OVERRIDE;
+
bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE {
const GrPorterDuffXPFactory& xpf = xpfBase.cast<GrPorterDuffXPFactory>();
return (fSrcCoeff == xpf.fSrcCoeff && fDstCoeff == xpf.fDstCoeff);