fDevBounds = NULL;
}
- fDstCopy = di.fDstCopy;
-
this->setVertexBuffer(di.vertexBuffer());
this->setIndexBuffer(di.indexBuffer());
if (devBounds) {
info.setDevBounds(*devBounds);
}
+
// TODO: We should continue with incorrect blending.
- if (!this->setupDstReadIfNecessary(ds, &info)) {
+ GrDeviceCoordTexture dstCopy;
+ if (!this->setupDstReadIfNecessary(ds, &dstCopy, devBounds)) {
return;
}
-
this->setDrawBuffers(&info);
- this->onDraw(*ds, info, scissorState);
+ this->onDraw(*ds, info, scissorState, dstCopy.texture() ? &dstCopy : NULL);
}
}
}
// TODO: We should continue with incorrect blending.
- if (!this->setupDstReadIfNecessary(ds, &info)) {
+ GrDeviceCoordTexture dstCopy;
+ if (!this->setupDstReadIfNecessary(ds, &dstCopy, devBounds)) {
return;
}
this->setDrawBuffers(&info);
- this->onDraw(*ds, info, scissorState);
+ this->onDraw(*ds, info, scissorState, dstCopy.texture() ? &dstCopy : NULL);
}
}
if (devBounds) {
info.setDevBounds(*devBounds);
}
+
// TODO: We should continue with incorrect blending.
- if (!this->setupDstReadIfNecessary(ds, &info)) {
+ GrDeviceCoordTexture dstCopy;
+ if (!this->setupDstReadIfNecessary(ds, &dstCopy, devBounds)) {
return;
}
info.fStartIndex,
info.fVertexCount,
info.fIndexCount)) {
- this->onDraw(*ds, info, scissorState);
+ this->onDraw(*ds, info, scissorState, dstCopy.texture() ? &dstCopy : NULL);
}
info.fStartVertex += info.fVertexCount;
instanceCount -= info.fInstanceCount;
}
const SkRect* getDevBounds() const { return fDevBounds; }
- // NULL if no copy of the dst is needed for the draw.
- const GrDeviceCoordTexture* getDstCopy() const {
- if (fDstCopy.texture()) {
- return &fDstCopy;
- } else {
- return NULL;
- }
- }
-
private:
DrawInfo() { fDevBounds = NULL; }
GrPendingIOResource<const GrVertexBuffer, kRead_GrIOType> fVertexBuffer;
GrPendingIOResource<const GrIndexBuffer, kRead_GrIOType> fIndexBuffer;
-
- GrDeviceCoordTexture fDstCopy;
};
virtual void setDrawBuffers(DrawInfo*) = 0;;
// Makes a copy of the dst if it is necessary for the draw. Returns false if a copy is required
// but couldn't be made. Otherwise, returns true. This method needs to be protected because it
// needs to be accessed by GLPrograms to setup a correct drawstate
- bool setupDstReadIfNecessary(GrDrawState* ds, DrawInfo* info) {
- return this->setupDstReadIfNecessary(ds, &info->fDstCopy, info->getDevBounds());
- }
bool setupDstReadIfNecessary(GrDrawState*,
GrDeviceCoordTexture* dstCopy,
const SkRect* drawBounds);
// subclass called to perform drawing
virtual void onDraw(const GrDrawState&,
const DrawInfo&,
- const GrClipMaskManager::ScissorState&) = 0;
+ const GrClipMaskManager::ScissorState&,
+ const GrDeviceCoordTexture* dstCopy) = 0;
// TODO copy in order drawbuffer onDrawRect to here
virtual void onDrawRect(GrDrawState*,
const SkRect& rect,
void GrGpu::draw(const GrOptDrawState& ds, const GrDrawTarget::DrawInfo& info) {
this->handleDirtyContext();
- if (!this->flushGraphicsState(ds,
- PrimTypeToDrawType(info.primitiveType()),
- info.getDstCopy())) {
+ if (!this->flushGraphicsState(ds, PrimTypeToDrawType(info.primitiveType()))) {
return;
}
this->onDraw(ds, info);
const GrStencilSettings& stencilSettings) {
this->handleDirtyContext();
- if (!this->flushGraphicsState(ds, kStencilPath_DrawType, NULL)) {
+ if (!this->flushGraphicsState(ds, kStencilPath_DrawType)) {
return;
}
void GrGpu::drawPath(const GrOptDrawState& ds,
const GrPath* path,
- const GrStencilSettings& stencilSettings,
- const GrDeviceCoordTexture* dstCopy) {
+ const GrStencilSettings& stencilSettings) {
this->handleDirtyContext();
- if (!this->flushGraphicsState(ds, kDrawPath_DrawType, dstCopy)) {
+ if (!this->flushGraphicsState(ds, kDrawPath_DrawType)) {
return;
}
int count,
const float transforms[],
GrDrawTarget::PathTransformType transformsType,
- const GrStencilSettings& stencilSettings,
- const GrDeviceCoordTexture* dstCopy) {
+ const GrStencilSettings& stencilSettings) {
this->handleDirtyContext();
- if (!this->flushGraphicsState(ds, kDrawPaths_DrawType, dstCopy)) {
+ if (!this->flushGraphicsState(ds, kDrawPaths_DrawType)) {
return;
}
virtual void buildProgramDesc(const GrOptDrawState&,
const GrProgramDesc::DescInfo&,
GrGpu::DrawType,
- const GrDeviceCoordTexture* dstCopy,
GrProgramDesc*) = 0;
/**
const GrStencilSettings&);
virtual void drawPath(const GrOptDrawState&,
const GrPath*,
- const GrStencilSettings&,
- const GrDeviceCoordTexture* dstCopy);
+ const GrStencilSettings&);
virtual void drawPaths(const GrOptDrawState&,
const GrPathRange*,
const uint32_t indices[],
int count,
const float transforms[],
GrDrawTarget::PathTransformType,
- const GrStencilSettings&,
- const GrDeviceCoordTexture*);
+ const GrStencilSettings&);
static DrawType PrimTypeToDrawType(GrPrimitiveType type) {
switch (type) {
// deltas from previous state at draw time. This function does the
// backend-specific flush of the state.
// returns false if current state is unsupported.
- virtual bool flushGraphicsState(const GrOptDrawState&,
- DrawType,
- const GrDeviceCoordTexture* dstCopy) = 0;
+ virtual bool flushGraphicsState(const GrOptDrawState&, DrawType) = 0;
// clears target's entire stencil buffer to 0
virtual void clearStencil(GrRenderTarget* target) = 0;
void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds,
const DrawInfo& info,
- const ScissorState& scissorState) {
+ const ScissorState& scissorState,
+ const GrDeviceCoordTexture* dstCopy) {
SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer()));
GeometryPoolState& poolState = fGeoPoolStateStack.back();
if (!this->recordStateAndShouldDraw(ds, GrGpu::PrimTypeToDrawType(info.primitiveType()),
- scissorState, info.getDstCopy())) {
+ scissorState, dstCopy)) {
return;
}
return;
}
DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path));
- if (dstCopy) {
- dp->fDstCopy = *dstCopy;
- }
dp->fStencilSettings = stencilSettings;
this->recordTraceMarkersIfNecessary();
}
dp->fTransformsLocation = savedTransforms - fPathTransformBuffer.begin();
dp->fTransformsType = transformsType;
dp->fStencilSettings = stencilSettings;
- if (dstCopy) {
- dp->fDstCopy = *dstCopy;
- }
this->recordTraceMarkersIfNecessary();
}
void GrInOrderDrawBuffer::DrawPath::execute(GrInOrderDrawBuffer* buf,
const GrOptDrawState* optState) {
- buf->fDstGpu->drawPath(*optState, this->path(), fStencilSettings,
- fDstCopy.texture() ? &fDstCopy : NULL);
+ buf->fDstGpu->drawPath(*optState, this->path(), fStencilSettings);
}
void GrInOrderDrawBuffer::DrawPaths::execute(GrInOrderDrawBuffer* buf,
buf->fDstGpu->drawPaths(*optState, this->pathRange(),
&buf->fPathIndexBuffer[fIndicesLocation], fCount,
&buf->fPathTransformBuffer[fTransformsLocation], fTransformsType,
- fStencilSettings, fDstCopy.texture() ? &fDstCopy : NULL);
+ fStencilSettings);
}
void GrInOrderDrawBuffer::SetState::execute(GrInOrderDrawBuffer*, const GrOptDrawState*) {
if (!fLastState || *optState != *fLastState) {
SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, (optState));
fLastState.reset(SkRef(optState.get()));
- if (dstCopy) {
- ss->fDstCopy = *dstCopy;
- }
ss->fDrawType = drawType;
this->recordTraceMarkersIfNecessary();
}
virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*);
- GrDeviceCoordTexture fDstCopy;
GrStencilSettings fStencilSettings;
private:
size_t fCount;
int fTransformsLocation;
PathTransformType fTransformsType;
- GrDeviceCoordTexture fDstCopy;
GrStencilSettings fStencilSettings;
private:
SkAutoTUnref<const GrOptDrawState> fState;
GrGpu::DrawType fDrawType;
- GrDeviceCoordTexture fDstCopy;
};
typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double.
// overrides from GrDrawTarget
void onDraw(const GrDrawState&,
const DrawInfo&,
- const ScissorState&) SK_OVERRIDE;
+ const ScissorState&,
+ const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE;
void onDrawRect(GrDrawState*,
const SkRect& rect,
const SkRect* localRect,
fDrawFace = drawState.getDrawFace();
fSrcBlend = optSrcCoeff;
fDstBlend = optDstCoeff;
+
+ // TODO move this out of optDrawState
+ if (dstCopy) {
+ fDstCopy = *dstCopy;
+ }
+
GrProgramDesc::DescInfo descInfo;
fFlags = 0;
this->setOutputStateInfo(drawState, blendOpt, *gpu->caps(), &descInfo);
// now create a key
- gpu->buildProgramDesc(*this, descInfo, drawType, dstCopy, &fDesc);
+ gpu->buildProgramDesc(*this, descInfo, drawType, &fDesc);
};
GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState,
this->fVAStride != that.fVAStride ||
memcmp(this->fVAPtr, that.fVAPtr, this->fVACount * sizeof(GrVertexAttrib)) ||
this->fStencilSettings != that.fStencilSettings ||
- this->fDrawFace != that.fDrawFace) {
+ this->fDrawFace != that.fDrawFace ||
+ this->fDstCopy.texture() != that.fDstCopy.texture()) {
return false;
}
///////////////////////////////////////////////////////////////////////////
+ const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ? &fDstCopy : NULL; }
const GrProgramDesc& programDesc() const { return fDesc; }
GrStencilSettings fStencilSettings;
uint8_t fCoverage;
GrDrawState::DrawFace fDrawFace;
+ GrDeviceCoordTexture fDstCopy;
GrBlendCoeff fSrcBlend;
GrBlendCoeff fDstBlend;
uint32_t fFlags;
virtual void buildProgramDesc(const GrOptDrawState&,
const GrProgramDesc::DescInfo&,
GrGpu::DrawType,
- const GrDeviceCoordTexture* dstCopy,
GrProgramDesc* desc) SK_OVERRIDE { }
virtual void discard(GrRenderTarget*) SK_OVERRIDE { }
return false;
}
- virtual bool flushGraphicsState(const GrOptDrawState&,
- DrawType,
- const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE {
+ virtual bool flushGraphicsState(const GrOptDrawState&, DrawType) SK_OVERRIDE {
return false;
}
///////////////////////////////////////////////////////////////////////////////
-void GrGLProgram::setData(const GrOptDrawState& optState,
- GrGpu::DrawType drawType,
- const GrDeviceCoordTexture* dstCopy) {
+void GrGLProgram::setData(const GrOptDrawState& optState, GrGpu::DrawType drawType) {
GrColor color = optState.getColor();
uint8_t coverage = optState.getCoverage();
this->setCoverage(optState, coverage);
this->setMatrixAndRenderTargetHeight(drawType, optState);
+ const GrDeviceCoordTexture* dstCopy = optState.getDstCopy();
if (dstCopy) {
if (fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()) {
fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyTopLeftUni,
* GrGpuGL object to bind the textures required by the GrGLProcessors. The color and coverage
* stages come from GrGLProgramDesc::Build().
*/
- void setData(const GrOptDrawState&,
- GrGpu::DrawType,
- const GrDeviceCoordTexture* dstCopy /* can be NULL*/);
+ void setData(const GrOptDrawState&, GrGpu::DrawType);
protected:
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
const GrProgramDesc::DescInfo& descInfo,
GrGpu::DrawType drawType,
GrGpuGL* gpu,
- const GrDeviceCoordTexture* dstCopy,
GrProgramDesc* desc) {
bool inputColorIsUsed = descInfo.fInputColorIsUsed;
bool inputCoverageIsUsed = descInfo.fInputCoverageIsUsed;
}
if (descInfo.fReadsDst) {
+ const GrDeviceCoordTexture* dstCopy = optState.getDstCopy();
SkASSERT(dstCopy || gpu->caps()->dstReadInShaderSupport());
const GrTexture* dstCopyTexture = NULL;
if (dstCopy) {
const GrProgramDesc::DescInfo&,
GrGpu::DrawType,
GrGpuGL*,
- const GrDeviceCoordTexture*,
GrProgramDesc*);
static const GLKeyHeader& GetHeader(const GrProgramDesc& desc) {
virtual void buildProgramDesc(const GrOptDrawState&,
const GrProgramDesc::DescInfo&,
GrGpu::DrawType,
- const GrDeviceCoordTexture* dstCopy,
GrProgramDesc*) SK_OVERRIDE;
private:
virtual void clearStencil(GrRenderTarget*) SK_OVERRIDE;
- virtual bool flushGraphicsState(const GrOptDrawState&,
- DrawType,
- const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE;
+ virtual bool flushGraphicsState(const GrOptDrawState&, DrawType) SK_OVERRIDE;
// GrDrawTarget overrides
virtual void didAddGpuTraceMarker() SK_OVERRIDE;
#define GL_CALL(X) GR_GL_CALL(this->glInterface(), X)
-bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState,
- DrawType type,
- const GrDeviceCoordTexture* dstCopy) {
+bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState, DrawType type) {
// GrGpu::setupClipAndFlushState should have already checked this and bailed if not true.
SkASSERT(optState.getRenderTarget());
this->flushBlend(optState, kDrawLines_DrawType == type, srcCoeff, dstCoeff);
- fCurrentProgram->setData(optState, type, dstCopy);
+ fCurrentProgram->setData(optState, type);
}
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState.getRenderTarget());
void GrGpuGL::buildProgramDesc(const GrOptDrawState& optState,
const GrProgramDesc::DescInfo& descInfo,
GrGpu::DrawType drawType,
- const GrDeviceCoordTexture* dstCopy,
GrProgramDesc* desc) {
- if (!GrGLProgramDescBuilder::Build(optState, descInfo, drawType, this, dstCopy, desc)) {
+ if (!GrGLProgramDescBuilder::Build(optState, descInfo, drawType, this, desc)) {
SkDEBUGFAIL("Failed to generate GL program descriptor");
}
}