handle null vertex or index buffers in batch

BUG=skia:

Review URL: https://codereview.chromium.org/979343002
This commit is contained in:
joshualitt 2015-03-05 14:33:41 -08:00 committed by Commit bot
parent cc4d6673a9
commit 4b31de8328
11 changed files with 123 additions and 2 deletions

View File

@ -76,6 +76,11 @@ private:
&vertexBuffer,
&firstVertex);
if (!vertices || !batchTarget->quadIndexBuffer()) {
SkDebugf("Could not allocate buffers\n");
return;
}
SkASSERT(vertexStride == sizeof(Vertex));
Vertex* verts = reinterpret_cast<Vertex*>(vertices);
@ -478,6 +483,11 @@ private:
&vertexBuffer,
&firstVertex);
if (!vertices || !batchTarget->quadIndexBuffer()) {
SkDebugf("Could not allocate buffers\n");
return;
}
SkASSERT(vertexStride == sizeof(Vertex));
Vertex* verts = reinterpret_cast<Vertex*>(vertices);

View File

@ -62,6 +62,11 @@ private:
&vertexBuffer,
&firstVertex);
if (!vertices || !batchTarget->quadIndexBuffer()) {
SkDebugf("Could not allocate buffers\n");
return;
}
SkASSERT(vertexStride == sizeof(SkPoint));
SkPoint* verts = reinterpret_cast<SkPoint*>(vertices);

View File

@ -784,6 +784,11 @@ public:
&vertexBuffer,
&firstVertex);
if (!vertices) {
SkDebugf("Could not allocate vertices\n");
return;
}
const GrIndexBuffer* indexBuffer;
int firstIndex;
@ -791,6 +796,11 @@ public:
&indexBuffer,
&firstIndex);
if (!indices) {
SkDebugf("Could not allocate indices\n");
return;
}
QuadVertex* verts = reinterpret_cast<QuadVertex*>(vertices);
uint16_t* idxs = reinterpret_cast<uint16_t*>(indices);

View File

@ -895,6 +895,11 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel
&vertexBuffer,
&firstVertex);
if (!vertices) {
SkDebugf("Could not allocate vertices\n");
return;
}
SkASSERT(lineGP->getVertexStride() == sizeof(LineVertex));
LineVertex* verts = reinterpret_cast<LineVertex*>(vertices);
@ -934,6 +939,11 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel
&vertexBuffer,
&firstVertex);
if (!vertices) {
SkDebugf("Could not allocate vertices\n");
return;
}
// Setup vertices
BezierVertex* verts = reinterpret_cast<BezierVertex*>(vertices);
@ -1021,6 +1031,11 @@ bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target,
const SkPath& path,
const SkStrokeRec& stroke,
bool) {
if (!fLinesIndexBuffer || !fQuadsIndexBuffer) {
SkDebugf("unable to allocate indices\n");
return false;
}
SkScalar hairlineCoverage;
uint8_t newCoverage = 0xff;
if (IsStrokeHairlineOrEquivalent(stroke, viewMatrix, &hairlineCoverage)) {

View File

@ -134,6 +134,11 @@ public:
&vertexBuffer,
&firstVertex);
if (!vertices) {
SkDebugf("Could not allocate vertices\n");
return;
}
for (int i = 0; i < instanceCount; i++) {
const Geometry& args = fGeoData[i];
this->generateAAFillRectGeometry(vertices,
@ -445,13 +450,18 @@ void GrAARectRenderer::geometryFillAARect(GrDrawTarget* target,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkRect& devRect) {
if (NULL == fAAFillRectIndexBuffer) {
if (!fAAFillRectIndexBuffer) {
fAAFillRectIndexBuffer = fGpu->createInstancedIndexBuffer(gFillAARectIdx,
kIndicesPerAAFillRect,
kNumAAFillRectsInIndexBuffer,
kVertsPerAAFillRect);
}
if (!fAAFillRectIndexBuffer) {
SkDebugf("Unable to create index buffer\n");
return;
}
AAFillRectBatch::Geometry geometry;
geometry.fRect = rect;
geometry.fViewMatrix = viewMatrix;
@ -623,6 +633,11 @@ public:
&vertexBuffer,
&firstVertex);
if (!vertices) {
SkDebugf("Could not allocate vertices\n");
return;
}
for (int i = 0; i < instanceCount; i++) {
const Geometry& args = fGeoData[i];
this->generateAAStrokeRectGeometry(vertices,
@ -846,7 +861,7 @@ void GrAARectRenderer::geometryStrokeAARect(GrDrawTarget* target,
const SkRect& devInside,
bool miterStroke) {
GrIndexBuffer* indexBuffer = this->aaStrokeRectIndexBuffer(miterStroke);
if (NULL == indexBuffer) {
if (!indexBuffer) {
SkDebugf("Failed to create index buffer!\n");
return;
}

View File

@ -567,6 +567,11 @@ public:
&vertexBuffer,
&firstVertex);
if (!vertices) {
SkDebugf("Could not allocate vertices\n");
return;
}
SkPoint* vertex = reinterpret_cast<SkPoint*>(vertices);
GrPrimitiveType primType;
@ -900,6 +905,11 @@ public:
&vertexBuffer,
&firstVertex);
if (!vertices) {
SkDebugf("Could not allocate vertices\n");
return;
}
const GrIndexBuffer* indexBuffer;
int firstIndex;
@ -908,6 +918,11 @@ public:
indices = batchTarget->indexPool()->makeSpace(this->indexCount(),
&indexBuffer,
&firstIndex);
if (!indices) {
SkDebugf("Could not allocate indices\n");
return;
}
}
int indexOffset = 0;

View File

@ -323,6 +323,11 @@ public:
&vertexBuffer,
&firstVertex);
if (!vertices) {
SkDebugf("Could not allocate vertices\n");
return;
}
const GrIndexBuffer* indexBuffer;
int firstIndex;
@ -331,6 +336,11 @@ public:
indices = batchTarget->indexPool()->makeSpace(maxIndices,
&indexBuffer,
&firstIndex);
if (!indices) {
SkDebugf("Could not allocate indices\n");
return;
}
}
// fill buffers

View File

@ -147,6 +147,11 @@ public:
&vertexBuffer,
&firstVertex);
if (!vertices || !batchTarget->quadIndexBuffer()) {
SkDebugf("Could not allocate buffers\n");
return;
}
for (int i = 0; i < instanceCount; i++) {
const Geometry& args = fGeoData[i];

View File

@ -762,6 +762,11 @@ public:
&vertexBuffer,
&firstVertex);
if (!vertices || !batchTarget->quadIndexBuffer()) {
SkDebugf("Could not allocate buffers\n");
return;
}
CircleVertex* verts = reinterpret_cast<CircleVertex*>(vertices);
for (int i = 0; i < instanceCount; i++) {
@ -1012,6 +1017,11 @@ public:
&vertexBuffer,
&firstVertex);
if (!vertices || !batchTarget->quadIndexBuffer()) {
SkDebugf("Could not allocate buffers\n");
return;
}
EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(vertices);
for (int i = 0; i < instanceCount; i++) {
@ -1303,6 +1313,11 @@ public:
&vertexBuffer,
&firstVertex);
if (!vertices || !batchTarget->quadIndexBuffer()) {
SkDebugf("Could not allocate buffers\n");
return;
}
DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(vertices);
for (int i = 0; i < instanceCount; i++) {
@ -1692,6 +1707,11 @@ public:
&vertexBuffer,
&firstVertex);
if (!vertices) {
SkDebugf("Could not allocate vertices\n");
return;
}
CircleVertex* verts = reinterpret_cast<CircleVertex*>(vertices);
for (int i = 0; i < instanceCount; i++) {
@ -1896,6 +1916,11 @@ public:
&vertexBuffer,
&firstVertex);
if (!vertices) {
SkDebugf("Could not allocate vertices\n");
return;
}
EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(vertices);
for (int i = 0; i < instanceCount; i++) {

View File

@ -1515,6 +1515,12 @@ public:
count,
&vertexBuffer,
&firstVertex);
if (!vertices) {
SkDebugf("Could not allocate vertices\n");
return;
}
LOG("emitting %d verts\n", count);
void* end = polys_to_triangles(polys, fillType, vertices);
int actualCount = static_cast<int>(

View File

@ -536,6 +536,11 @@ public:
&vertexBuffer,
&firstVertex);
if (!vertices || !batchTarget->quadIndexBuffer()) {
SkDebugf("Could not allocate buffers\n");
return;
}
int curVIdx = 0;
int rectIndex = 0;
for (int i = 0; i < instanceCount; i++) {