typedef GrSurface INHERITED;
};
-/**
- * Represents a texture that is intended to be accessed in device coords with an offset.
- */
-class GrDeviceCoordTexture {
-public:
- GrDeviceCoordTexture() { fOffset.set(0, 0); }
-
- GrDeviceCoordTexture(const GrDeviceCoordTexture& other) {
- *this = other;
- }
-
- GrDeviceCoordTexture(GrTexture* texture, const SkIPoint& offset)
- : fTexture(SkSafeRef(texture))
- , fOffset(offset) {
- }
-
- GrDeviceCoordTexture& operator=(const GrDeviceCoordTexture& 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;
-};
-
#endif
*/
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.
* 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;
}
/**
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);
protected:
GrXferProcessor();
- GrXferProcessor(const GrDeviceCoordTexture* dstCopy, bool willReadDstColor);
+ GrXferProcessor(const DstTexture*, bool willReadDstColor);
private:
virtual OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI,
bool fWillReadDstColor;
bool fReadsCoverage;
- SkIPoint fDstCopyTextureOffset;
- GrTextureAccess fDstCopy;
+ SkIPoint fDstTextureOffset;
+ GrTextureAccess fDstTexture;
typedef GrFragmentProcessor INHERITED;
};
*/
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;
/**
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()) {
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.
GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
- const GrDeviceCoordTexture* dstCopy) const override;
+ const DstTexture*) const override;
bool willReadDstColor(const GrCaps& /*caps*/,
const GrProcOptInfo& /*colorPOI*/,
GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
- const GrDeviceCoordTexture* dstCopy) const override;
+ const DstTexture*) const override;
bool willReadDstColor(const GrCaps& caps,
const GrProcOptInfo& colorPOI,
class ArithmeticXP : public GrXferProcessor {
public:
static GrXferProcessor* Create(float k1, float k2, float k3, float k4, bool enforcePMColor,
- const GrDeviceCoordTexture* dstCopy,
- bool willReadDstColor) {
- return SkNEW_ARGS(ArithmeticXP, (k1, k2, k3, k4, enforcePMColor, dstCopy,
+ const DstTexture* dstTexture, bool willReadDstColor) {
+ return SkNEW_ARGS(ArithmeticXP, (k1, k2, k3, k4, enforcePMColor, dstTexture,
willReadDstColor));
}
private:
ArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor,
- const GrDeviceCoordTexture* dstCopy, bool willReadDstColor);
+ const DstTexture*, bool willReadDstColor);
GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
///////////////////////////////////////////////////////////////////////////////
ArithmeticXP::ArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor,
- const GrDeviceCoordTexture* dstCopy, bool willReadDstColor)
- : INHERITED(dstCopy, willReadDstColor)
+ const DstTexture* dstTexture, bool willReadDstColor)
+ : INHERITED(dstTexture, willReadDstColor)
, fK1(k1)
, fK2(k2)
, fK3(k3)
GrArithmeticXPFactory::onCreateXferProcessor(const GrCaps& caps,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
- const GrDeviceCoordTexture* dstCopy) const {
- return ArithmeticXP::Create(fK1, fK2, fK3, fK4, fEnforcePMColor, dstCopy,
+ const DstTexture* dstTexture) const {
+ return ArithmeticXP::Create(fK1, fK2, fK3, fK4, fEnforcePMColor, dstTexture,
this->willReadDstColor(caps, colorPOI, coveragePOI));
}
GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
- const GrDeviceCoordTexture* dstCopy) const override;
+ const DstTexture*) const override;
bool willReadDstColor(const GrCaps& caps,
const GrProcOptInfo& colorPOI,
bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuilder,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
- GrDeviceCoordTexture* dstCopy,
+ GrXferProcessor::DstTexture* dstTexture,
const SkRect* drawBounds) {
- if (!pipelineBuilder.willXPNeedDstCopy(*this->caps(), colorPOI, coveragePOI)) {
+ if (!pipelineBuilder.willXPNeedDstTexture(*this->caps(), colorPOI, coveragePOI)) {
return true;
}
if (GrTexture* rtTex = rt->asTexture()) {
// The render target is a texture, se we can read from it directly in the shader. The XP
// will be responsible to detect this situation and request a texture barrier.
- dstCopy->setTexture(rtTex);
- dstCopy->setOffset(0, 0);
+ dstTexture->setTexture(rtTex);
+ dstTexture->setOffset(0, 0);
return true;
}
}
}
SkIPoint dstPoint = {0, 0};
if (this->copySurface(copy, rt, copyRect, dstPoint)) {
- dstCopy->setTexture(copy);
- dstCopy->setOffset(copyRect.fLeft, copyRect.fTop);
+ dstTexture->setTexture(copy);
+ dstTexture->setOffset(copyRect.fLeft, copyRect.fTop);
return true;
} else {
return false;
pipelineInfo.fCoveragePOI,
*this->caps(),
*pipelineInfo.fScissor,
- &pipelineInfo.fDstCopy));
+ &pipelineInfo.fDstTexture));
}
///////////////////////////////////////////////////////////////////////////////
fColorPOI = fPipelineBuilder->colorProcInfo(primProc);
fCoveragePOI = fPipelineBuilder->coverageProcInfo(primProc);
if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoveragePOI,
- &fDstCopy, devBounds)) {
+ &fDstTexture, devBounds)) {
fPipelineBuilder = NULL;
}
}
fColorPOI = fPipelineBuilder->colorProcInfo(batch);
fCoveragePOI = fPipelineBuilder->coverageProcInfo(batch);
if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoveragePOI,
- &fDstCopy, devBounds)) {
+ &fDstTexture, devBounds)) {
fPipelineBuilder = NULL;
}
}
#include "GrPipelineBuilder.h"
#include "GrTraceMarker.h"
#include "GrVertexBuffer.h"
+#include "GrXferProcessor.h"
#include "SkClipStack.h"
#include "SkMatrix.h"
bool setupDstReadIfNecessary(const GrPipelineBuilder&,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
- GrDeviceCoordTexture* dstCopy,
+ GrXferProcessor::DstTexture*,
const SkRect* drawBounds);
struct PipelineInfo {
bool mustSkipDraw() const { return (NULL == fPipelineBuilder); }
- GrPipelineBuilder* fPipelineBuilder;
- GrScissorState* fScissor;
- GrProcOptInfo fColorPOI;
- GrProcOptInfo fCoveragePOI;
- GrDeviceCoordTexture fDstCopy;
+ GrPipelineBuilder* fPipelineBuilder;
+ GrScissorState* fScissor;
+ GrProcOptInfo fColorPOI;
+ GrProcOptInfo fCoveragePOI;
+ GrXferProcessor::DstTexture fDstTexture;
};
void setupPipeline(const PipelineInfo& pipelineInfo, GrPipeline* pipeline);
const GrProcOptInfo& coveragePOI,
const GrCaps& caps,
const GrScissorState& scissorState,
- const GrDeviceCoordTexture* dstCopy) {
+ const GrXferProcessor::DstTexture* dstTexture) {
// Create XferProcessor from DS's XPFactory
SkAutoTUnref<GrXferProcessor> xferProcessor(
- pipelineBuilder.getXPFactory()->createXferProcessor(colorPOI, coveragePOI, dstCopy, caps));
+ pipelineBuilder.getXPFactory()->createXferProcessor(
+ colorPOI, coveragePOI, dstTexture, caps));
GrColor overrideColor = GrColor_ILLEGAL;
if (colorPOI.firstEffectiveStageIndex() != 0) {
const GrProcOptInfo& coveragePOI,
const GrCaps&,
const GrScissorState&,
- const GrDeviceCoordTexture* dstCopy);
+ const GrXferProcessor::DstTexture*);
/*
* Returns true if these pipelines are equivalent.
//////////////////////////////////////////////////////////////////////////////s
-bool GrPipelineBuilder::willXPNeedDstCopy(const GrCaps& caps,
- const GrProcOptInfo& colorPOI,
- const GrProcOptInfo& coveragePOI) const {
- return this->getXPFactory()->willNeedDstCopy(caps, colorPOI, coveragePOI);
+bool GrPipelineBuilder::willXPNeedDstTexture(const GrCaps& caps,
+ const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& coveragePOI) const {
+ return this->getXPFactory()->willNeedDstTexture(caps, colorPOI, coveragePOI);
}
void GrPipelineBuilder::AutoRestoreFragmentProcessors::set(GrPipelineBuilder* pipelineBuilder) {
}
/**
- * Checks whether the xp will need a copy of the destination to correctly blend.
+ * Checks whether the xp will need destination in a texture to correctly blend.
*/
- bool willXPNeedDstCopy(const GrCaps& caps, const GrProcOptInfo& colorPOI,
- const GrProcOptInfo& coveragePOI) const;
+ bool willXPNeedDstTexture(const GrCaps& caps, const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& coveragePOI) const;
/// @}
#include "gl/GrGLCaps.h"
GrXferProcessor::GrXferProcessor()
- : fWillReadDstColor(false), fReadsCoverage(true), fDstCopyTextureOffset() {
+ : fWillReadDstColor(false), fReadsCoverage(true), fDstTextureOffset() {
}
-GrXferProcessor::GrXferProcessor(const GrDeviceCoordTexture* dstCopy, bool willReadDstColor)
+GrXferProcessor::GrXferProcessor(const DstTexture* dstTexture, bool willReadDstColor)
: fWillReadDstColor(willReadDstColor)
, fReadsCoverage(true)
- , fDstCopyTextureOffset() {
- if (dstCopy && dstCopy->texture()) {
- fDstCopy.reset(dstCopy->texture());
- fDstCopyTextureOffset = dstCopy->offset();
- this->addTextureAccess(&fDstCopy);
+ , fDstTextureOffset() {
+ if (dstTexture && dstTexture->texture()) {
+ fDstTexture.reset(dstTexture->texture());
+ fDstTextureOffset = dstTexture->offset();
+ this->addTextureAccess(&fDstTexture);
this->setWillReadFragmentPosition();
}
}
void GrXferProcessor::getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const {
uint32_t key = this->willReadDstColor() ? 0x1 : 0x0;
- if (this->getDstCopyTexture() &&
- kTopLeft_GrSurfaceOrigin == this->getDstCopyTexture()->origin()) {
+ if (this->getDstTexture() &&
+ kTopLeft_GrSurfaceOrigin == this->getDstTexture()->origin()) {
key |= 0x2;
}
b->add32(key);
bool GrXferProcessor::willNeedXferBarrier(const GrRenderTarget* rt,
const GrCaps& caps,
GrXferBarrierType* outBarrierType) const {
- if (static_cast<const GrSurface*>(rt) == this->getDstCopyTexture()) {
+ if (static_cast<const GrSurface*>(rt) == this->getDstTexture()) {
// Texture barriers are required when a shader reads and renders to the same texture.
SkASSERT(rt);
SkASSERT(caps.textureBarrierSupport());
GrXferProcessor* GrXPFactory::createXferProcessor(const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
- const GrDeviceCoordTexture* dstCopy,
+ const DstTexture* dstTexture,
const GrCaps& caps) const {
#ifdef SK_DEBUG
if (this->willReadDstColor(caps, colorPOI, coveragePOI)) {
if (!caps.shaderCaps()->dstReadInShaderSupport()) {
- SkASSERT(dstCopy && dstCopy->texture());
+ SkASSERT(dstTexture && dstTexture->texture());
} else {
- SkASSERT(!dstCopy || !dstCopy->texture());
+ SkASSERT(!dstTexture || !dstTexture->texture());
}
} else {
- SkASSERT(!dstCopy || !dstCopy->texture());
+ SkASSERT(!dstTexture || !dstTexture->texture());
}
#endif
- return this->onCreateXferProcessor(caps, colorPOI, coveragePOI, dstCopy);
+ return this->onCreateXferProcessor(caps, colorPOI, coveragePOI, dstTexture);
}
-bool GrXPFactory::willNeedDstCopy(const GrCaps& caps, const GrProcOptInfo& colorPOI,
- const GrProcOptInfo& coveragePOI) const {
+bool GrXPFactory::willNeedDstTexture(const GrCaps& caps, const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& coveragePOI) const {
return (this->willReadDstColor(caps, colorPOI, coveragePOI)
&& !caps.shaderCaps()->dstReadInShaderSupport());
}
-
GrCoverageSetOpXPFactory::onCreateXferProcessor(const GrCaps& caps,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& covPOI,
- const GrDeviceCoordTexture* dstCopy) const {
+ const DstTexture* dst) const {
+ SkASSERT(!dst);
return CoverageSetOpXP::Create(fRegionOp, fInvertCoverage);
}
class CustomXP : public GrXferProcessor {
public:
- static GrXferProcessor* Create(SkXfermode::Mode mode, const GrDeviceCoordTexture* dstCopy,
+ static GrXferProcessor* Create(SkXfermode::Mode mode, const DstTexture* dstTexture,
bool willReadDstColor) {
if (!GrCustomXfermode::IsSupportedMode(mode)) {
return NULL;
} else {
- return SkNEW_ARGS(CustomXP, (mode, dstCopy, willReadDstColor));
+ return SkNEW_ARGS(CustomXP, (mode, dstTexture, willReadDstColor));
}
}
}
private:
- CustomXP(SkXfermode::Mode mode, const GrDeviceCoordTexture* dstCopy, bool willReadDstColor);
+ CustomXP(SkXfermode::Mode mode, const DstTexture*, bool willReadDstColor);
GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
///////////////////////////////////////////////////////////////////////////////
-CustomXP::CustomXP(SkXfermode::Mode mode, const GrDeviceCoordTexture* dstCopy,
- bool willReadDstColor)
- : INHERITED(dstCopy, willReadDstColor),
+CustomXP::CustomXP(SkXfermode::Mode mode, const DstTexture* dstTexture, bool willReadDstColor)
+ : INHERITED(dstTexture, willReadDstColor),
fMode(mode),
fHWBlendEquation(static_cast<GrBlendEquation>(-1)) {
this->initClassID<CustomXP>();
GrCustomXPFactory::onCreateXferProcessor(const GrCaps& caps,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
- const GrDeviceCoordTexture* dstCopy) const {
- return CustomXP::Create(fMode, dstCopy, this->willReadDstColor(caps, colorPOI, coveragePOI));
+ const DstTexture* dstTexture) const {
+ return CustomXP::Create(fMode, dstTexture, this->willReadDstColor(caps, colorPOI, coveragePOI));
}
bool GrCustomXPFactory::willReadDstColor(const GrCaps& caps,
GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
- const GrDeviceCoordTexture* dstCopy) const override;
+ const DstTexture*) const override;
bool willReadDstColor(const GrCaps& caps,
const GrProcOptInfo& colorPOI,
GrDisableColorXPFactory::onCreateXferProcessor(const GrCaps& caps,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& covPOI,
- const GrDeviceCoordTexture* dstCopy) const {
+ const DstTexture* dst) const {
+ SkASSERT(!dst);
return DisableColorXP::Create();
}
GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
- const GrDeviceCoordTexture* dstCopy) const override;
+ const DstTexture* dstTexture) const override;
bool willReadDstColor(const GrCaps& caps,
const GrProcOptInfo& colorPOI,
class PorterDuffXferProcessor : public GrXferProcessor {
public:
- static GrXferProcessor* Create(SkXfermode::Mode xfermode, const GrDeviceCoordTexture* dstCopy,
+ static GrXferProcessor* Create(SkXfermode::Mode xfermode, const DstTexture* dstTexture,
bool willReadDstColor) {
- return SkNEW_ARGS(PorterDuffXferProcessor, (xfermode, dstCopy, willReadDstColor));
+ return SkNEW_ARGS(PorterDuffXferProcessor, (xfermode, dstTexture, willReadDstColor));
}
~PorterDuffXferProcessor() override;
BlendFormula getBlendFormula() const { return fBlendFormula; }
private:
- PorterDuffXferProcessor(SkXfermode::Mode, const GrDeviceCoordTexture* dstCopy,
- bool willReadDstColor);
+ PorterDuffXferProcessor(SkXfermode::Mode, const DstTexture*, bool willReadDstColor);
GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
///////////////////////////////////////////////////////////////////////////////
PorterDuffXferProcessor::PorterDuffXferProcessor(SkXfermode::Mode xfermode,
- const GrDeviceCoordTexture* dstCopy,
+ const DstTexture* dstTexture,
bool willReadDstColor)
- : INHERITED(dstCopy, willReadDstColor)
+ : INHERITED(dstTexture, willReadDstColor)
, fXfermode(xfermode)
, fBlendFormula(get_unoptimized_blend_formula(xfermode)) {
this->initClassID<PorterDuffXferProcessor>();
GrPorterDuffXPFactory::onCreateXferProcessor(const GrCaps& caps,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& covPOI,
- const GrDeviceCoordTexture* dstCopy) const {
+ const DstTexture* dstTexture) const {
if (covPOI.isFourChannelOutput()) {
return PDLCDXferProcessor::Create(fXfermode, colorPOI);
} else {
- return PorterDuffXferProcessor::Create(fXfermode, dstCopy,
+ return PorterDuffXferProcessor::Create(fXfermode, dstTexture,
this->willReadDstColor(caps, colorPOI, covPOI));
}
}
GrGLInstalledFragProcs* fragmentProcessors)
: fColor(GrColor_ILLEGAL)
, fCoverage(0)
- , fDstCopyTexUnit(-1)
+ , fDstTextureUnit(-1)
, fBuiltinUniformHandles(builtinUniforms)
, fProgramID(programID)
, fGeometryProcessor(geometryProcessor)
RenderTargetState fRenderTargetState;
GrColor fColor;
uint8_t fCoverage;
- int fDstCopyTexUnit;
+ int fDstTextureUnit;
BuiltinUniformHandles fBuiltinUniformHandles;
GrGLuint fProgramID;
* this optstate.
* @param GrGLGpu A GL Gpu, the caps and Gpu object are used to output processor specific
* parts of the descriptor.
- * @param GrDeviceCoordTexture A dstCopy texture, which may be null if frame buffer fetch is
- * supported
* @param GrProgramDesc The built and finalized descriptor
**/
static bool Build(GrProgramDesc*,
#include "gl/builders/GrGLProgramBuilder.h"
void GrGLXferProcessor::emitCode(const EmitArgs& args) {
- if (args.fXP.getDstCopyTexture()) {
- bool topDown = kTopLeft_GrSurfaceOrigin == args.fXP.getDstCopyTexture()->origin();
+ if (args.fXP.getDstTexture()) {
+ bool topDown = kTopLeft_GrSurfaceOrigin == args.fXP.getDstTexture()->origin();
GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
const char* dstColor = fsBuilder->dstColor();
- const char* dstCopyTopLeftName;
- const char* dstCopyCoordScaleName;
+ const char* dstTopLeftName;
+ const char* dstCoordScaleName;
- fDstCopyTopLeftUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
- kVec2f_GrSLType,
- kDefault_GrSLPrecision,
- "DstCopyUpperLeft",
- &dstCopyTopLeftName);
- fDstCopyScaleUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
- kVec2f_GrSLType,
- kDefault_GrSLPrecision,
- "DstCopyCoordScale",
- &dstCopyCoordScaleName);
+ fDstTopLeftUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+ kVec2f_GrSLType,
+ kDefault_GrSLPrecision,
+ "DstTextureUpperLeft",
+ &dstTopLeftName);
+ fDstScaleUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+ kVec2f_GrSLType,
+ kDefault_GrSLPrecision,
+ "DstTextureCoordScale",
+ &dstCoordScaleName);
const char* fragPos = fsBuilder->fragmentPosition();
fsBuilder->codeAppend("// Read color from copy of the destination.\n");
fsBuilder->codeAppendf("vec2 _dstTexCoord = (%s.xy - %s) * %s;",
- fragPos, dstCopyTopLeftName, dstCopyCoordScaleName);
+ fragPos, dstTopLeftName, dstCoordScaleName);
if (!topDown) {
fsBuilder->codeAppend("_dstTexCoord.y = 1.0 - _dstTexCoord.y;");
}
void GrGLXferProcessor::setData(const GrGLProgramDataManager& pdm, const GrXferProcessor& xp) {
- if (xp.getDstCopyTexture()) {
- if (fDstCopyTopLeftUni.isValid()) {
- pdm.set2f(fDstCopyTopLeftUni, static_cast<GrGLfloat>(xp.dstCopyTextureOffset().fX),
- static_cast<GrGLfloat>(xp.dstCopyTextureOffset().fY));
- pdm.set2f(fDstCopyScaleUni, 1.f / xp.getDstCopyTexture()->width(),
- 1.f / xp.getDstCopyTexture()->height());
+ if (xp.getDstTexture()) {
+ if (fDstTopLeftUni.isValid()) {
+ pdm.set2f(fDstTopLeftUni, static_cast<GrGLfloat>(xp.dstTextureOffset().fX),
+ static_cast<GrGLfloat>(xp.dstTextureOffset().fY));
+ pdm.set2f(fDstScaleUni, 1.f / xp.getDstTexture()->width(),
+ 1.f / xp.getDstTexture()->height());
} else {
- SkASSERT(!fDstCopyScaleUni.isValid());
+ SkASSERT(!fDstScaleUni.isValid());
}
} else {
- SkASSERT(!fDstCopyTopLeftUni.isValid());
- SkASSERT(!fDstCopyScaleUni.isValid());
+ SkASSERT(!fDstTopLeftUni.isValid());
+ SkASSERT(!fDstScaleUni.isValid());
}
this->onSetData(pdm, xp);
}
virtual void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) = 0;
- GrGLProgramDataManager::UniformHandle fDstCopyTopLeftUni;
- GrGLProgramDataManager::UniformHandle fDstCopyScaleUni;
+ GrGLProgramDataManager::UniformHandle fDstTopLeftUni;
+ GrGLProgramDataManager::UniformHandle fDstScaleUni;
typedef GrGLProcessor INHERITED;
};
#define GL_CALL(X) GR_GL_CALL(fProgramBuilder->gpu()->glInterface(), X)
#define GL_CALL_RET(R, X) GR_GL_CALL_RET(fProgramBuilder->gpu()->glInterface(), R, X)
-const char* GrGLFragmentShaderBuilder::kDstCopyColorName = "_dstColor";
+const char* GrGLFragmentShaderBuilder::kDstTextureColorName = "_dstColor";
static const char* declared_color_output_name() { return "fsColorOut"; }
static const char* dual_source_output_name() { return "dualSourceOut"; }
static void append_default_precision_qualifier(GrSLPrecision p,
}
GrGLFragmentShaderBuilder::DstReadKey
-GrGLFragmentShaderBuilder::KeyForDstRead(const GrTexture* dstCopy, const GrGLCaps& caps) {
+GrGLFragmentShaderBuilder::KeyForDstRead(const GrTexture* dstTexture, const GrGLCaps& caps) {
uint32_t key = kYesDstRead_DstReadKeyBit;
if (caps.glslCaps()->fbFetchSupport()) {
return key;
}
- SkASSERT(dstCopy);
- if (!caps.textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(dstCopy->config())) {
+ SkASSERT(dstTexture);
+ if (!caps.textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(dstTexture->config())) {
// The fact that the config is alpha-only must be considered when generating code.
key |= kUseAlphaConfig_DstReadKeyBit;
}
- if (kTopLeft_GrSurfaceOrigin == dstCopy->origin()) {
+ if (kTopLeft_GrSurfaceOrigin == dstTexture->origin()) {
key |= kTopLeftOrigin_DstReadKeyBit;
}
SkASSERT(static_cast<DstReadKey>(key) == key);
}
return fbFetchColorName;
} else {
- return kDstCopyColorName;
+ return kDstTextureColorName;
}
}
typedef uint8_t DstReadKey;
typedef uint8_t FragPosKey;
- /** Returns a key for adding code to read the copy-of-dst color in service of effects that
+ /** Returns a key for adding code to read the dst texture color in service of effects that
require reading the dst. It must not return 0 because 0 indicates that there is no dst
- copy read at all (in which case this function should not be called). */
- static DstReadKey KeyForDstRead(const GrTexture* dstCopy, const GrGLCaps&);
+ texture at all (in which case this function should not be called). */
+ static DstReadKey KeyForDstRead(const GrTexture* dsttexture, const GrGLCaps&);
/** Returns a key for reading the fragment location. This should only be called if there is an
effect that will requires the fragment position. If the fragment position is not required,
kBottomLeftFragPosRead_FragPosKey = 0x2,// Read frag pos relative to bottom-left.
};
- static const char* kDstCopyColorName;
+ static const char* kDstTextureColorName;
bool fHasCustomColorOutput;
bool fHasSecondaryOutput;
const GrProcOptInfo& colorPOI, const GrProcOptInfo& covPOI) {
SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode));
SkAutoTUnref<GrXferProcessor> xp(xpf->createXferProcessor(colorPOI, covPOI, 0, caps));
- TEST_ASSERT(!xpf->willNeedDstCopy(caps, colorPOI, covPOI));
+ TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI));
xpf->getInvariantOutput(colorPOI, covPOI, &fInvariantOutput);
fOptFlags = xp->getOptimizations(colorPOI, covPOI, false, 0, caps);
GetXPOutputTypes(xp, &fPrimaryOutputType, &fSecondaryOutputType);
SkASSERT(covPOI.isFourChannelOutput());
SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(SkXfermode::kSrcOver_Mode));
- TEST_ASSERT(!xpf->willNeedDstCopy(caps, colorPOI, covPOI));
+ TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI));
GrXPFactory::InvariantOutput invariantOutput;
xpf->getInvariantOutput(colorPOI, covPOI, &invariantOutput);