Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | |
michael@0 | 2 | /* |
michael@0 | 3 | * Copyright 2012 Google Inc. |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | #include "gl/GrGLInterface.h" |
michael@0 | 11 | #include "GrDebugGL.h" |
michael@0 | 12 | #include "GrShaderObj.h" |
michael@0 | 13 | #include "GrProgramObj.h" |
michael@0 | 14 | #include "GrBufferObj.h" |
michael@0 | 15 | #include "GrTextureUnitObj.h" |
michael@0 | 16 | #include "GrTextureObj.h" |
michael@0 | 17 | #include "GrFrameBufferObj.h" |
michael@0 | 18 | #include "GrRenderBufferObj.h" |
michael@0 | 19 | #include "GrVertexArrayObj.h" |
michael@0 | 20 | #include "SkFloatingPoint.h" |
michael@0 | 21 | #include "../GrGLNoOpInterface.h" |
michael@0 | 22 | |
michael@0 | 23 | namespace { // suppress no previous prototype warning |
michael@0 | 24 | |
michael@0 | 25 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 26 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLActiveTexture(GrGLenum texture) { |
michael@0 | 27 | |
michael@0 | 28 | // Ganesh offsets the texture unit indices |
michael@0 | 29 | texture -= GR_GL_TEXTURE0; |
michael@0 | 30 | GrAlwaysAssert(texture < GrDebugGL::getInstance()->getMaxTextureUnits()); |
michael@0 | 31 | |
michael@0 | 32 | GrDebugGL::getInstance()->setCurTextureUnit(texture); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 36 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLAttachShader(GrGLuint programID, |
michael@0 | 37 | GrGLuint shaderID) { |
michael@0 | 38 | |
michael@0 | 39 | GrProgramObj *program = GR_FIND(programID, GrProgramObj, |
michael@0 | 40 | GrDebugGL::kProgram_ObjTypes); |
michael@0 | 41 | GrAlwaysAssert(program); |
michael@0 | 42 | |
michael@0 | 43 | GrShaderObj *shader = GR_FIND(shaderID, |
michael@0 | 44 | GrShaderObj, |
michael@0 | 45 | GrDebugGL::kShader_ObjTypes); |
michael@0 | 46 | GrAlwaysAssert(shader); |
michael@0 | 47 | |
michael@0 | 48 | program->AttachShader(shader); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBeginQuery(GrGLenum target, GrGLuint id) { |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindAttribLocation(GrGLuint program, |
michael@0 | 55 | GrGLuint index, |
michael@0 | 56 | const char* name) { |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 60 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindTexture(GrGLenum target, |
michael@0 | 61 | GrGLuint textureID) { |
michael@0 | 62 | |
michael@0 | 63 | // we don't use cube maps |
michael@0 | 64 | GrAlwaysAssert(target == GR_GL_TEXTURE_2D); |
michael@0 | 65 | // || target == GR_GL_TEXTURE_CUBE_MAP); |
michael@0 | 66 | |
michael@0 | 67 | // a textureID of 0 is acceptable - it binds to the default texture target |
michael@0 | 68 | GrTextureObj *texture = GR_FIND(textureID, GrTextureObj, |
michael@0 | 69 | GrDebugGL::kTexture_ObjTypes); |
michael@0 | 70 | |
michael@0 | 71 | GrDebugGL::getInstance()->setTexture(texture); |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | |
michael@0 | 75 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 76 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBufferData(GrGLenum target, |
michael@0 | 77 | GrGLsizeiptr size, |
michael@0 | 78 | const GrGLvoid* data, |
michael@0 | 79 | GrGLenum usage) { |
michael@0 | 80 | GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || |
michael@0 | 81 | GR_GL_ELEMENT_ARRAY_BUFFER == target); |
michael@0 | 82 | GrAlwaysAssert(size >= 0); |
michael@0 | 83 | GrAlwaysAssert(GR_GL_STREAM_DRAW == usage || |
michael@0 | 84 | GR_GL_STATIC_DRAW == usage || |
michael@0 | 85 | GR_GL_DYNAMIC_DRAW == usage); |
michael@0 | 86 | |
michael@0 | 87 | GrBufferObj *buffer = NULL; |
michael@0 | 88 | switch (target) { |
michael@0 | 89 | case GR_GL_ARRAY_BUFFER: |
michael@0 | 90 | buffer = GrDebugGL::getInstance()->getArrayBuffer(); |
michael@0 | 91 | break; |
michael@0 | 92 | case GR_GL_ELEMENT_ARRAY_BUFFER: |
michael@0 | 93 | buffer = GrDebugGL::getInstance()->getElementArrayBuffer(); |
michael@0 | 94 | break; |
michael@0 | 95 | default: |
michael@0 | 96 | GrCrash("Unexpected target to glBufferData"); |
michael@0 | 97 | break; |
michael@0 | 98 | } |
michael@0 | 99 | |
michael@0 | 100 | GrAlwaysAssert(buffer); |
michael@0 | 101 | GrAlwaysAssert(buffer->getBound()); |
michael@0 | 102 | |
michael@0 | 103 | buffer->allocate(size, reinterpret_cast<const GrGLchar *>(data)); |
michael@0 | 104 | buffer->setUsage(usage); |
michael@0 | 105 | } |
michael@0 | 106 | |
michael@0 | 107 | |
michael@0 | 108 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLPixelStorei(GrGLenum pname, |
michael@0 | 109 | GrGLint param) { |
michael@0 | 110 | |
michael@0 | 111 | switch (pname) { |
michael@0 | 112 | case GR_GL_UNPACK_ROW_LENGTH: |
michael@0 | 113 | GrDebugGL::getInstance()->setUnPackRowLength(param); |
michael@0 | 114 | break; |
michael@0 | 115 | case GR_GL_PACK_ROW_LENGTH: |
michael@0 | 116 | GrDebugGL::getInstance()->setPackRowLength(param); |
michael@0 | 117 | break; |
michael@0 | 118 | case GR_GL_UNPACK_ALIGNMENT: |
michael@0 | 119 | break; |
michael@0 | 120 | case GR_GL_PACK_ALIGNMENT: |
michael@0 | 121 | GrAlwaysAssert(false); |
michael@0 | 122 | break; |
michael@0 | 123 | default: |
michael@0 | 124 | GrAlwaysAssert(false); |
michael@0 | 125 | break; |
michael@0 | 126 | } |
michael@0 | 127 | } |
michael@0 | 128 | |
michael@0 | 129 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLReadPixels(GrGLint x, |
michael@0 | 130 | GrGLint y, |
michael@0 | 131 | GrGLsizei width, |
michael@0 | 132 | GrGLsizei height, |
michael@0 | 133 | GrGLenum format, |
michael@0 | 134 | GrGLenum type, |
michael@0 | 135 | GrGLvoid* pixels) { |
michael@0 | 136 | |
michael@0 | 137 | GrGLint pixelsInRow = width; |
michael@0 | 138 | if (0 < GrDebugGL::getInstance()->getPackRowLength()) { |
michael@0 | 139 | pixelsInRow = GrDebugGL::getInstance()->getPackRowLength(); |
michael@0 | 140 | } |
michael@0 | 141 | |
michael@0 | 142 | GrGLint componentsPerPixel = 0; |
michael@0 | 143 | |
michael@0 | 144 | switch (format) { |
michael@0 | 145 | case GR_GL_RGBA: |
michael@0 | 146 | // fallthrough |
michael@0 | 147 | case GR_GL_BGRA: |
michael@0 | 148 | componentsPerPixel = 4; |
michael@0 | 149 | break; |
michael@0 | 150 | case GR_GL_RGB: |
michael@0 | 151 | componentsPerPixel = 3; |
michael@0 | 152 | break; |
michael@0 | 153 | case GR_GL_RED: |
michael@0 | 154 | componentsPerPixel = 1; |
michael@0 | 155 | break; |
michael@0 | 156 | default: |
michael@0 | 157 | GrAlwaysAssert(false); |
michael@0 | 158 | break; |
michael@0 | 159 | } |
michael@0 | 160 | |
michael@0 | 161 | GrGLint alignment = 4; // the pack alignment (one of 1, 2, 4 or 8) |
michael@0 | 162 | // Ganesh currently doesn't support setting GR_GL_PACK_ALIGNMENT |
michael@0 | 163 | |
michael@0 | 164 | GrGLint componentSize = 0; // size (in bytes) of a single component |
michael@0 | 165 | |
michael@0 | 166 | switch (type) { |
michael@0 | 167 | case GR_GL_UNSIGNED_BYTE: |
michael@0 | 168 | componentSize = 1; |
michael@0 | 169 | break; |
michael@0 | 170 | default: |
michael@0 | 171 | GrAlwaysAssert(false); |
michael@0 | 172 | break; |
michael@0 | 173 | } |
michael@0 | 174 | |
michael@0 | 175 | GrGLint rowStride = 0; // number of components (not bytes) to skip |
michael@0 | 176 | if (componentSize >= alignment) { |
michael@0 | 177 | rowStride = componentsPerPixel * pixelsInRow; |
michael@0 | 178 | } else { |
michael@0 | 179 | float fTemp = |
michael@0 | 180 | sk_float_ceil(componentSize * componentsPerPixel * pixelsInRow / |
michael@0 | 181 | static_cast<float>(alignment)); |
michael@0 | 182 | rowStride = static_cast<GrGLint>(alignment * fTemp / componentSize); |
michael@0 | 183 | } |
michael@0 | 184 | |
michael@0 | 185 | GrGLchar *scanline = static_cast<GrGLchar *>(pixels); |
michael@0 | 186 | for (int y = 0; y < height; ++y) { |
michael@0 | 187 | memset(scanline, 0, componentsPerPixel * componentSize * width); |
michael@0 | 188 | scanline += rowStride; |
michael@0 | 189 | } |
michael@0 | 190 | } |
michael@0 | 191 | |
michael@0 | 192 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLUseProgram(GrGLuint programID) { |
michael@0 | 193 | |
michael@0 | 194 | // A programID of 0 is legal |
michael@0 | 195 | GrProgramObj *program = GR_FIND(programID, |
michael@0 | 196 | GrProgramObj, |
michael@0 | 197 | GrDebugGL::kProgram_ObjTypes); |
michael@0 | 198 | |
michael@0 | 199 | GrDebugGL::getInstance()->useProgram(program); |
michael@0 | 200 | } |
michael@0 | 201 | |
michael@0 | 202 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindFramebuffer(GrGLenum target, |
michael@0 | 203 | GrGLuint frameBufferID) { |
michael@0 | 204 | |
michael@0 | 205 | GrAlwaysAssert(GR_GL_FRAMEBUFFER == target || |
michael@0 | 206 | GR_GL_READ_FRAMEBUFFER == target || |
michael@0 | 207 | GR_GL_DRAW_FRAMEBUFFER); |
michael@0 | 208 | |
michael@0 | 209 | // a frameBufferID of 0 is acceptable - it binds to the default |
michael@0 | 210 | // frame buffer |
michael@0 | 211 | GrFrameBufferObj *frameBuffer = GR_FIND(frameBufferID, |
michael@0 | 212 | GrFrameBufferObj, |
michael@0 | 213 | GrDebugGL::kFrameBuffer_ObjTypes); |
michael@0 | 214 | |
michael@0 | 215 | GrDebugGL::getInstance()->setFrameBuffer(frameBuffer); |
michael@0 | 216 | } |
michael@0 | 217 | |
michael@0 | 218 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindRenderbuffer(GrGLenum target, GrGLuint renderBufferID) { |
michael@0 | 219 | |
michael@0 | 220 | GrAlwaysAssert(GR_GL_RENDERBUFFER == target); |
michael@0 | 221 | |
michael@0 | 222 | // a renderBufferID of 0 is acceptable - it unbinds the bound render buffer |
michael@0 | 223 | GrRenderBufferObj *renderBuffer = GR_FIND(renderBufferID, |
michael@0 | 224 | GrRenderBufferObj, |
michael@0 | 225 | GrDebugGL::kRenderBuffer_ObjTypes); |
michael@0 | 226 | |
michael@0 | 227 | GrDebugGL::getInstance()->setRenderBuffer(renderBuffer); |
michael@0 | 228 | } |
michael@0 | 229 | |
michael@0 | 230 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteTextures(GrGLsizei n, const GrGLuint* textures) { |
michael@0 | 231 | |
michael@0 | 232 | // first potentially unbind the texture |
michael@0 | 233 | // TODO: move this into GrDebugGL as unBindTexture? |
michael@0 | 234 | for (unsigned int i = 0; |
michael@0 | 235 | i < GrDebugGL::getInstance()->getMaxTextureUnits(); |
michael@0 | 236 | ++i) { |
michael@0 | 237 | GrTextureUnitObj *pTU = GrDebugGL::getInstance()->getTextureUnit(i); |
michael@0 | 238 | |
michael@0 | 239 | if (pTU->getTexture()) { |
michael@0 | 240 | for (int j = 0; j < n; ++j) { |
michael@0 | 241 | |
michael@0 | 242 | if (textures[j] == pTU->getTexture()->getID()) { |
michael@0 | 243 | // this ID is the current texture - revert the binding to 0 |
michael@0 | 244 | pTU->setTexture(NULL); |
michael@0 | 245 | } |
michael@0 | 246 | } |
michael@0 | 247 | } |
michael@0 | 248 | } |
michael@0 | 249 | |
michael@0 | 250 | // TODO: fuse the following block with DeleteRenderBuffers? |
michael@0 | 251 | // Open GL will remove a deleted render buffer from the active |
michael@0 | 252 | // frame buffer but not from any other frame buffer |
michael@0 | 253 | if (GrDebugGL::getInstance()->getFrameBuffer()) { |
michael@0 | 254 | |
michael@0 | 255 | GrFrameBufferObj *frameBuffer = GrDebugGL::getInstance()->getFrameBuffer(); |
michael@0 | 256 | |
michael@0 | 257 | for (int i = 0; i < n; ++i) { |
michael@0 | 258 | |
michael@0 | 259 | if (NULL != frameBuffer->getColor() && |
michael@0 | 260 | textures[i] == frameBuffer->getColor()->getID()) { |
michael@0 | 261 | frameBuffer->setColor(NULL); |
michael@0 | 262 | } |
michael@0 | 263 | if (NULL != frameBuffer->getDepth() && |
michael@0 | 264 | textures[i] == frameBuffer->getDepth()->getID()) { |
michael@0 | 265 | frameBuffer->setDepth(NULL); |
michael@0 | 266 | } |
michael@0 | 267 | if (NULL != frameBuffer->getStencil() && |
michael@0 | 268 | textures[i] == frameBuffer->getStencil()->getID()) { |
michael@0 | 269 | frameBuffer->setStencil(NULL); |
michael@0 | 270 | } |
michael@0 | 271 | } |
michael@0 | 272 | } |
michael@0 | 273 | |
michael@0 | 274 | // then actually "delete" the buffers |
michael@0 | 275 | for (int i = 0; i < n; ++i) { |
michael@0 | 276 | GrTextureObj *buffer = GR_FIND(textures[i], |
michael@0 | 277 | GrTextureObj, |
michael@0 | 278 | GrDebugGL::kTexture_ObjTypes); |
michael@0 | 279 | GrAlwaysAssert(buffer); |
michael@0 | 280 | |
michael@0 | 281 | // OpenGL gives no guarantees if a texture is deleted while attached to |
michael@0 | 282 | // something other than the currently bound frame buffer |
michael@0 | 283 | GrAlwaysAssert(!buffer->getBound()); |
michael@0 | 284 | |
michael@0 | 285 | GrAlwaysAssert(!buffer->getDeleted()); |
michael@0 | 286 | buffer->deleteAction(); |
michael@0 | 287 | } |
michael@0 | 288 | |
michael@0 | 289 | } |
michael@0 | 290 | |
michael@0 | 291 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteFramebuffers(GrGLsizei n, |
michael@0 | 292 | const GrGLuint *frameBuffers) { |
michael@0 | 293 | |
michael@0 | 294 | // first potentially unbind the buffers |
michael@0 | 295 | if (GrDebugGL::getInstance()->getFrameBuffer()) { |
michael@0 | 296 | for (int i = 0; i < n; ++i) { |
michael@0 | 297 | |
michael@0 | 298 | if (frameBuffers[i] == |
michael@0 | 299 | GrDebugGL::getInstance()->getFrameBuffer()->getID()) { |
michael@0 | 300 | // this ID is the current frame buffer - rebind to the default |
michael@0 | 301 | GrDebugGL::getInstance()->setFrameBuffer(NULL); |
michael@0 | 302 | } |
michael@0 | 303 | } |
michael@0 | 304 | } |
michael@0 | 305 | |
michael@0 | 306 | // then actually "delete" the buffers |
michael@0 | 307 | for (int i = 0; i < n; ++i) { |
michael@0 | 308 | GrFrameBufferObj *buffer = GR_FIND(frameBuffers[i], |
michael@0 | 309 | GrFrameBufferObj, |
michael@0 | 310 | GrDebugGL::kFrameBuffer_ObjTypes); |
michael@0 | 311 | GrAlwaysAssert(buffer); |
michael@0 | 312 | |
michael@0 | 313 | GrAlwaysAssert(!buffer->getDeleted()); |
michael@0 | 314 | buffer->deleteAction(); |
michael@0 | 315 | } |
michael@0 | 316 | } |
michael@0 | 317 | |
michael@0 | 318 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteRenderbuffers(GrGLsizei n, |
michael@0 | 319 | const GrGLuint *renderBuffers) { |
michael@0 | 320 | |
michael@0 | 321 | // first potentially unbind the buffers |
michael@0 | 322 | if (GrDebugGL::getInstance()->getRenderBuffer()) { |
michael@0 | 323 | for (int i = 0; i < n; ++i) { |
michael@0 | 324 | |
michael@0 | 325 | if (renderBuffers[i] == |
michael@0 | 326 | GrDebugGL::getInstance()->getRenderBuffer()->getID()) { |
michael@0 | 327 | // this ID is the current render buffer - make no |
michael@0 | 328 | // render buffer be bound |
michael@0 | 329 | GrDebugGL::getInstance()->setRenderBuffer(NULL); |
michael@0 | 330 | } |
michael@0 | 331 | } |
michael@0 | 332 | } |
michael@0 | 333 | |
michael@0 | 334 | // TODO: fuse the following block with DeleteTextures? |
michael@0 | 335 | // Open GL will remove a deleted render buffer from the active frame |
michael@0 | 336 | // buffer but not from any other frame buffer |
michael@0 | 337 | if (GrDebugGL::getInstance()->getFrameBuffer()) { |
michael@0 | 338 | |
michael@0 | 339 | GrFrameBufferObj *frameBuffer = |
michael@0 | 340 | GrDebugGL::getInstance()->getFrameBuffer(); |
michael@0 | 341 | |
michael@0 | 342 | for (int i = 0; i < n; ++i) { |
michael@0 | 343 | |
michael@0 | 344 | if (NULL != frameBuffer->getColor() && |
michael@0 | 345 | renderBuffers[i] == frameBuffer->getColor()->getID()) { |
michael@0 | 346 | frameBuffer->setColor(NULL); |
michael@0 | 347 | } |
michael@0 | 348 | if (NULL != frameBuffer->getDepth() && |
michael@0 | 349 | renderBuffers[i] == frameBuffer->getDepth()->getID()) { |
michael@0 | 350 | frameBuffer->setDepth(NULL); |
michael@0 | 351 | } |
michael@0 | 352 | if (NULL != frameBuffer->getStencil() && |
michael@0 | 353 | renderBuffers[i] == frameBuffer->getStencil()->getID()) { |
michael@0 | 354 | frameBuffer->setStencil(NULL); |
michael@0 | 355 | } |
michael@0 | 356 | } |
michael@0 | 357 | } |
michael@0 | 358 | |
michael@0 | 359 | // then actually "delete" the buffers |
michael@0 | 360 | for (int i = 0; i < n; ++i) { |
michael@0 | 361 | GrRenderBufferObj *buffer = GR_FIND(renderBuffers[i], |
michael@0 | 362 | GrRenderBufferObj, |
michael@0 | 363 | GrDebugGL::kRenderBuffer_ObjTypes); |
michael@0 | 364 | GrAlwaysAssert(buffer); |
michael@0 | 365 | |
michael@0 | 366 | // OpenGL gives no guarantees if a render buffer is deleted |
michael@0 | 367 | // while attached to something other than the currently |
michael@0 | 368 | // bound frame buffer |
michael@0 | 369 | GrAlwaysAssert(!buffer->getColorBound()); |
michael@0 | 370 | GrAlwaysAssert(!buffer->getDepthBound()); |
michael@0 | 371 | // However, at GrContext destroy time we release all GrRsources and so stencil buffers |
michael@0 | 372 | // may get deleted before FBOs that refer to them. |
michael@0 | 373 | //GrAlwaysAssert(!buffer->getStencilBound()); |
michael@0 | 374 | |
michael@0 | 375 | GrAlwaysAssert(!buffer->getDeleted()); |
michael@0 | 376 | buffer->deleteAction(); |
michael@0 | 377 | } |
michael@0 | 378 | } |
michael@0 | 379 | |
michael@0 | 380 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLFramebufferRenderbuffer(GrGLenum target, |
michael@0 | 381 | GrGLenum attachment, |
michael@0 | 382 | GrGLenum renderbuffertarget, |
michael@0 | 383 | GrGLuint renderBufferID) { |
michael@0 | 384 | |
michael@0 | 385 | GrAlwaysAssert(GR_GL_FRAMEBUFFER == target); |
michael@0 | 386 | GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment || |
michael@0 | 387 | GR_GL_DEPTH_ATTACHMENT == attachment || |
michael@0 | 388 | GR_GL_STENCIL_ATTACHMENT == attachment); |
michael@0 | 389 | GrAlwaysAssert(GR_GL_RENDERBUFFER == renderbuffertarget); |
michael@0 | 390 | |
michael@0 | 391 | GrFrameBufferObj *framebuffer = GrDebugGL::getInstance()->getFrameBuffer(); |
michael@0 | 392 | // A render buffer cannot be attached to the default framebuffer |
michael@0 | 393 | GrAlwaysAssert(NULL != framebuffer); |
michael@0 | 394 | |
michael@0 | 395 | // a renderBufferID of 0 is acceptable - it unbinds the current |
michael@0 | 396 | // render buffer |
michael@0 | 397 | GrRenderBufferObj *renderbuffer = GR_FIND(renderBufferID, |
michael@0 | 398 | GrRenderBufferObj, |
michael@0 | 399 | GrDebugGL::kRenderBuffer_ObjTypes); |
michael@0 | 400 | |
michael@0 | 401 | switch (attachment) { |
michael@0 | 402 | case GR_GL_COLOR_ATTACHMENT0: |
michael@0 | 403 | framebuffer->setColor(renderbuffer); |
michael@0 | 404 | break; |
michael@0 | 405 | case GR_GL_DEPTH_ATTACHMENT: |
michael@0 | 406 | framebuffer->setDepth(renderbuffer); |
michael@0 | 407 | break; |
michael@0 | 408 | case GR_GL_STENCIL_ATTACHMENT: |
michael@0 | 409 | framebuffer->setStencil(renderbuffer); |
michael@0 | 410 | break; |
michael@0 | 411 | default: |
michael@0 | 412 | GrAlwaysAssert(false); |
michael@0 | 413 | break; |
michael@0 | 414 | }; |
michael@0 | 415 | |
michael@0 | 416 | } |
michael@0 | 417 | |
michael@0 | 418 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 419 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLFramebufferTexture2D(GrGLenum target, |
michael@0 | 420 | GrGLenum attachment, |
michael@0 | 421 | GrGLenum textarget, |
michael@0 | 422 | GrGLuint textureID, |
michael@0 | 423 | GrGLint level) { |
michael@0 | 424 | |
michael@0 | 425 | GrAlwaysAssert(GR_GL_FRAMEBUFFER == target); |
michael@0 | 426 | GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment || |
michael@0 | 427 | GR_GL_DEPTH_ATTACHMENT == attachment || |
michael@0 | 428 | GR_GL_STENCIL_ATTACHMENT == attachment); |
michael@0 | 429 | GrAlwaysAssert(GR_GL_TEXTURE_2D == textarget); |
michael@0 | 430 | |
michael@0 | 431 | GrFrameBufferObj *framebuffer = GrDebugGL::getInstance()->getFrameBuffer(); |
michael@0 | 432 | // A texture cannot be attached to the default framebuffer |
michael@0 | 433 | GrAlwaysAssert(NULL != framebuffer); |
michael@0 | 434 | |
michael@0 | 435 | // A textureID of 0 is allowed - it unbinds the currently bound texture |
michael@0 | 436 | GrTextureObj *texture = GR_FIND(textureID, GrTextureObj, |
michael@0 | 437 | GrDebugGL::kTexture_ObjTypes); |
michael@0 | 438 | if (texture) { |
michael@0 | 439 | // The texture shouldn't be bound to a texture unit - this |
michael@0 | 440 | // could lead to a feedback loop |
michael@0 | 441 | GrAlwaysAssert(!texture->getBound()); |
michael@0 | 442 | } |
michael@0 | 443 | |
michael@0 | 444 | GrAlwaysAssert(0 == level); |
michael@0 | 445 | |
michael@0 | 446 | switch (attachment) { |
michael@0 | 447 | case GR_GL_COLOR_ATTACHMENT0: |
michael@0 | 448 | framebuffer->setColor(texture); |
michael@0 | 449 | break; |
michael@0 | 450 | case GR_GL_DEPTH_ATTACHMENT: |
michael@0 | 451 | framebuffer->setDepth(texture); |
michael@0 | 452 | break; |
michael@0 | 453 | case GR_GL_STENCIL_ATTACHMENT: |
michael@0 | 454 | framebuffer->setStencil(texture); |
michael@0 | 455 | break; |
michael@0 | 456 | default: |
michael@0 | 457 | GrAlwaysAssert(false); |
michael@0 | 458 | break; |
michael@0 | 459 | }; |
michael@0 | 460 | } |
michael@0 | 461 | |
michael@0 | 462 | GrGLuint GR_GL_FUNCTION_TYPE debugGLCreateProgram() { |
michael@0 | 463 | |
michael@0 | 464 | GrProgramObj *program = GR_CREATE(GrProgramObj, |
michael@0 | 465 | GrDebugGL::kProgram_ObjTypes); |
michael@0 | 466 | |
michael@0 | 467 | return program->getID(); |
michael@0 | 468 | } |
michael@0 | 469 | |
michael@0 | 470 | GrGLuint GR_GL_FUNCTION_TYPE debugGLCreateShader(GrGLenum type) { |
michael@0 | 471 | |
michael@0 | 472 | GrAlwaysAssert(GR_GL_VERTEX_SHADER == type || |
michael@0 | 473 | GR_GL_FRAGMENT_SHADER == type); |
michael@0 | 474 | |
michael@0 | 475 | GrShaderObj *shader = GR_CREATE(GrShaderObj, GrDebugGL::kShader_ObjTypes); |
michael@0 | 476 | shader->setType(type); |
michael@0 | 477 | |
michael@0 | 478 | return shader->getID(); |
michael@0 | 479 | } |
michael@0 | 480 | |
michael@0 | 481 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteProgram(GrGLuint programID) { |
michael@0 | 482 | |
michael@0 | 483 | GrProgramObj *program = GR_FIND(programID, |
michael@0 | 484 | GrProgramObj, |
michael@0 | 485 | GrDebugGL::kProgram_ObjTypes); |
michael@0 | 486 | GrAlwaysAssert(program); |
michael@0 | 487 | |
michael@0 | 488 | if (program->getRefCount()) { |
michael@0 | 489 | // someone is still using this program so we can't delete it here |
michael@0 | 490 | program->setMarkedForDeletion(); |
michael@0 | 491 | } else { |
michael@0 | 492 | program->deleteAction(); |
michael@0 | 493 | } |
michael@0 | 494 | } |
michael@0 | 495 | |
michael@0 | 496 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteShader(GrGLuint shaderID) { |
michael@0 | 497 | |
michael@0 | 498 | GrShaderObj *shader = GR_FIND(shaderID, |
michael@0 | 499 | GrShaderObj, |
michael@0 | 500 | GrDebugGL::kShader_ObjTypes); |
michael@0 | 501 | GrAlwaysAssert(shader); |
michael@0 | 502 | |
michael@0 | 503 | if (shader->getRefCount()) { |
michael@0 | 504 | // someone is still using this shader so we can't delete it here |
michael@0 | 505 | shader->setMarkedForDeletion(); |
michael@0 | 506 | } else { |
michael@0 | 507 | shader->deleteAction(); |
michael@0 | 508 | } |
michael@0 | 509 | } |
michael@0 | 510 | |
michael@0 | 511 | GrGLvoid debugGenObjs(GrDebugGL::GrObjTypes type, |
michael@0 | 512 | GrGLsizei n, |
michael@0 | 513 | GrGLuint* ids) { |
michael@0 | 514 | |
michael@0 | 515 | for (int i = 0; i < n; ++i) { |
michael@0 | 516 | GrFakeRefObj *obj = GrDebugGL::getInstance()->createObj(type); |
michael@0 | 517 | GrAlwaysAssert(obj); |
michael@0 | 518 | ids[i] = obj->getID(); |
michael@0 | 519 | } |
michael@0 | 520 | } |
michael@0 | 521 | |
michael@0 | 522 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenBuffers(GrGLsizei n, GrGLuint* ids) { |
michael@0 | 523 | debugGenObjs(GrDebugGL::kBuffer_ObjTypes, n, ids); |
michael@0 | 524 | } |
michael@0 | 525 | |
michael@0 | 526 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenerateMipmap(GrGLenum level) { |
michael@0 | 527 | } |
michael@0 | 528 | |
michael@0 | 529 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenFramebuffers(GrGLsizei n, |
michael@0 | 530 | GrGLuint* ids) { |
michael@0 | 531 | debugGenObjs(GrDebugGL::kFrameBuffer_ObjTypes, n, ids); |
michael@0 | 532 | } |
michael@0 | 533 | |
michael@0 | 534 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenRenderbuffers(GrGLsizei n, |
michael@0 | 535 | GrGLuint* ids) { |
michael@0 | 536 | debugGenObjs(GrDebugGL::kRenderBuffer_ObjTypes, n, ids); |
michael@0 | 537 | } |
michael@0 | 538 | |
michael@0 | 539 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenTextures(GrGLsizei n, GrGLuint* ids) { |
michael@0 | 540 | debugGenObjs(GrDebugGL::kTexture_ObjTypes, n, ids); |
michael@0 | 541 | } |
michael@0 | 542 | |
michael@0 | 543 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGenVertexArrays(GrGLsizei n, GrGLuint* ids) { |
michael@0 | 544 | debugGenObjs(GrDebugGL::kVertexArray_ObjTypes, n, ids); |
michael@0 | 545 | } |
michael@0 | 546 | |
michael@0 | 547 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteVertexArrays(GrGLsizei n, const GrGLuint* ids) { |
michael@0 | 548 | for (GrGLsizei i = 0; i < n; ++i) { |
michael@0 | 549 | GrVertexArrayObj* array = |
michael@0 | 550 | GR_FIND(ids[i], GrVertexArrayObj, GrDebugGL::kVertexArray_ObjTypes); |
michael@0 | 551 | GrAlwaysAssert(array); |
michael@0 | 552 | |
michael@0 | 553 | // Deleting the current vertex array binds object 0 |
michael@0 | 554 | if (GrDebugGL::getInstance()->getVertexArray() == array) { |
michael@0 | 555 | GrDebugGL::getInstance()->setVertexArray(NULL); |
michael@0 | 556 | } |
michael@0 | 557 | |
michael@0 | 558 | if (array->getRefCount()) { |
michael@0 | 559 | // someone is still using this vertex array so we can't delete it here |
michael@0 | 560 | array->setMarkedForDeletion(); |
michael@0 | 561 | } else { |
michael@0 | 562 | array->deleteAction(); |
michael@0 | 563 | } |
michael@0 | 564 | } |
michael@0 | 565 | } |
michael@0 | 566 | |
michael@0 | 567 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindVertexArray(GrGLuint id) { |
michael@0 | 568 | GrVertexArrayObj* array = GR_FIND(id, GrVertexArrayObj, GrDebugGL::kVertexArray_ObjTypes); |
michael@0 | 569 | GrAlwaysAssert((0 == id) || NULL != array); |
michael@0 | 570 | GrDebugGL::getInstance()->setVertexArray(array); |
michael@0 | 571 | } |
michael@0 | 572 | |
michael@0 | 573 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindBuffer(GrGLenum target, GrGLuint bufferID) { |
michael@0 | 574 | GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || GR_GL_ELEMENT_ARRAY_BUFFER == target); |
michael@0 | 575 | |
michael@0 | 576 | GrBufferObj *buffer = GR_FIND(bufferID, |
michael@0 | 577 | GrBufferObj, |
michael@0 | 578 | GrDebugGL::kBuffer_ObjTypes); |
michael@0 | 579 | // 0 is a permissible bufferID - it unbinds the current buffer |
michael@0 | 580 | |
michael@0 | 581 | switch (target) { |
michael@0 | 582 | case GR_GL_ARRAY_BUFFER: |
michael@0 | 583 | GrDebugGL::getInstance()->setArrayBuffer(buffer); |
michael@0 | 584 | break; |
michael@0 | 585 | case GR_GL_ELEMENT_ARRAY_BUFFER: |
michael@0 | 586 | GrDebugGL::getInstance()->setElementArrayBuffer(buffer); |
michael@0 | 587 | break; |
michael@0 | 588 | default: |
michael@0 | 589 | GrCrash("Unexpected target to glBindBuffer"); |
michael@0 | 590 | break; |
michael@0 | 591 | } |
michael@0 | 592 | } |
michael@0 | 593 | |
michael@0 | 594 | // deleting a bound buffer has the side effect of binding 0 |
michael@0 | 595 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteBuffers(GrGLsizei n, const GrGLuint* ids) { |
michael@0 | 596 | // first potentially unbind the buffers |
michael@0 | 597 | for (int i = 0; i < n; ++i) { |
michael@0 | 598 | |
michael@0 | 599 | if (GrDebugGL::getInstance()->getArrayBuffer() && |
michael@0 | 600 | ids[i] == GrDebugGL::getInstance()->getArrayBuffer()->getID()) { |
michael@0 | 601 | // this ID is the current array buffer |
michael@0 | 602 | GrDebugGL::getInstance()->setArrayBuffer(NULL); |
michael@0 | 603 | } |
michael@0 | 604 | if (GrDebugGL::getInstance()->getElementArrayBuffer() && |
michael@0 | 605 | ids[i] == |
michael@0 | 606 | GrDebugGL::getInstance()->getElementArrayBuffer()->getID()) { |
michael@0 | 607 | // this ID is the current element array buffer |
michael@0 | 608 | GrDebugGL::getInstance()->setElementArrayBuffer(NULL); |
michael@0 | 609 | } |
michael@0 | 610 | } |
michael@0 | 611 | |
michael@0 | 612 | // then actually "delete" the buffers |
michael@0 | 613 | for (int i = 0; i < n; ++i) { |
michael@0 | 614 | GrBufferObj *buffer = GR_FIND(ids[i], |
michael@0 | 615 | GrBufferObj, |
michael@0 | 616 | GrDebugGL::kBuffer_ObjTypes); |
michael@0 | 617 | GrAlwaysAssert(buffer); |
michael@0 | 618 | |
michael@0 | 619 | GrAlwaysAssert(!buffer->getDeleted()); |
michael@0 | 620 | buffer->deleteAction(); |
michael@0 | 621 | } |
michael@0 | 622 | } |
michael@0 | 623 | |
michael@0 | 624 | // map a buffer to the caller's address space |
michael@0 | 625 | GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBuffer(GrGLenum target, GrGLenum access) { |
michael@0 | 626 | |
michael@0 | 627 | GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || |
michael@0 | 628 | GR_GL_ELEMENT_ARRAY_BUFFER == target); |
michael@0 | 629 | // GR_GL_READ_ONLY == access || || GR_GL_READ_WRIT == access); |
michael@0 | 630 | GrAlwaysAssert(GR_GL_WRITE_ONLY == access); |
michael@0 | 631 | |
michael@0 | 632 | GrBufferObj *buffer = NULL; |
michael@0 | 633 | switch (target) { |
michael@0 | 634 | case GR_GL_ARRAY_BUFFER: |
michael@0 | 635 | buffer = GrDebugGL::getInstance()->getArrayBuffer(); |
michael@0 | 636 | break; |
michael@0 | 637 | case GR_GL_ELEMENT_ARRAY_BUFFER: |
michael@0 | 638 | buffer = GrDebugGL::getInstance()->getElementArrayBuffer(); |
michael@0 | 639 | break; |
michael@0 | 640 | default: |
michael@0 | 641 | GrCrash("Unexpected target to glMapBuffer"); |
michael@0 | 642 | break; |
michael@0 | 643 | } |
michael@0 | 644 | |
michael@0 | 645 | if (buffer) { |
michael@0 | 646 | GrAlwaysAssert(!buffer->getMapped()); |
michael@0 | 647 | buffer->setMapped(); |
michael@0 | 648 | return buffer->getDataPtr(); |
michael@0 | 649 | } |
michael@0 | 650 | |
michael@0 | 651 | GrAlwaysAssert(false); |
michael@0 | 652 | return NULL; // no buffer bound to the target |
michael@0 | 653 | } |
michael@0 | 654 | |
michael@0 | 655 | // remove a buffer from the caller's address space |
michael@0 | 656 | // TODO: check if the "access" method from "glMapBuffer" was honored |
michael@0 | 657 | GrGLboolean GR_GL_FUNCTION_TYPE debugGLUnmapBuffer(GrGLenum target) { |
michael@0 | 658 | |
michael@0 | 659 | GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || |
michael@0 | 660 | GR_GL_ELEMENT_ARRAY_BUFFER == target); |
michael@0 | 661 | |
michael@0 | 662 | GrBufferObj *buffer = NULL; |
michael@0 | 663 | switch (target) { |
michael@0 | 664 | case GR_GL_ARRAY_BUFFER: |
michael@0 | 665 | buffer = GrDebugGL::getInstance()->getArrayBuffer(); |
michael@0 | 666 | break; |
michael@0 | 667 | case GR_GL_ELEMENT_ARRAY_BUFFER: |
michael@0 | 668 | buffer = GrDebugGL::getInstance()->getElementArrayBuffer(); |
michael@0 | 669 | break; |
michael@0 | 670 | default: |
michael@0 | 671 | GrCrash("Unexpected target to glUnmapBuffer"); |
michael@0 | 672 | break; |
michael@0 | 673 | } |
michael@0 | 674 | |
michael@0 | 675 | if (buffer) { |
michael@0 | 676 | GrAlwaysAssert(buffer->getMapped()); |
michael@0 | 677 | buffer->resetMapped(); |
michael@0 | 678 | return GR_GL_TRUE; |
michael@0 | 679 | } |
michael@0 | 680 | |
michael@0 | 681 | GrAlwaysAssert(false); |
michael@0 | 682 | return GR_GL_FALSE; // GR_GL_INVALID_OPERATION; |
michael@0 | 683 | } |
michael@0 | 684 | |
michael@0 | 685 | GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetBufferParameteriv(GrGLenum target, |
michael@0 | 686 | GrGLenum value, |
michael@0 | 687 | GrGLint* params) { |
michael@0 | 688 | |
michael@0 | 689 | GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || |
michael@0 | 690 | GR_GL_ELEMENT_ARRAY_BUFFER == target); |
michael@0 | 691 | GrAlwaysAssert(GR_GL_BUFFER_SIZE == value || |
michael@0 | 692 | GR_GL_BUFFER_USAGE == value); |
michael@0 | 693 | |
michael@0 | 694 | GrBufferObj *buffer = NULL; |
michael@0 | 695 | switch (target) { |
michael@0 | 696 | case GR_GL_ARRAY_BUFFER: |
michael@0 | 697 | buffer = GrDebugGL::getInstance()->getArrayBuffer(); |
michael@0 | 698 | break; |
michael@0 | 699 | case GR_GL_ELEMENT_ARRAY_BUFFER: |
michael@0 | 700 | buffer = GrDebugGL::getInstance()->getElementArrayBuffer(); |
michael@0 | 701 | break; |
michael@0 | 702 | } |
michael@0 | 703 | |
michael@0 | 704 | GrAlwaysAssert(buffer); |
michael@0 | 705 | |
michael@0 | 706 | switch (value) { |
michael@0 | 707 | case GR_GL_BUFFER_MAPPED: |
michael@0 | 708 | *params = GR_GL_FALSE; |
michael@0 | 709 | if (buffer) |
michael@0 | 710 | *params = buffer->getMapped() ? GR_GL_TRUE : GR_GL_FALSE; |
michael@0 | 711 | break; |
michael@0 | 712 | case GR_GL_BUFFER_SIZE: |
michael@0 | 713 | *params = 0; |
michael@0 | 714 | if (buffer) |
michael@0 | 715 | *params = buffer->getSize(); |
michael@0 | 716 | break; |
michael@0 | 717 | case GR_GL_BUFFER_USAGE: |
michael@0 | 718 | *params = GR_GL_STATIC_DRAW; |
michael@0 | 719 | if (buffer) |
michael@0 | 720 | *params = buffer->getUsage(); |
michael@0 | 721 | break; |
michael@0 | 722 | default: |
michael@0 | 723 | GrCrash("Unexpected value to glGetBufferParamateriv"); |
michael@0 | 724 | break; |
michael@0 | 725 | } |
michael@0 | 726 | }; |
michael@0 | 727 | } // end of namespace |
michael@0 | 728 | |
michael@0 | 729 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 730 | struct GrDebugGLInterface : public GrGLInterface { |
michael@0 | 731 | |
michael@0 | 732 | public: |
michael@0 | 733 | SK_DECLARE_INST_COUNT(GrDebugGLInterface) |
michael@0 | 734 | |
michael@0 | 735 | GrDebugGLInterface() |
michael@0 | 736 | : fWrapped(NULL) { |
michael@0 | 737 | GrDebugGL::staticRef(); |
michael@0 | 738 | } |
michael@0 | 739 | |
michael@0 | 740 | virtual ~GrDebugGLInterface() { |
michael@0 | 741 | GrDebugGL::staticUnRef(); |
michael@0 | 742 | } |
michael@0 | 743 | |
michael@0 | 744 | void setWrapped(GrGLInterface *interface) { |
michael@0 | 745 | fWrapped.reset(interface); |
michael@0 | 746 | } |
michael@0 | 747 | |
michael@0 | 748 | // TODO: there are some issues w/ wrapping another GL interface inside the |
michael@0 | 749 | // debug interface: |
michael@0 | 750 | // Since none of the "gl" methods are member functions they don't get |
michael@0 | 751 | // a "this" pointer through which to access "fWrapped" |
michael@0 | 752 | // This could be worked around by having all of them access the |
michael@0 | 753 | // "glInterface" pointer - i.e., treating the debug interface as a |
michael@0 | 754 | // true singleton |
michael@0 | 755 | // |
michael@0 | 756 | // The problem with this is that we also want to handle OpenGL |
michael@0 | 757 | // contexts. The natural way to do this is to have multiple debug |
michael@0 | 758 | // interfaces. Each of which represents a separate context. The |
michael@0 | 759 | // static ID count would still uniquify IDs across all of them. |
michael@0 | 760 | // The problem then is that we couldn't treat the debug GL |
michael@0 | 761 | // interface as a singleton (since there would be one for each |
michael@0 | 762 | // context). |
michael@0 | 763 | // |
michael@0 | 764 | // The solution to this is probably to alter SkDebugGlContext's |
michael@0 | 765 | // "makeCurrent" method to make a call like "makeCurrent(this)" to |
michael@0 | 766 | // the debug GL interface (assuming that the application will create |
michael@0 | 767 | // multiple SkGLContextHelper's) to let it switch between the active |
michael@0 | 768 | // context. Everything in the GrDebugGL object would then need to be |
michael@0 | 769 | // moved to a GrContextObj and the GrDebugGL object would just switch |
michael@0 | 770 | // between them. Note that this approach would also require that |
michael@0 | 771 | // SkDebugGLContext wrap an arbitrary other context |
michael@0 | 772 | // and then pass the wrapped interface to the debug GL interface. |
michael@0 | 773 | |
michael@0 | 774 | protected: |
michael@0 | 775 | private: |
michael@0 | 776 | |
michael@0 | 777 | SkAutoTUnref<GrGLInterface> fWrapped; |
michael@0 | 778 | |
michael@0 | 779 | typedef GrGLInterface INHERITED; |
michael@0 | 780 | }; |
michael@0 | 781 | |
michael@0 | 782 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 783 | const GrGLInterface* GrGLCreateDebugInterface() { |
michael@0 | 784 | GrGLInterface* interface = SkNEW(GrDebugGLInterface); |
michael@0 | 785 | |
michael@0 | 786 | interface->fStandard = kGL_GrGLStandard; |
michael@0 | 787 | |
michael@0 | 788 | GrGLInterface::Functions* functions = &interface->fFunctions; |
michael@0 | 789 | functions->fActiveTexture = debugGLActiveTexture; |
michael@0 | 790 | functions->fAttachShader = debugGLAttachShader; |
michael@0 | 791 | functions->fBeginQuery = debugGLBeginQuery; |
michael@0 | 792 | functions->fBindAttribLocation = debugGLBindAttribLocation; |
michael@0 | 793 | functions->fBindBuffer = debugGLBindBuffer; |
michael@0 | 794 | functions->fBindFragDataLocation = noOpGLBindFragDataLocation; |
michael@0 | 795 | functions->fBindTexture = debugGLBindTexture; |
michael@0 | 796 | functions->fBindVertexArray = debugGLBindVertexArray; |
michael@0 | 797 | functions->fBlendColor = noOpGLBlendColor; |
michael@0 | 798 | functions->fBlendFunc = noOpGLBlendFunc; |
michael@0 | 799 | functions->fBufferData = debugGLBufferData; |
michael@0 | 800 | functions->fBufferSubData = noOpGLBufferSubData; |
michael@0 | 801 | functions->fClear = noOpGLClear; |
michael@0 | 802 | functions->fClearColor = noOpGLClearColor; |
michael@0 | 803 | functions->fClearStencil = noOpGLClearStencil; |
michael@0 | 804 | functions->fColorMask = noOpGLColorMask; |
michael@0 | 805 | functions->fCompileShader = noOpGLCompileShader; |
michael@0 | 806 | functions->fCompressedTexImage2D = noOpGLCompressedTexImage2D; |
michael@0 | 807 | functions->fCopyTexSubImage2D = noOpGLCopyTexSubImage2D; |
michael@0 | 808 | functions->fCreateProgram = debugGLCreateProgram; |
michael@0 | 809 | functions->fCreateShader = debugGLCreateShader; |
michael@0 | 810 | functions->fCullFace = noOpGLCullFace; |
michael@0 | 811 | functions->fDeleteBuffers = debugGLDeleteBuffers; |
michael@0 | 812 | functions->fDeleteProgram = debugGLDeleteProgram; |
michael@0 | 813 | functions->fDeleteQueries = noOpGLDeleteIds; |
michael@0 | 814 | functions->fDeleteShader = debugGLDeleteShader; |
michael@0 | 815 | functions->fDeleteTextures = debugGLDeleteTextures; |
michael@0 | 816 | functions->fDeleteVertexArrays = debugGLDeleteVertexArrays; |
michael@0 | 817 | functions->fDepthMask = noOpGLDepthMask; |
michael@0 | 818 | functions->fDisable = noOpGLDisable; |
michael@0 | 819 | functions->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray; |
michael@0 | 820 | functions->fDrawArrays = noOpGLDrawArrays; |
michael@0 | 821 | functions->fDrawBuffer = noOpGLDrawBuffer; |
michael@0 | 822 | functions->fDrawBuffers = noOpGLDrawBuffers; |
michael@0 | 823 | functions->fDrawElements = noOpGLDrawElements; |
michael@0 | 824 | functions->fEnable = noOpGLEnable; |
michael@0 | 825 | functions->fEnableVertexAttribArray = noOpGLEnableVertexAttribArray; |
michael@0 | 826 | functions->fEndQuery = noOpGLEndQuery; |
michael@0 | 827 | functions->fFinish = noOpGLFinish; |
michael@0 | 828 | functions->fFlush = noOpGLFlush; |
michael@0 | 829 | functions->fFrontFace = noOpGLFrontFace; |
michael@0 | 830 | functions->fGenerateMipmap = debugGLGenerateMipmap; |
michael@0 | 831 | functions->fGenBuffers = debugGLGenBuffers; |
michael@0 | 832 | functions->fGenQueries = noOpGLGenIds; |
michael@0 | 833 | functions->fGenTextures = debugGLGenTextures; |
michael@0 | 834 | functions->fGetBufferParameteriv = debugGLGetBufferParameteriv; |
michael@0 | 835 | functions->fGetError = noOpGLGetError; |
michael@0 | 836 | functions->fGetIntegerv = noOpGLGetIntegerv; |
michael@0 | 837 | functions->fGetQueryObjecti64v = noOpGLGetQueryObjecti64v; |
michael@0 | 838 | functions->fGetQueryObjectiv = noOpGLGetQueryObjectiv; |
michael@0 | 839 | functions->fGetQueryObjectui64v = noOpGLGetQueryObjectui64v; |
michael@0 | 840 | functions->fGetQueryObjectuiv = noOpGLGetQueryObjectuiv; |
michael@0 | 841 | functions->fGetQueryiv = noOpGLGetQueryiv; |
michael@0 | 842 | functions->fGetProgramInfoLog = noOpGLGetInfoLog; |
michael@0 | 843 | functions->fGetProgramiv = noOpGLGetShaderOrProgramiv; |
michael@0 | 844 | functions->fGetShaderInfoLog = noOpGLGetInfoLog; |
michael@0 | 845 | functions->fGetShaderiv = noOpGLGetShaderOrProgramiv; |
michael@0 | 846 | functions->fGetString = noOpGLGetString; |
michael@0 | 847 | functions->fGetStringi = noOpGLGetStringi; |
michael@0 | 848 | functions->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv; |
michael@0 | 849 | functions->fGetUniformLocation = noOpGLGetUniformLocation; |
michael@0 | 850 | functions->fGenVertexArrays = debugGLGenVertexArrays; |
michael@0 | 851 | functions->fLoadIdentity = noOpGLLoadIdentity; |
michael@0 | 852 | functions->fLoadMatrixf = noOpGLLoadMatrixf; |
michael@0 | 853 | functions->fLineWidth = noOpGLLineWidth; |
michael@0 | 854 | functions->fLinkProgram = noOpGLLinkProgram; |
michael@0 | 855 | functions->fMatrixMode = noOpGLMatrixMode; |
michael@0 | 856 | functions->fPixelStorei = debugGLPixelStorei; |
michael@0 | 857 | functions->fQueryCounter = noOpGLQueryCounter; |
michael@0 | 858 | functions->fReadBuffer = noOpGLReadBuffer; |
michael@0 | 859 | functions->fReadPixels = debugGLReadPixels; |
michael@0 | 860 | functions->fScissor = noOpGLScissor; |
michael@0 | 861 | functions->fShaderSource = noOpGLShaderSource; |
michael@0 | 862 | functions->fStencilFunc = noOpGLStencilFunc; |
michael@0 | 863 | functions->fStencilFuncSeparate = noOpGLStencilFuncSeparate; |
michael@0 | 864 | functions->fStencilMask = noOpGLStencilMask; |
michael@0 | 865 | functions->fStencilMaskSeparate = noOpGLStencilMaskSeparate; |
michael@0 | 866 | functions->fStencilOp = noOpGLStencilOp; |
michael@0 | 867 | functions->fStencilOpSeparate = noOpGLStencilOpSeparate; |
michael@0 | 868 | functions->fTexGenfv = noOpGLTexGenfv; |
michael@0 | 869 | functions->fTexGeni = noOpGLTexGeni; |
michael@0 | 870 | functions->fTexImage2D = noOpGLTexImage2D; |
michael@0 | 871 | functions->fTexParameteri = noOpGLTexParameteri; |
michael@0 | 872 | functions->fTexParameteriv = noOpGLTexParameteriv; |
michael@0 | 873 | functions->fTexSubImage2D = noOpGLTexSubImage2D; |
michael@0 | 874 | functions->fTexStorage2D = noOpGLTexStorage2D; |
michael@0 | 875 | functions->fDiscardFramebuffer = noOpGLDiscardFramebuffer; |
michael@0 | 876 | functions->fUniform1f = noOpGLUniform1f; |
michael@0 | 877 | functions->fUniform1i = noOpGLUniform1i; |
michael@0 | 878 | functions->fUniform1fv = noOpGLUniform1fv; |
michael@0 | 879 | functions->fUniform1iv = noOpGLUniform1iv; |
michael@0 | 880 | functions->fUniform2f = noOpGLUniform2f; |
michael@0 | 881 | functions->fUniform2i = noOpGLUniform2i; |
michael@0 | 882 | functions->fUniform2fv = noOpGLUniform2fv; |
michael@0 | 883 | functions->fUniform2iv = noOpGLUniform2iv; |
michael@0 | 884 | functions->fUniform3f = noOpGLUniform3f; |
michael@0 | 885 | functions->fUniform3i = noOpGLUniform3i; |
michael@0 | 886 | functions->fUniform3fv = noOpGLUniform3fv; |
michael@0 | 887 | functions->fUniform3iv = noOpGLUniform3iv; |
michael@0 | 888 | functions->fUniform4f = noOpGLUniform4f; |
michael@0 | 889 | functions->fUniform4i = noOpGLUniform4i; |
michael@0 | 890 | functions->fUniform4fv = noOpGLUniform4fv; |
michael@0 | 891 | functions->fUniform4iv = noOpGLUniform4iv; |
michael@0 | 892 | functions->fUniformMatrix2fv = noOpGLUniformMatrix2fv; |
michael@0 | 893 | functions->fUniformMatrix3fv = noOpGLUniformMatrix3fv; |
michael@0 | 894 | functions->fUniformMatrix4fv = noOpGLUniformMatrix4fv; |
michael@0 | 895 | functions->fUseProgram = debugGLUseProgram; |
michael@0 | 896 | functions->fVertexAttrib4fv = noOpGLVertexAttrib4fv; |
michael@0 | 897 | functions->fVertexAttribPointer = noOpGLVertexAttribPointer; |
michael@0 | 898 | functions->fViewport = noOpGLViewport; |
michael@0 | 899 | functions->fBindFramebuffer = debugGLBindFramebuffer; |
michael@0 | 900 | functions->fBindRenderbuffer = debugGLBindRenderbuffer; |
michael@0 | 901 | functions->fCheckFramebufferStatus = noOpGLCheckFramebufferStatus; |
michael@0 | 902 | functions->fDeleteFramebuffers = debugGLDeleteFramebuffers; |
michael@0 | 903 | functions->fDeleteRenderbuffers = debugGLDeleteRenderbuffers; |
michael@0 | 904 | functions->fFramebufferRenderbuffer = debugGLFramebufferRenderbuffer; |
michael@0 | 905 | functions->fFramebufferTexture2D = debugGLFramebufferTexture2D; |
michael@0 | 906 | functions->fGenFramebuffers = debugGLGenFramebuffers; |
michael@0 | 907 | functions->fGenRenderbuffers = debugGLGenRenderbuffers; |
michael@0 | 908 | functions->fGetFramebufferAttachmentParameteriv = |
michael@0 | 909 | noOpGLGetFramebufferAttachmentParameteriv; |
michael@0 | 910 | functions->fGetRenderbufferParameteriv = noOpGLGetRenderbufferParameteriv; |
michael@0 | 911 | functions->fRenderbufferStorage = noOpGLRenderbufferStorage; |
michael@0 | 912 | functions->fRenderbufferStorageMultisample = |
michael@0 | 913 | noOpGLRenderbufferStorageMultisample; |
michael@0 | 914 | functions->fBlitFramebuffer = noOpGLBlitFramebuffer; |
michael@0 | 915 | functions->fResolveMultisampleFramebuffer = |
michael@0 | 916 | noOpGLResolveMultisampleFramebuffer; |
michael@0 | 917 | functions->fMapBuffer = debugGLMapBuffer; |
michael@0 | 918 | functions->fUnmapBuffer = debugGLUnmapBuffer; |
michael@0 | 919 | functions->fBindFragDataLocationIndexed = |
michael@0 | 920 | noOpGLBindFragDataLocationIndexed; |
michael@0 | 921 | |
michael@0 | 922 | interface->fExtensions.init(kGL_GrGLStandard, functions->fGetString, functions->fGetStringi, |
michael@0 | 923 | functions->fGetIntegerv); |
michael@0 | 924 | |
michael@0 | 925 | return interface; |
michael@0 | 926 | } |