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
This commit is contained in:
bsalomon@google.com 2011-08-05 20:12:30 +00:00
Родитель 82866fd5a7
Коммит 6513cd06ae
6 изменённых файлов: 42 добавлений и 11 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);

Просмотреть файл

@ -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());

Просмотреть файл

@ -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());