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
diff --git a/src/gpu/GrXferProcessor.cpp b/src/gpu/GrXferProcessor.cpp
new file mode 100644
index 0000000..e98ae40
--- /dev/null
+++ b/src/gpu/GrXferProcessor.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrXferProcessor.h"
+#include "gl/GrGLCaps.h"
+
+GrXferProcessor::GrXferProcessor() : fWillReadDstColor(false), fDstCopyTextureOffset() {
+}
+
+GrXferProcessor::GrXferProcessor(const GrDeviceCoordTexture* dstCopy, bool willReadDstColor)
+ : fWillReadDstColor(willReadDstColor)
+ , fDstCopyTextureOffset() {
+ if (dstCopy && dstCopy->texture()) {
+ fDstCopy.reset(dstCopy->texture());
+ fDstCopyTextureOffset = dstCopy->offset();
+ this->addTextureAccess(&fDstCopy);
+ }
+}
+
+void GrXferProcessor::getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const {
+ uint32_t key = this->willReadDstColor() ? 0x1 : 0x0;
+ if (this->getDstCopyTexture() &&
+ kTopLeft_GrSurfaceOrigin == this->getDstCopyTexture()->origin()) {
+ key |= 0x2;
+ }
+ b->add32(key);
+ this->onGetGLProcessorKey(caps, b);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+GrXferProcessor* GrXPFactory::createXferProcessor(const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& coveragePOI,
+ const GrDeviceCoordTexture* dstCopy,
+ const GrDrawTargetCaps& caps) const {
+#ifdef SK_DEBUG
+ if (this->willReadDstColor()) {
+ if (!caps.dstReadInShaderSupport()) {
+ SkASSERT(dstCopy && dstCopy->texture());
+ } else {
+ SkASSERT(!dstCopy || !dstCopy->texture());
+ }
+ } else {
+ SkASSERT(!dstCopy || !dstCopy->texture());
+
+ }
+#endif
+ return this->onCreateXferProcessor(colorPOI, coveragePOI, dstCopy);
+}
+
+bool GrXPFactory::willNeedDstCopy(const GrDrawTargetCaps& caps) const {
+ return (this->willReadDstColor() && !caps.dstReadInShaderSupport());
+}
+