Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Unified Diff: src/gpu/GrXferProcessor.cpp

Issue 885923002: Move DstCopy on gpu into the GrXferProcessor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Some clean up Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrXferProcessor.cpp
diff --git a/src/gpu/GrXferProcessor.cpp b/src/gpu/GrXferProcessor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e2d714208f525129ae9aa8984e8f0bd77dfe88d7
--- /dev/null
+++ b/src/gpu/GrXferProcessor.cpp
@@ -0,0 +1,74 @@
+/*
+ * 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"
+
+// Interpretation of DstReadKey when generating code
+enum {
+ kNoDstRead_DstReadKey = 0,
+ kYesDstRead_DstReadKeyBit = 0x1, // Set if we read the dst.
+ kDstCopyRead_DstReadKeyBit = 0x2, // Set if we use a dst-copy-read.
+ kTopLeftOrigin_DstReadKeyBit = 0x4, // Set if dst-copy origin is top-left.
bsalomon 2015/01/30 14:59:15 canonicalize on always tl or bl?
egdaniel 2015/02/03 16:47:44 Done.
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
+GrXferProcessor::GrXferProcessor() : fWillReadDstColor(false), fDstReadKey(kNoDstRead_DstReadKey) {
+}
+
+GrXferProcessor::GrXferProcessor(const GrDeviceCoordTexture* dstCopy, int32_t dstReadKey)
+ : fWillReadDstColor(false)
+ , fDstReadKey(dstReadKey) {
+ if (dstCopy && dstCopy->texture()) {
+ SkASSERT(kDstCopyRead_DstReadKeyBit & fDstReadKey);
+ fDstCopy.reset(dstCopy->texture());
+ fOffset = dstCopy->offset();
+ this->addTextureAccess(&fDstCopy);
+ }
+}
+
+void GrXferProcessor::getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const {
+ b->add32(fDstReadKey);
+ this->onGetGLProcessorKey(caps, b);
+}
+
+bool GrXferProcessor::hasDstCopy() const {
+ return (kDstCopyRead_DstReadKeyBit & fDstReadKey);
+}
+
+bool GrXferProcessor::dstCopyIsTopDown() const {
+ return (kTopLeftOrigin_DstReadKeyBit & fDstReadKey);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+GrXferProcessor* GrXPFactory::createXferProcessor(const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& coveragePOI,
+ const GrDeviceCoordTexture* dstCopy,
+ const GrDrawTargetCaps& caps) const {
+ int32_t dstReadKey;
+ if (this->willReadDst()) {
+ dstReadKey = kYesDstRead_DstReadKeyBit;
+ if (!caps.dstReadInShaderSupport()) {
+ SkASSERT(dstCopy->texture());
+ dstReadKey |= kDstCopyRead_DstReadKeyBit;
+ if (kTopLeft_GrSurfaceOrigin == dstCopy->texture()->origin()) {
+ dstReadKey |= kTopLeftOrigin_DstReadKeyBit;
+ }
+ }
+ } else {
+ dstReadKey = kNoDstRead_DstReadKey;
+
+ }
+ return this->onCreateXferProcessor(colorPOI, coveragePOI, dstCopy, dstReadKey);
+}
+
+bool GrXPFactory::willNeedDstCopy(const GrDrawTargetCaps& caps) const {
+ return (this->willReadDst() && !caps.dstReadInShaderSupport());
+}
+

Powered by Google App Engine
This is Rietveld 408576698