aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-05 20:12:30 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-05 20:12:30 +0000
commit6513cd06ae34f5d777b3aaea0b4533014d0a10f2 (patch)
tree05411947795649eab052658f109db56c5121fba0
parent82866fd5a7ac55a7abe7bc1069741fa353e608d8 (diff)
Fail draws when can't get geom into vb/ib.
Review URL: http://codereview.appspot.com/4837059/ git-svn-id: http://skia.googlecode.com/svn/trunk@2053 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--gpu/include/GrContext_impl.h2
-rw-r--r--gpu/include/GrDrawTarget.h6
-rw-r--r--gpu/src/GrBufferAllocPool.cpp7
-rw-r--r--gpu/src/GrContext.cpp30
-rw-r--r--gpu/src/GrDrawTarget.cpp4
-rw-r--r--gpu/src/GrInOrderDrawBuffer.cpp4
6 files changed, 42 insertions, 11 deletions
diff --git a/gpu/include/GrContext_impl.h b/gpu/include/GrContext_impl.h
index df16c8cb41..8596491a80 100644
--- a/gpu/include/GrContext_impl.h
+++ b/gpu/include/GrContext_impl.h
@@ -37,7 +37,7 @@ inline void GrContext::drawCustomVertices(const GrPaint& paint,
int indexCount = (NULL != idxSrc) ? idxSrc->count() : 0;
if (!geo.set(target, layout, vertexCount, indexCount)) {
- GrPrintf("Failed to get space for vertices!");
+ GrPrintf("Failed to get space for vertices!\n");
return;
}
diff --git a/gpu/include/GrDrawTarget.h b/gpu/include/GrDrawTarget.h
index 4431dc0839..8196beb102 100644
--- a/gpu/include/GrDrawTarget.h
+++ b/gpu/include/GrDrawTarget.h
@@ -938,10 +938,10 @@ public:
int vertexCount,
int indexCount);
bool succeeded() const { return NULL != fTarget; }
- void* vertices() const { return fVertices; }
- void* indices() const { return fIndices; }
+ void* vertices() const { GrAssert(this->succeeded()); return fVertices; }
+ void* indices() const { GrAssert(this->succeeded()); return fIndices; }
GrPoint* positions() const {
- return static_cast<GrPoint*>(fVertices);
+ return static_cast<GrPoint*>(this->vertices());
}
private:
diff --git a/gpu/src/GrBufferAllocPool.cpp b/gpu/src/GrBufferAllocPool.cpp
index efe2017cb4..5b4935085b 100644
--- a/gpu/src/GrBufferAllocPool.cpp
+++ b/gpu/src/GrBufferAllocPool.cpp
@@ -220,7 +220,12 @@ void GrBufferAllocPool::putBack(size_t bytes) {
if (bytes >= bytesUsed) {
bytes -= bytesUsed;
fBytesInUse -= bytesUsed;
- destroyBlock();
+ // if we locked a vb to satisfy the make space and we're releasing
+ // beyond it, then unlock it.
+ if (block.fBuffer->isLocked()) {
+ block.fBuffer->unlock();
+ }
+ this->destroyBlock();
} else {
block.fBytesFree += bytes;
fBytesInUse -= bytes;
diff --git a/gpu/src/GrContext.cpp b/gpu/src/GrContext.cpp
index 10ff206871..bfae62e051 100644
--- a/gpu/src/GrContext.cpp
+++ b/gpu/src/GrContext.cpp
@@ -955,6 +955,10 @@ void GrContext::fillAARect(GrDrawTarget* target,
size_t vsize = GrDrawTarget::VertexSize(layout);
GrDrawTarget::AutoReleaseGeometry geo(target, layout, 8, 0);
+ if (!geo.succeeded()) {
+ GrPrintf("Failed to get space for vertices!\n");
+ return;
+ }
intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices());
@@ -1008,6 +1012,10 @@ void GrContext::strokeAARect(GrDrawTarget* target, const GrPaint& paint,
size_t vsize = GrDrawTarget::VertexSize(layout);
GrDrawTarget::AutoReleaseGeometry geo(target, layout, 16, 0);
+ if (!geo.succeeded()) {
+ GrPrintf("Failed to get space for vertices!\n");
+ return;
+ }
intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices());
@@ -1149,6 +1157,7 @@ void GrContext::drawRect(const GrPaint& paint,
GrDrawTarget::AutoReleaseGeometry geo(target, layout, worstCaseVertCount, 0);
if (!geo.succeeded()) {
+ GrPrintf("Failed to get space for vertices!\n");
return;
}
@@ -1182,9 +1191,12 @@ void GrContext::drawRect(const GrPaint& paint,
} else {
#if GR_STATIC_RECT_VB
GrVertexLayout layout = PaintStageVertexLayoutBits(paint, NULL);
-
- target->setVertexSourceToBuffer(layout,
- fGpu->getUnitSquareVertexBuffer());
+ const GrVertexBuffer* sqVB = fGpu->getUnitSquareVertexBuffer();
+ if (NULL == sqVB) {
+ GrPrintf("Failed to create static rect vb.\n");
+ return;
+ }
+ target->setVertexSourceToBuffer(layout, sqVB);
GrDrawTarget::AutoViewMatrixRestore avmr(target);
GrMatrix m;
m.setAll(rect.width(), 0, rect.fLeft,
@@ -1251,7 +1263,12 @@ void GrContext::drawRectToRect(const GrPaint& paint,
}
target->preConcatSamplerMatrix(GrPaint::kFirstTextureStage, m);
- target->setVertexSourceToBuffer(layout, fGpu->getUnitSquareVertexBuffer());
+ const GrVertexBuffer* sqVB = fGpu->getUnitSquareVertexBuffer();
+ if (NULL == sqVB) {
+ GrPrintf("Failed to create static rect vb.\n");
+ return;
+ }
+ target->setVertexSourceToBuffer(layout, sqVB);
target->drawNonIndexed(kTriangleFan_PrimitiveType, 0, 4);
#else
@@ -1299,7 +1316,7 @@ void GrContext::drawVertices(const GrPaint& paint,
if (sizeof(GrPoint) != vertexSize) {
if (!geo.set(target, layout, vertexCount, 0)) {
- GrPrintf("Failed to get space for vertices!");
+ GrPrintf("Failed to get space for vertices!\n");
return;
}
int texOffsets[GrDrawTarget::kMaxTexCoords];
@@ -1517,9 +1534,10 @@ void GrContext::writePixels(int left, int top, int width, int height,
GrVertexLayout layout = GrDrawTarget::StagePosAsTexCoordVertexLayoutBit(0);
static const int VCOUNT = 4;
-
+ // TODO: Use GrGpu::drawRect here
GrDrawTarget::AutoReleaseGeometry geo(fGpu, layout, VCOUNT, 0);
if (!geo.succeeded()) {
+ GrPrintf("Failed to get space for vertices!\n");
return;
}
((GrPoint*)geo.vertices())->setIRectFan(0, 0, width, height);
diff --git a/gpu/src/GrDrawTarget.cpp b/gpu/src/GrDrawTarget.cpp
index ad066d8609..1dd750de24 100644
--- a/gpu/src/GrDrawTarget.cpp
+++ b/gpu/src/GrDrawTarget.cpp
@@ -768,6 +768,10 @@ void GrDrawTarget::drawRect(const GrRect& rect,
GrVertexLayout layout = GetRectVertexLayout(stageEnableBitfield, srcRects);
AutoReleaseGeometry geo(this, layout, 4, 0);
+ if (!geo.succeeded()) {
+ GrPrintf("Failed to get space for vertices!\n");
+ return;
+ }
SetRectVertices(rect, matrix, srcRects,
srcMatrices, layout, geo.vertices());
diff --git a/gpu/src/GrInOrderDrawBuffer.cpp b/gpu/src/GrInOrderDrawBuffer.cpp
index a8eb1f5d09..39bf275560 100644
--- a/gpu/src/GrInOrderDrawBuffer.cpp
+++ b/gpu/src/GrInOrderDrawBuffer.cpp
@@ -87,6 +87,10 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
bool appendToPreviousDraw = false;
GrVertexLayout layout = GetRectVertexLayout(stageEnableBitfield, srcRects);
AutoReleaseGeometry geo(this, layout, 4, 0);
+ if (!geo.succeeded()) {
+ GrPrintf("Failed to get space for vertices!\n");
+ return;
+ }
AutoViewMatrixRestore avmr(this);
GrMatrix combinedMatrix = this->getViewMatrix();
this->setViewMatrix(GrMatrix::I());