aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrInOrderDrawBuffer.cpp
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-12-10 13:48:57 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-10 13:48:57 -0800
commitc6bc58eded89b0c0a36b8e20e193c200f297a0da (patch)
tree3de559baf8eecee6f6576c9b6deee39fb8258775 /src/gpu/GrInOrderDrawBuffer.cpp
parent04b49c31789201fbef969f5598a286187920dd56 (diff)
Remove GP from drawstate, revision of invariant output for GP
Diffstat (limited to 'src/gpu/GrInOrderDrawBuffer.cpp')
-rw-r--r--src/gpu/GrInOrderDrawBuffer.cpp39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 493420db0b..0b5c96889b 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* create_rect_gp(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(create_rect_gp(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, NULL,
GrGpu::PrimTypeToDrawType(info.primitiveType()),
scissorState, dstCopy)) {
return;
@@ -249,11 +253,12 @@ void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds,
}
void GrInOrderDrawBuffer::onStencilPath(const GrDrawState& ds,
+ const GrPathProcessor* pathProc,
const GrPath* path,
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, pathProc, GrGpu::kStencilPath_DrawType,
scissorState, NULL)) {
return;
}
@@ -263,14 +268,14 @@ void GrInOrderDrawBuffer::onStencilPath(const GrDrawState& ds,
}
void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds,
- GrColor color,
+ const GrPathProcessor* pathProc,
const GrPath* path,
const GrClipMaskManager::ScissorState& scissorState,
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, pathProc, GrGpu::kDrawPath_DrawType,
+ scissorState, dstCopy)) {
return;
}
DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path));
@@ -279,7 +284,7 @@ void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds,
}
void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds,
- GrColor color,
+ const GrPathProcessor* pathProc,
const GrPathRange* pathRange,
const void* indices,
PathIndexType indexType,
@@ -293,7 +298,7 @@ void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds,
SkASSERT(indices);
SkASSERT(transformValues);
- if (!this->recordStateAndShouldDraw(ds, color, 0xff, GrGpu::kDrawPath_DrawType, scissorState,
+ if (!this->recordStateAndShouldDraw(ds, NULL, pathProc, GrGpu::kDrawPath_DrawType, scissorState,
dstCopy)) {
return;
}
@@ -324,7 +329,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(pathProc)) {
// Fold this DrawPaths call into the one previous.
previous->fCount += count;
return;
@@ -490,13 +495,13 @@ bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst,
}
bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds,
- GrColor color,
- uint8_t coverage,
+ const GrGeometryProcessor* gp,
+ const GrPathProcessor* pathProc,
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,
+ (ds, gp, pathProc, *this->getGpu()->caps(), scissor,
dstCopy, drawType));
if (ss->fState.mustSkip()) {
fCmdBuffer.pop_back();