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

Unified Diff: src/gpu/GrContext.cpp

Issue 1121463002: Move bounds to GrBatch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweak Created 5 years, 8 months 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/GrBatch.h ('k') | src/gpu/GrDefaultPathRenderer.cpp » ('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 301c676af741f42fffd68524a43466b3d7acf6ac..47095135259eb4e8654fabaaad877baf49125363 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -529,6 +529,12 @@ private:
fBatch.fHairline = geometry.fStrokeWidth == 0;
fGeoData.push_back(geometry);
+
+ // setup bounds
+ fBounds = geometry.fRect;
+ SkScalar rad = SkScalarHalf(geometry.fStrokeWidth);
+ fBounds.outset(rad, rad);
+ geometry.fViewMatrix.mapRect(&fBounds);
}
/* create a triangle strip that strokes the specified rect. There are 8
@@ -679,16 +685,12 @@ void GrContext::drawRect(GrRenderTarget* rt,
SkAutoTUnref<GrBatch> batch(StrokeRectBatch::Create(geometry));
- SkRect bounds = rect;
- SkScalar rad = SkScalarHalf(width);
- bounds.outset(rad, rad);
- viewMatrix.mapRect(&bounds);
// Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of
// hairline rects. We jam all the vertices to pixel centers to avoid this, but not when MSAA
// is enabled because it can cause ugly artifacts.
pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_Flag,
0 == width && !rt->isMultisampled());
- target->drawBatch(&pipelineBuilder, batch, &bounds);
+ target->drawBatch(&pipelineBuilder, batch);
} else {
// filled BW rect
target->drawSimpleRect(&pipelineBuilder, color, viewMatrix, rect);
@@ -758,10 +760,11 @@ public:
const SkMatrix& viewMatrix,
const SkPoint* positions, int vertexCount,
const uint16_t* indices, int indexCount,
- const GrColor* colors, const SkPoint* localCoords) {
+ const GrColor* colors, const SkPoint* localCoords,
+ const SkRect& bounds) {
return SkNEW_ARGS(DrawVerticesBatch, (geometry, primitiveType, viewMatrix, positions,
vertexCount, indices, indexCount, colors,
- localCoords));
+ localCoords, bounds));
}
const char* name() const override { return "DrawVerticesBatch"; }
@@ -895,7 +898,7 @@ private:
const SkMatrix& viewMatrix,
const SkPoint* positions, int vertexCount,
const uint16_t* indices, int indexCount,
- const GrColor* colors, const SkPoint* localCoords) {
+ const GrColor* colors, const SkPoint* localCoords, const SkRect& bounds) {
this->initClassID<DrawVerticesBatch>();
SkASSERT(positions);
@@ -926,6 +929,8 @@ private:
fBatch.fVertexCount = vertexCount;
fBatch.fIndexCount = indexCount;
fBatch.fPrimitiveType = primitiveType;
+
+ this->setBounds(bounds);
}
GrPrimitiveType primitiveType() const { return fBatch.fPrimitiveType; }
@@ -980,6 +985,8 @@ private:
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
fBatch.fVertexCount += that->vertexCount();
fBatch.fIndexCount += that->indexCount();
+
+ this->joinBounds(that->bounds());
return true;
}
@@ -1032,13 +1039,12 @@ void GrContext::drawVertices(GrRenderTarget* rt,
DrawVerticesBatch::Geometry geometry;
geometry.fColor = paint.getColor();
-
SkAutoTUnref<GrBatch> batch(DrawVerticesBatch::Create(geometry, primitiveType, viewMatrix,
positions, vertexCount, indices,
- indexCount,colors, texCoords));
+ indexCount, colors, texCoords,
+ bounds));
- // TODO figure out bounds
- target->drawBatch(&pipelineBuilder, batch, &bounds);
+ target->drawBatch(&pipelineBuilder, batch);
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/gpu/GrBatch.h ('k') | src/gpu/GrDefaultPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698