diff options
author | 2013-03-01 15:36:02 +0000 | |
---|---|---|
committer | 2013-03-01 15:36:02 +0000 | |
commit | ecd84842b3f65918eb040c53391172b6413fd7ad (patch) | |
tree | b6fb8cad101462c65157bad473b161ed40f0bb23 /src/gpu/gl/debug/GrGLCreateDebugInterface.cpp | |
parent | b82c3993c2f753e5caaff2df9648ebdafc68595f (diff) |
Add support to GrGLInterface for vertex array objects
Committed: https://code.google.com/p/skia/source/detail?r=7919
Review URL: https://codereview.chromium.org/12379025
git-svn-id: http://skia.googlecode.com/svn/trunk@7924 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/gl/debug/GrGLCreateDebugInterface.cpp')
-rw-r--r-- | src/gpu/gl/debug/GrGLCreateDebugInterface.cpp | 56 |
1 files changed, 39 insertions, 17 deletions
diff --git a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp index 21a3d1bf71..f8c5b1fdcc 100644 --- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp +++ b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp @@ -16,6 +16,7 @@ #include "GrTextureObj.h" #include "GrFrameBufferObj.h" #include "GrRenderBufferObj.h" +#include "GrVertexArrayObj.h" #include "SkFloatingPoint.h" #include "../GrGLNoOpInterface.h" @@ -212,8 +213,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE debugGLReadPixels(GrGLint x, GrDebugGL::getInstance()->setFrameBuffer(frameBuffer); } - GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindRenderbuffer(GrGLenum target, - GrGLuint renderBufferID) { + GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindRenderbuffer(GrGLenum target, GrGLuint renderBufferID) { GrAlwaysAssert(GR_GL_RENDERBUFFER == target); @@ -225,8 +225,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE debugGLReadPixels(GrGLint x, GrDebugGL::getInstance()->setRenderBuffer(renderBuffer); } - GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteTextures(GrGLsizei n, - const GrGLuint* textures) { + GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteTextures(GrGLsizei n, const GrGLuint* textures) { // first potentially unbind the texture // TODO: move this into GrDebugGL as unBindTexture? @@ -287,7 +286,6 @@ GrGLvoid GR_GL_FUNCTION_TYPE debugGLReadPixels(GrGLint x, } - GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteFramebuffers(GrGLsizei n, const GrGLuint *frameBuffers) { @@ -518,32 +516,55 @@ GrGLvoid debugGenObjs(GrDebugGL::GrObjTypes type, } GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenBuffers(GrGLsizei n, GrGLuint* ids) { - debugGenObjs(GrDebugGL::kBuffer_ObjTypes, n, ids); } GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenFramebuffers(GrGLsizei n, GrGLuint* ids) { - debugGenObjs(GrDebugGL::kFrameBuffer_ObjTypes, n, ids); } GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenRenderbuffers(GrGLsizei n, GrGLuint* ids) { - debugGenObjs(GrDebugGL::kRenderBuffer_ObjTypes, n, ids); } GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenTextures(GrGLsizei n, GrGLuint* ids) { - debugGenObjs(GrDebugGL::kTexture_ObjTypes, n, ids); } -GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindBuffer(GrGLenum target, - GrGLuint bufferID) { +GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenVertexArrays(GrGLsizei n, GrGLuint* ids) { + debugGenObjs(GrDebugGL::kVertexArray_ObjTypes, n, ids); +} - GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || - GR_GL_ELEMENT_ARRAY_BUFFER == target); +GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteVertexArrays(GrGLsizei n, const GrGLuint* ids) { + for (GrGLsizei i = 0; i < n; ++i) { + GrVertexArrayObj* array = + GR_FIND(ids[i], GrVertexArrayObj, GrDebugGL::kVertexArray_ObjTypes); + GrAlwaysAssert(array); + + // Deleting the current vertex array binds object 0 + if (GrDebugGL::getInstance()->getVertexArray() == array) { + GrDebugGL::getInstance()->setVertexArray(NULL); + } + + if (array->getRefCount()) { + // someone is still using this vertex array so we can't delete it here + array->setMarkedForDeletion(); + } else { + array->deleteAction(); + } + } +} + +GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindVertexArray(GrGLuint id) { + GrVertexArrayObj* array = GR_FIND(id, GrVertexArrayObj, GrDebugGL::kVertexArray_ObjTypes); + GrAlwaysAssert(array); + GrDebugGL::getInstance()->setVertexArray(array); +} + +GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindBuffer(GrGLenum target, GrGLuint bufferID) { + GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || GR_GL_ELEMENT_ARRAY_BUFFER == target); GrBufferObj *buffer = GR_FIND(bufferID, GrBufferObj, @@ -564,8 +585,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindBuffer(GrGLenum target, } // deleting a bound buffer has the side effect of binding 0 -GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteBuffers(GrGLsizei n, - const GrGLuint* ids) { +GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteBuffers(GrGLsizei n, const GrGLuint* ids) { // first potentially unbind the buffers for (int i = 0; i < n; ++i) { @@ -595,8 +615,7 @@ GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteBuffers(GrGLsizei n, } // map a buffer to the caller's address space -GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBuffer(GrGLenum target, - GrGLenum access) { +GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBuffer(GrGLenum target, GrGLenum access) { GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || GR_GL_ELEMENT_ARRAY_BUFFER == target); @@ -767,6 +786,7 @@ const GrGLInterface* GrGLCreateDebugInterface() { interface->fBindBuffer = debugGLBindBuffer; interface->fBindFragDataLocation = noOpGLBindFragDataLocation; interface->fBindTexture = debugGLBindTexture; + interface->fBindVertexArray = debugGLBindVertexArray; interface->fBlendColor = noOpGLBlendColor; interface->fBlendFunc = noOpGLBlendFunc; interface->fBufferData = debugGLBufferData; @@ -785,6 +805,7 @@ const GrGLInterface* GrGLCreateDebugInterface() { interface->fDeleteQueries = noOpGLDeleteIds; interface->fDeleteShader = debugGLDeleteShader; interface->fDeleteTextures = debugGLDeleteTextures; + interface->fDeleteVertexArrays = debugGLDeleteVertexArrays; interface->fDepthMask = noOpGLDepthMask; interface->fDisable = noOpGLDisable; interface->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray; @@ -817,6 +838,7 @@ const GrGLInterface* GrGLCreateDebugInterface() { interface->fGetStringi = noOpGLGetStringi; interface->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv; interface->fGetUniformLocation = noOpGLGetUniformLocation; + interface->fGenVertexArrays = debugGLGenVertexArrays; interface->fLineWidth = noOpGLLineWidth; interface->fLinkProgram = noOpGLLinkProgram; interface->fPixelStorei = debugGLPixelStorei; |