diff options
author | 2011-08-19 13:28:54 +0000 | |
---|---|---|
committer | 2011-08-19 13:28:54 +0000 | |
commit | 0b77d6892b067ad402c9678b0226bff70599fbe2 (patch) | |
tree | c3659ba65d516bedf2d3a021f2b9f4be94d3f04b /gpu/src/GrGLIndexBuffer.cpp | |
parent | 098660020cf06ef9a95934b9635ab6996145b3e2 (diff) |
Make GrGLInterface a per-GrContext refcounted object rather than a global
Review URL: http://codereview.appspot.com/4901046/
git-svn-id: http://skia.googlecode.com/svn/trunk@2140 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gpu/src/GrGLIndexBuffer.cpp')
-rw-r--r-- | gpu/src/GrGLIndexBuffer.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/gpu/src/GrGLIndexBuffer.cpp b/gpu/src/GrGLIndexBuffer.cpp index 3b34d63eea..54ee78bc27 100644 --- a/gpu/src/GrGLIndexBuffer.cpp +++ b/gpu/src/GrGLIndexBuffer.cpp @@ -13,6 +13,8 @@ #define GPUGL static_cast<GrGpuGL*>(getGpu()) +#define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X) + GrGLIndexBuffer::GrGLIndexBuffer(GrGpuGL* gpu, GrGLuint id, size_t sizeInBytes, @@ -27,7 +29,7 @@ void GrGLIndexBuffer::onRelease() { // make sure we've not been abandoned if (fBufferID) { GPUGL->notifyIndexBufferDelete(this); - GR_GL(DeleteBuffers(1, &fBufferID)); + GL_CALL(DeleteBuffers(1, &fBufferID)); fBufferID = 0; } } @@ -38,7 +40,7 @@ void GrGLIndexBuffer::onAbandon() { } void GrGLIndexBuffer::bind() const { - GR_GL(BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, fBufferID)); + GL_CALL(BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, fBufferID)); GPUGL->notifyIndexBufferBind(this); } @@ -52,9 +54,13 @@ void* GrGLIndexBuffer::lock() { if (GPUGL->supportsBufferLocking()) { this->bind(); // Let driver know it can discard the old data - GR_GL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, this->sizeInBytes(), NULL, - this->dynamic() ? GR_GL_DYNAMIC_DRAW : GR_GL_STATIC_DRAW)); - fLockPtr = GR_GL(MapBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, GR_GL_WRITE_ONLY)); + GL_CALL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, + this->sizeInBytes(), + NULL, + this->dynamic() ? GR_GL_DYNAMIC_DRAW : + GR_GL_STATIC_DRAW)); + fLockPtr = GL_CALL(MapBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, + GR_GL_WRITE_ONLY)); return fLockPtr; } @@ -71,7 +77,7 @@ void GrGLIndexBuffer::unlock() { GrAssert(GPUGL->supportsBufferLocking()); this->bind(); - GR_GL(UnmapBuffer(GR_GL_ELEMENT_ARRAY_BUFFER)); + GL_CALL(UnmapBuffer(GR_GL_ELEMENT_ARRAY_BUFFER)); fLockPtr = NULL; } @@ -80,8 +86,8 @@ bool GrGLIndexBuffer::isLocked() const { if (this->isValid() && GPUGL->supportsBufferLocking()) { this->bind(); GrGLint mapped; - GR_GL(GetBufferParameteriv(GR_GL_ELEMENT_ARRAY_BUFFER, - GR_GL_BUFFER_MAPPED, &mapped)); + GL_CALL(GetBufferParameteriv(GR_GL_ELEMENT_ARRAY_BUFFER, + GR_GL_BUFFER_MAPPED, &mapped)); GrAssert(!!mapped == !!fLockPtr); } #endif @@ -97,12 +103,15 @@ bool GrGLIndexBuffer::updateData(const void* src, size_t srcSizeInBytes) { this->bind(); GrGLenum usage = dynamic() ? GR_GL_DYNAMIC_DRAW : GR_GL_STATIC_DRAW; if (this->sizeInBytes() == srcSizeInBytes) { - GR_GL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, srcSizeInBytes, src, usage)); + GL_CALL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, + srcSizeInBytes, src, usage)); } else { #if GR_GL_USE_BUFFER_DATA_NULL_HINT - GR_GL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, this->sizeInBytes(), NULL, usage)); + GL_CALL(BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, + this->sizeInBytes(), NULL, usage)); #endif - GR_GL(BufferSubData(GR_GL_ELEMENT_ARRAY_BUFFER, 0, srcSizeInBytes, src)); + GL_CALL(BufferSubData(GR_GL_ELEMENT_ARRAY_BUFFER, + 0, srcSizeInBytes, src)); } return true; } @@ -116,7 +125,8 @@ bool GrGLIndexBuffer::updateSubData(const void* src, return false; } this->bind(); - GR_GL(BufferSubData(GR_GL_ELEMENT_ARRAY_BUFFER, offset, srcSizeInBytes, src)); + GL_CALL(BufferSubData(GR_GL_ELEMENT_ARRAY_BUFFER, + offset, srcSizeInBytes, src)); return true; } |