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

Unified Diff: src/gpu/gl/GrGpuGL_program.cpp

Issue 12533007: Use vertex array objects on core profiles. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Use vertex array objects on core profiles. Created 7 years, 9 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
Index: src/gpu/gl/GrGpuGL_program.cpp
===================================================================
--- src/gpu/gl/GrGpuGL_program.cpp (revision 8015)
+++ src/gpu/gl/GrGpuGL_program.cpp (working copy)
@@ -217,10 +217,57 @@
GrGLsizei stride = this->getDrawState().getVertexSize();
- size_t vertexOffset;
- GrGLVertexBuffer* vb= this->setBuffers(info.isIndexed(), &vertexOffset, indexOffsetInBytes);
- vertexOffset += stride * info.startVertex();
+ size_t vertexOffsetInBytes = stride * info.startVertex();
+ const GeometryPoolState& geoPoolState = this->getGeomPoolState();
+
+ GrGLVertexBuffer* vbuf;
+ switch (this->getGeomSrc().fVertexSrc) {
+ case kBuffer_GeometrySrcType:
+ vbuf = (GrGLVertexBuffer*) this->getGeomSrc().fVertexBuffer;
+ break;
+ case kArray_GeometrySrcType:
+ case kReserved_GeometrySrcType:
+ this->finalizeReservedVertices();
+ vertexOffsetInBytes += geoPoolState.fPoolStartVertex * this->getGeomSrc().fVertexSize;
+ vbuf = (GrGLVertexBuffer*) geoPoolState.fPoolVertexBuffer;
+ break;
+ default:
+ vbuf = NULL; // suppress warning
+ GrCrash("Unknown geometry src type!");
+ }
+
+ GrAssert(NULL != vbuf);
+ GrAssert(!vbuf->isLocked());
+ vertexOffsetInBytes += vbuf->baseOffset();
+
+ GrGLIndexBuffer* ibuf = NULL;
+ if (info.isIndexed()) {
+ GrAssert(NULL != indexOffsetInBytes);
+
+ switch (this->getGeomSrc().fIndexSrc) {
+ case kBuffer_GeometrySrcType:
+ *indexOffsetInBytes = 0;
+ ibuf = (GrGLIndexBuffer*)this->getGeomSrc().fIndexBuffer;
+ break;
+ case kArray_GeometrySrcType:
+ case kReserved_GeometrySrcType:
+ this->finalizeReservedIndices();
+ *indexOffsetInBytes = geoPoolState.fPoolStartIndex * sizeof(GrGLushort);
+ ibuf = (GrGLIndexBuffer*) geoPoolState.fPoolIndexBuffer;
+ break;
+ default:
+ ibuf = NULL; // suppress warning
+ GrCrash("Unknown geometry src type!");
+ }
+
+ GrAssert(NULL != ibuf);
+ GrAssert(!ibuf->isLocked());
+ *indexOffsetInBytes += ibuf->baseOffset();
+ }
+ GrGLAttribArrayState* attribState =
+ fHWGeometryState.bindArrayAndBuffersToDraw(this, vbuf, ibuf);
+
uint32_t usedAttribArraysMask = 0;
const GrVertexAttrib* vertexAttrib = this->getDrawState().getVertexAttribs();
int vertexAttribCount = this->getDrawState().getVertexAttribCount();
@@ -229,16 +276,16 @@
usedAttribArraysMask |= (1 << vertexAttribIndex);
GrVertexAttribType attribType = vertexAttrib->fType;
- fHWGeometryState.setAttribArray(this,
- vertexAttribIndex,
- vb,
- GrGLProgram::kAttribLayouts[attribType].fCount,
- GrGLProgram::kAttribLayouts[attribType].fType,
- GrGLProgram::kAttribLayouts[attribType].fNormalized,
- stride,
- reinterpret_cast<GrGLvoid*>(
- vertexOffset + vertexAttrib->fOffset));
- }
+ attribState->set(this,
+ vertexAttribIndex,
+ vbuf,
+ GrGLProgram::kAttribLayouts[attribType].fCount,
+ GrGLProgram::kAttribLayouts[attribType].fType,
+ GrGLProgram::kAttribLayouts[attribType].fNormalized,
+ stride,
+ reinterpret_cast<GrGLvoid*>(
+ vertexOffsetInBytes + vertexAttrib->fOffset));
+ }
- fHWGeometryState.disableUnusedAttribArrays(this, usedAttribArraysMask);
+ attribState->disableUnusedAttribArrays(this, usedAttribArraysMask);
}

Powered by Google App Engine
This is Rietveld 408576698