diff options
author | joshualitt <joshualitt@chromium.org> | 2014-12-03 06:24:10 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-03 06:24:10 -0800 |
commit | 2dd1ae016d7f297b433c3ea3a771ef8e01657c1f (patch) | |
tree | 96aa03d4b4b1802490cb5b769627b75f3de4a470 /src/gpu/GrContext.cpp | |
parent | 960fb50a1a7ac76fd51e22983812f26bfffa6d1e (diff) |
First step to moving vertex attributes to the geometryProcessor
BUG=skia:
Review URL: https://codereview.chromium.org/761563002
Diffstat (limited to 'src/gpu/GrContext.cpp')
-rwxr-xr-x | src/gpu/GrContext.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 852afe01ba..e947a16dd6 100755 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -313,13 +313,13 @@ GrTexture* GrContext::createResizedTexture(const GrSurfaceDesc& desc, GrTextureParams::kNone_FilterMode); drawState.addColorTextureProcessor(clampedTexture, SkMatrix::I(), params); - drawState.setGeometryProcessor( - GrDefaultGeoProcFactory::CreateAndSetAttribs( - &drawState, - GrDefaultGeoProcFactory::kPosition_GPType | - GrDefaultGeoProcFactory::kLocalCoord_GPType))->unref(); + uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType | + GrDefaultGeoProcFactory::kLocalCoord_GPType; + const GrGeometryProcessor* gp = GrDefaultGeoProcFactory::Create(flags); + drawState.setGeometryProcessor(gp)->unref(); - GrDrawTarget::AutoReleaseGeometry arg(fDrawBuffer, 4, drawState.getVertexStride(), 0); + GrDrawTarget::AutoReleaseGeometry arg(fDrawBuffer, 4, gp->getVertexStride(), 0); + SkASSERT(gp->getVertexStride() == 2 * sizeof(SkPoint)); if (arg.succeeded()) { SkPoint* verts = (SkPoint*) arg.vertices(); @@ -753,12 +753,13 @@ void GrContext::drawRect(const GrPaint& paint, // unitSquareVertexBuffer() static const int worstCaseVertCount = 10; - drawState.setDefaultVertexAttribs(); - drawState.setGeometryProcessor(GrDefaultGeoProcFactory::Create(false))->unref(); + const GrGeometryProcessor* gp = GrDefaultGeoProcFactory::Create(); + drawState.setGeometryProcessor(gp)->unref(); GrDrawTarget::AutoReleaseGeometry geo(target, worstCaseVertCount, - drawState.getVertexStride(), + gp->getVertexStride(), 0); + SkASSERT(gp->getVertexStride() == sizeof(SkPoint)); if (!geo.succeeded()) { SkDebugf("Failed to get space for vertices!\n"); @@ -828,8 +829,7 @@ static void set_vertex_attributes(GrDrawState* drawState, *colorOffset = sizeof(SkPoint); flags |= GrDefaultGeoProcFactory::kColor_GPType; } - drawState->setGeometryProcessor(GrDefaultGeoProcFactory::CreateAndSetAttribs(drawState, - flags))->unref(); + drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create(flags))->unref(); } void GrContext::drawVertices(const GrPaint& paint, @@ -854,7 +854,9 @@ void GrContext::drawVertices(const GrPaint& paint, int colorOffset = -1, texOffset = -1; set_vertex_attributes(&drawState, texCoords, colors, &colorOffset, &texOffset); - size_t vertexStride = drawState.getVertexStride(); + size_t vertexStride = drawState.getGeometryProcessor()->getVertexStride(); + SkASSERT(vertexStride == sizeof(SkPoint) + (SkToBool(texCoords) ? sizeof(SkPoint) : 0) + + (SkToBool(colors) ? sizeof(GrColor) : 0)); if (!geo.set(target, vertexCount, vertexStride, indexCount)) { SkDebugf("Failed to get space for vertices!\n"); return; @@ -1546,9 +1548,6 @@ GrDrawTarget* GrContext::prepareToDraw(GrDrawState* ds, SkDebugf("Partial pixel coverage will be incorrectly blended.\n"); } #endif - // Clear any vertex attributes configured for the previous use of the - // GrDrawState which can effect which blend optimizations are in effect. - ds->setDefaultVertexAttribs(); } else { ds->reset(fViewMatrix); ds->setRenderTarget(fRenderTarget.get()); |