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

Unified Diff: src/gpu/batches/GrAADistanceFieldPathRenderer.cpp

Issue 2144663004: Make GrBatchAtlas robust against attempts to add large rects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix warning Created 4 years, 5 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/GrBatchAtlas.cpp ('k') | tests/DFPathRendererTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
index ea802b70dd2f68bcd64a321588abc92d150c754f..553ac6e0c6848270f66af4344f8447c73126e421 100644
--- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
@@ -225,6 +225,8 @@ private:
}
flushInfo.fInstancesToFlush = 0;
+ // Pointer to the next set of vertices to write.
+ intptr_t offset = reinterpret_cast<intptr_t>(vertices);
for (int i = 0; i < instanceCount; i++) {
const Geometry& args = fGeoData[i];
@@ -263,23 +265,20 @@ private:
desiredDimension,
scale)) {
SkDebugf("Can't rasterize path\n");
- return;
+ continue;
}
}
atlas->setLastUseToken(shapeData->fID, target->nextDrawToken());
- // Now set vertices
- intptr_t offset = reinterpret_cast<intptr_t>(vertices);
- offset += i * kVerticesPerQuad * vertexStride;
this->writePathVertices(target,
atlas,
offset,
args.fColor,
vertexStride,
this->viewMatrix(),
- args.fShape,
shapeData);
+ offset += kVerticesPerQuad * vertexStride;
flushInfo.fInstancesToFlush++;
}
@@ -370,15 +369,11 @@ private:
// add to atlas
SkIPoint16 atlasLocation;
GrBatchAtlas::AtlasID id;
- bool success = atlas->addToAtlas(&id, target, width, height, dfStorage.get(),
- &atlasLocation);
- if (!success) {
+ if (!atlas->addToAtlas(&id, target, width, height, dfStorage.get(), &atlasLocation)) {
this->flush(target, flushInfo);
-
- SkDEBUGCODE(success =) atlas->addToAtlas(&id, target, width, height,
- dfStorage.get(), &atlasLocation);
- SkASSERT(success);
-
+ if (!atlas->addToAtlas(&id, target, width, height, dfStorage.get(), &atlasLocation)) {
+ return false;
+ }
}
// add to cache
@@ -414,7 +409,6 @@ private:
GrColor color,
size_t vertexStride,
const SkMatrix& viewMatrix,
- const GrShape& shape,
const ShapeData* shapeData) const {
GrTexture* texture = atlas->getTexture();
@@ -455,15 +449,17 @@ private:
}
void flush(GrVertexBatch::Target* target, FlushInfo* flushInfo) const {
- GrMesh mesh;
- int maxInstancesPerDraw =
- static_cast<int>(flushInfo->fIndexBuffer->gpuMemorySize() / sizeof(uint16_t) / 6);
- mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer,
- flushInfo->fIndexBuffer, flushInfo->fVertexOffset, kVerticesPerQuad,
- kIndicesPerQuad, flushInfo->fInstancesToFlush, maxInstancesPerDraw);
- target->draw(flushInfo->fGeometryProcessor.get(), mesh);
- flushInfo->fVertexOffset += kVerticesPerQuad * flushInfo->fInstancesToFlush;
- flushInfo->fInstancesToFlush = 0;
+ if (flushInfo->fInstancesToFlush) {
+ GrMesh mesh;
+ int maxInstancesPerDraw =
+ static_cast<int>(flushInfo->fIndexBuffer->gpuMemorySize() / sizeof(uint16_t) / 6);
+ mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer,
+ flushInfo->fIndexBuffer, flushInfo->fVertexOffset, kVerticesPerQuad,
+ kIndicesPerQuad, flushInfo->fInstancesToFlush, maxInstancesPerDraw);
+ target->draw(flushInfo->fGeometryProcessor.get(), mesh);
+ flushInfo->fVertexOffset += kVerticesPerQuad * flushInfo->fInstancesToFlush;
+ flushInfo->fInstancesToFlush = 0;
+ }
}
GrColor color() const { return fGeoData[0].fColor; }
« no previous file with comments | « src/gpu/GrBatchAtlas.cpp ('k') | tests/DFPathRendererTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698