Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Unified Diff: src/gpu/GrContext.cpp

Issue 791743003: Remove GP from drawstate, revision of invariant output for GP (Closed) Base URL: https://skia.googlesource.com/skia.git@color-to-gp
Patch Set: more windows fix Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrBitmapTextContext.cpp ('k') | src/gpu/GrDefaultGeoProcFactory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrContext.cpp
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 9d07fdfd9cdfedbbbda23996402c97c2dadacc55..bfbce359a4be87726837a21c495a768b41ef2b6c 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -315,8 +315,8 @@ GrTexture* GrContext::createResizedTexture(const GrSurfaceDesc& desc,
uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType |
GrDefaultGeoProcFactory::kLocalCoord_GPType;
- const GrGeometryProcessor* gp = GrDefaultGeoProcFactory::Create(GrColor_WHITE, flags);
- drawState.setGeometryProcessor(gp)->unref();
+ SkAutoTUnref<const GrGeometryProcessor> gp(
+ GrDefaultGeoProcFactory::Create(GrColor_WHITE, flags));
GrDrawTarget::AutoReleaseGeometry arg(fDrawBuffer, 4, gp->getVertexStride(), 0);
SkASSERT(gp->getVertexStride() == 2 * sizeof(SkPoint));
@@ -325,7 +325,7 @@ GrTexture* GrContext::createResizedTexture(const GrSurfaceDesc& desc,
SkPoint* verts = (SkPoint*) arg.vertices();
verts[0].setIRectFan(0, 0, texture->width(), texture->height(), 2 * sizeof(SkPoint));
verts[1].setIRectFan(0, 0, 1, 1, 2 * sizeof(SkPoint));
- fDrawBuffer->drawNonIndexed(&drawState, kTriangleFan_GrPrimitiveType, 0, 4);
+ fDrawBuffer->drawNonIndexed(&drawState, gp, kTriangleFan_GrPrimitiveType, 0, 4);
}
} else {
// TODO: Our CPU stretch doesn't filter. But we create separate
@@ -758,8 +758,7 @@ void GrContext::drawRect(const GrPaint& paint,
// unitSquareVertexBuffer()
static const int worstCaseVertCount = 10;
- const GrGeometryProcessor* gp = GrDefaultGeoProcFactory::Create(color);
- drawState.setGeometryProcessor(gp)->unref();
+ SkAutoTUnref<const GrGeometryProcessor> gp(GrDefaultGeoProcFactory::Create(color));
GrDrawTarget::AutoReleaseGeometry geo(target,
worstCaseVertCount,
gp->getVertexStride(),
@@ -790,7 +789,7 @@ void GrContext::drawRect(const GrPaint& paint,
vertex[4].set(rect.fLeft, rect.fTop);
}
- target->drawNonIndexed(&drawState, primType, 0, vertCount);
+ target->drawNonIndexed(&drawState, gp, primType, 0, vertCount);
} else {
// filled BW rect
target->drawSimpleRect(&drawState, color, rect);
@@ -813,12 +812,11 @@ void GrContext::drawRectToRect(const GrPaint& paint,
target->drawRect(&drawState, paint.getColor(), dstRect, &localRect, localMatrix);
}
-static void set_vertex_attributes(GrDrawState* drawState,
- const SkPoint* texCoords,
- const GrColor* colors,
- int* colorOffset,
- int* texOffset,
- GrColor color) {
+static const GrGeometryProcessor* set_vertex_attributes(const SkPoint* texCoords,
+ const GrColor* colors,
+ int* colorOffset,
+ int* texOffset,
+ GrColor color) {
*texOffset = -1;
*colorOffset = -1;
@@ -835,7 +833,7 @@ static void set_vertex_attributes(GrDrawState* drawState,
*colorOffset = sizeof(SkPoint);
flags |= GrDefaultGeoProcFactory::kColor_GPType;
}
- drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create(color, flags))->unref();
+ return GrDefaultGeoProcFactory::Create(color, flags);
}
void GrContext::drawVertices(const GrPaint& paint,
@@ -858,10 +856,10 @@ void GrContext::drawVertices(const GrPaint& paint,
GR_CREATE_TRACE_MARKER("GrContext::drawVertices", target);
int colorOffset = -1, texOffset = -1;
- set_vertex_attributes(&drawState, texCoords, colors, &colorOffset, &texOffset,
- paint.getColor());
+ SkAutoTUnref<const GrGeometryProcessor> gp(
+ set_vertex_attributes(texCoords, colors, &colorOffset, &texOffset, paint.getColor()));
- size_t vertexStride = drawState.getGeometryProcessor()->getVertexStride();
+ size_t vertexStride = gp->getVertexStride();
SkASSERT(vertexStride == sizeof(SkPoint) + (SkToBool(texCoords) ? sizeof(SkPoint) : 0)
+ (SkToBool(colors) ? sizeof(GrColor) : 0));
if (!geo.set(target, vertexCount, vertexStride, indexCount)) {
@@ -889,9 +887,9 @@ void GrContext::drawVertices(const GrPaint& paint,
for (int i = 0; i < indexCount; ++i) {
curIndex[i] = indices[i];
}
- target->drawIndexed(&drawState, primitiveType, 0, 0, vertexCount, indexCount);
+ target->drawIndexed(&drawState, gp, primitiveType, 0, 0, vertexCount, indexCount);
} else {
- target->drawNonIndexed(&drawState, primitiveType, 0, vertexCount);
+ target->drawNonIndexed(&drawState, gp, primitiveType, 0, vertexCount);
}
}
« no previous file with comments | « src/gpu/GrBitmapTextContext.cpp ('k') | src/gpu/GrDefaultGeoProcFactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698