Index: src/gpu/GrInOrderDrawBuffer.cpp |
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp |
index 493420db0b1d111448f078383cf249918f3b02c9..19d52be6f5663b28fb9207807c2a6f3233f14ade 100644 |
--- a/src/gpu/GrInOrderDrawBuffer.cpp |
+++ b/src/gpu/GrInOrderDrawBuffer.cpp |
@@ -62,14 +62,17 @@ void get_vertex_bounds(const void* vertices, |
The vertex attrib order is always pos, color, [local coords]. |
*/ |
-static void set_vertex_attributes(GrDrawState* drawState, bool hasLocalCoords, GrColor color) { |
+static const GrGeometryProcessor* set_vertex_attributes(GrDrawState* drawState, |
+ bool hasLocalCoords, |
+ GrColor color) { |
uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType | |
GrDefaultGeoProcFactory::kColor_GPType; |
flags |= hasLocalCoords ? GrDefaultGeoProcFactory::kLocalCoord_GPType : 0; |
- drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create(color, flags))->unref(); |
+ const GrGeometryProcessor* gp = GrDefaultGeoProcFactory::Create(color, flags); |
if (0xFF == GrColorUnpackA(color)) { |
drawState->setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true); |
} |
+ return gp; |
} |
static bool path_fill_type_is_winding(const GrStencilSettings& pathStencilSettings) { |
@@ -116,9 +119,10 @@ void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds, |
const SkMatrix* localMatrix) { |
GrDrawState::AutoRestoreEffects are(ds); |
- set_vertex_attributes(ds, SkToBool(localRect), color); |
+ SkAutoTUnref<const GrGeometryProcessor> gp(set_vertex_attributes(ds, SkToBool(localRect), |
+ color)); |
- size_t vstride = ds->getGeometryProcessor()->getVertexStride(); |
+ size_t vstride = gp->getVertexStride(); |
SkASSERT(vstride == sizeof(SkPoint) + sizeof(GrColor) + (SkToBool(localRect) ? sizeof(SkPoint) : |
0)); |
AutoReleaseGeometry geo(this, 4, vstride, 0); |
@@ -165,7 +169,7 @@ void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds, |
} |
this->setIndexSourceToBuffer(this->getContext()->getQuadIndexBuffer()); |
- this->drawIndexedInstances(ds, kTriangles_GrPrimitiveType, 1, 4, 6, &devBounds); |
+ this->drawIndexedInstances(ds, gp, kTriangles_GrPrimitiveType, 1, 4, 6, &devBounds); |
} |
int GrInOrderDrawBuffer::concatInstancedDraw(const GrDrawState& ds, const DrawInfo& info) { |
@@ -221,13 +225,13 @@ int GrInOrderDrawBuffer::concatInstancedDraw(const GrDrawState& ds, const DrawIn |
} |
void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds, |
+ const GrGeometryProcessor* gp, |
const DrawInfo& info, |
const ScissorState& scissorState, |
const GrDeviceCoordTexture* dstCopy) { |
SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); |
- const GrGeometryProcessor* gp = ds.getGeometryProcessor(); |
- if (!this->recordStateAndShouldDraw(ds, gp->getColor(), gp->getCoverage(), |
+ if (!this->recordStateAndShouldDraw(ds, gp, gp->getColor(), gp->getCoverage(), |
GrGpu::PrimTypeToDrawType(info.primitiveType()), |
scissorState, dstCopy)) { |
return; |
@@ -253,7 +257,7 @@ void GrInOrderDrawBuffer::onStencilPath(const GrDrawState& ds, |
const GrClipMaskManager::ScissorState& scissorState, |
const GrStencilSettings& stencilSettings) { |
// Only compare the subset of GrDrawState relevant to path stenciling? |
- if (!this->recordStateAndShouldDraw(ds, GrColor_WHITE, 0xff, GrGpu::kStencilPath_DrawType, |
+ if (!this->recordStateAndShouldDraw(ds, NULL, GrColor_WHITE, 0xff, GrGpu::kStencilPath_DrawType, |
scissorState, NULL)) { |
return; |
} |
@@ -269,8 +273,8 @@ void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds, |
const GrStencilSettings& stencilSettings, |
const GrDeviceCoordTexture* dstCopy) { |
// TODO: Only compare the subset of GrDrawState relevant to path covering? |
- if (!this->recordStateAndShouldDraw(ds, color, 0xff, GrGpu::kDrawPath_DrawType, scissorState, |
- dstCopy)) { |
+ if (!this->recordStateAndShouldDraw(ds, NULL, color, 0xff, GrGpu::kDrawPath_DrawType, |
+ scissorState, dstCopy)) { |
return; |
} |
DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); |
@@ -293,8 +297,8 @@ void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds, |
SkASSERT(indices); |
SkASSERT(transformValues); |
- if (!this->recordStateAndShouldDraw(ds, color, 0xff, GrGpu::kDrawPath_DrawType, scissorState, |
- dstCopy)) { |
+ if (!this->recordStateAndShouldDraw(ds, NULL, color, 0xff, GrGpu::kDrawPath_DrawType, |
+ scissorState, dstCopy)) { |
return; |
} |
@@ -324,7 +328,7 @@ void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds, |
transformType == previous->fTransformType && |
stencilSettings == previous->fStencilSettings && |
path_fill_type_is_winding(stencilSettings) && |
- !ds.willBlendWithDst(color, GrColor_WHITE)) { |
+ !ds.willBlendWithDst(NULL, color, GrColor_WHITE)) { |
// Fold this DrawPaths call into the one previous. |
previous->fCount += count; |
return; |
@@ -490,14 +494,15 @@ bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst, |
} |
bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds, |
+ const GrGeometryProcessor* gp, |
GrColor color, |
uint8_t coverage, |
GrGpu::DrawType drawType, |
const GrClipMaskManager::ScissorState& scissor, |
const GrDeviceCoordTexture* dstCopy) { |
SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, |
- (ds, color, coverage, *this->getGpu()->caps(), scissor, |
- dstCopy, drawType)); |
+ (ds, gp, color, coverage, *this->getGpu()->caps(), |
+ scissor, dstCopy, drawType)); |
if (ss->fState.mustSkip()) { |
fCmdBuffer.pop_back(); |
return false; |