Chromium Code Reviews| Index: src/gpu/GrXferProcessor.cpp |
| diff --git a/src/gpu/GrXferProcessor.cpp b/src/gpu/GrXferProcessor.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a005417f209b67f9bc5f5062fd14861be7b75b76 |
| --- /dev/null |
| +++ b/src/gpu/GrXferProcessor.cpp |
| @@ -0,0 +1,54 @@ |
| +/* |
| + * 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); |
|
bsalomon
2015/02/03 17:28:24
Assert that fDstCopy has kTopLeft origin?
egdaniel
2015/02/03 19:50:57
Done.
|
| + } |
| +} |
| + |
| +void GrXferProcessor::getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const { |
| + uint32_t key = this->willReadDstColor() ? 0x1 : 0x0; |
| + 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()); |
| +} |
| + |