OLD | NEW |
| 1 |
1 /* | 2 /* |
2 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
3 * | 4 * |
4 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 6 * found in the LICENSE file. |
6 */ | 7 */ |
7 | 8 |
8 | 9 #include "DebugGLContext.h" |
9 #include "gl/GrGLInterface.h" | |
10 | 10 |
11 #include "GrBufferObj.h" | 11 #include "GrBufferObj.h" |
12 #include "GrFrameBufferObj.h" | 12 #include "GrFrameBufferObj.h" |
13 #include "GrProgramObj.h" | 13 #include "GrProgramObj.h" |
14 #include "GrRenderBufferObj.h" | 14 #include "GrRenderBufferObj.h" |
15 #include "GrShaderObj.h" | 15 #include "GrShaderObj.h" |
16 #include "GrTextureObj.h" | 16 #include "GrTextureObj.h" |
17 #include "GrTextureUnitObj.h" | 17 #include "GrTextureUnitObj.h" |
18 #include "GrVertexArrayObj.h" | 18 #include "GrVertexArrayObj.h" |
19 #include "gl/GrGLTestInterface.h" | 19 #include "gl/GrGLTestInterface.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 rowStride = static_cast<GrGLint>(alignment * fTemp / componentSize); | 210 rowStride = static_cast<GrGLint>(alignment * fTemp / componentSize); |
211 } | 211 } |
212 | 212 |
213 GrGLchar *scanline = static_cast<GrGLchar *>(pixels); | 213 GrGLchar *scanline = static_cast<GrGLchar *>(pixels); |
214 for (int y = 0; y < height; ++y) { | 214 for (int y = 0; y < height; ++y) { |
215 memset(scanline, 0, componentsPerPixel * componentSize * width); | 215 memset(scanline, 0, componentsPerPixel * componentSize * width); |
216 scanline += rowStride; | 216 scanline += rowStride; |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 GrGLvoid useProgram(GrGLuint programID) override { | 220 GrGLvoid useProgram(GrGLuint programID) override { |
221 | 221 |
222 // A programID of 0 is legal | 222 // A programID of 0 is legal |
223 GrProgramObj *program = FIND(programID, GrProgramObj, kProgram_ObjTypes
); | 223 GrProgramObj *program = FIND(programID, GrProgramObj, kProgram_ObjTypes)
; |
224 | 224 |
225 this->useProgram(program); | 225 this->useProgram(program); |
226 } | 226 } |
227 | 227 |
228 GrGLvoid bindFramebuffer(GrGLenum target, GrGLuint frameBufferID) override
{ | 228 GrGLvoid bindFramebuffer(GrGLenum target, GrGLuint frameBufferID) override { |
229 | 229 |
230 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target || | 230 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target || |
231 GR_GL_READ_FRAMEBUFFER == target || | 231 GR_GL_READ_FRAMEBUFFER == target || |
232 GR_GL_DRAW_FRAMEBUFFER); | 232 GR_GL_DRAW_FRAMEBUFFER); |
233 | 233 |
234 // a frameBufferID of 0 is acceptable - it binds to the default | 234 // a frameBufferID of 0 is acceptable - it binds to the default |
235 // frame buffer | 235 // frame buffer |
236 GrFrameBufferObj *frameBuffer = FIND(frameBufferID, GrFrameBufferObj, | 236 GrFrameBufferObj *frameBuffer = FIND(frameBufferID, GrFrameBufferObj, |
237 kFrameBuffer_ObjTypes); | |
238 | |
239 this->setFrameBuffer(frameBuffer); | |
240 } | |
241 | |
242 GrGLvoid bindRenderbuffer(GrGLenum target, GrGLuint renderBufferID) overrid
e { | |
243 | |
244 GrAlwaysAssert(GR_GL_RENDERBUFFER == target); | |
245 | |
246 // a renderBufferID of 0 is acceptable - it unbinds the bound render bu
ffer | |
247 GrRenderBufferObj *renderBuffer = FIND(renderBufferID, GrRenderBufferOb
j, | |
248 kRenderBuffer_ObjTypes); | |
249 | |
250 this->setRenderBuffer(renderBuffer); | |
251 } | |
252 | |
253 GrGLvoid deleteTextures(GrGLsizei n, const GrGLuint* textures) override { | |
254 // first potentially unbind the texture | |
255 for (unsigned int i = 0; i < kDefaultMaxTextureUnits; ++i) { | |
256 GrTextureUnitObj *pTU = this->getTextureUnit(i); | |
257 | |
258 if (pTU->getTexture()) { | |
259 for (int j = 0; j < n; ++j) { | |
260 | |
261 if (textures[j] == pTU->getTexture()->getID()) { | |
262 // this ID is the current texture - revert the binding
to 0 | |
263 pTU->setTexture(nullptr); | |
264 } | |
265 } | |
266 } | |
267 } | |
268 | |
269 // TODO: fuse the following block with DeleteRenderBuffers? | |
270 // Open GL will remove a deleted render buffer from the active | |
271 // frame buffer but not from any other frame buffer | |
272 if (this->getFrameBuffer()) { | |
273 | |
274 GrFrameBufferObj *frameBuffer = this->getFrameBuffer(); | |
275 | |
276 for (int i = 0; i < n; ++i) { | |
277 | |
278 if (frameBuffer->getColor() && | |
279 textures[i] == frameBuffer->getColor()->getID()) { | |
280 frameBuffer->setColor(nullptr); | |
281 } | |
282 if (frameBuffer->getDepth() && | |
283 textures[i] == frameBuffer->getDepth()->getID()) { | |
284 frameBuffer->setDepth(nullptr); | |
285 } | |
286 if (frameBuffer->getStencil() && | |
287 textures[i] == frameBuffer->getStencil()->getID()) { | |
288 frameBuffer->setStencil(nullptr); | |
289 } | |
290 } | |
291 } | |
292 | |
293 // then actually "delete" the buffers | |
294 for (int i = 0; i < n; ++i) { | |
295 GrTextureObj *buffer = FIND(textures[i], GrTextureObj, kTexture_Obj
Types); | |
296 GrAlwaysAssert(buffer); | |
297 | |
298 // OpenGL gives no guarantees if a texture is deleted while attache
d to | |
299 // something other than the currently bound frame buffer | |
300 GrAlwaysAssert(!buffer->getBound()); | |
301 | |
302 GrAlwaysAssert(!buffer->getDeleted()); | |
303 buffer->deleteAction(); | |
304 } | |
305 | |
306 } | |
307 | |
308 GrGLvoid deleteFramebuffers(GrGLsizei n, const GrGLuint *frameBuffers) over
ride { | |
309 | |
310 // first potentially unbind the buffers | |
311 if (this->getFrameBuffer()) { | |
312 for (int i = 0; i < n; ++i) { | |
313 | |
314 if (frameBuffers[i] == | |
315 this->getFrameBuffer()->getID()) { | |
316 // this ID is the current frame buffer - rebind to the defa
ult | |
317 this->setFrameBuffer(nullptr); | |
318 } | |
319 } | |
320 } | |
321 | |
322 // then actually "delete" the buffers | |
323 for (int i = 0; i < n; ++i) { | |
324 GrFrameBufferObj *buffer = FIND(frameBuffers[i], GrFrameBufferObj, | |
325 kFrameBuffer_ObjTypes); | 237 kFrameBuffer_ObjTypes); |
326 GrAlwaysAssert(buffer); | 238 |
327 | 239 this->setFrameBuffer(frameBuffer); |
328 GrAlwaysAssert(!buffer->getDeleted()); | 240 } |
329 buffer->deleteAction(); | 241 |
330 } | 242 GrGLvoid bindRenderbuffer(GrGLenum target, GrGLuint renderBufferID) override
{ |
331 } | 243 |
332 | 244 GrAlwaysAssert(GR_GL_RENDERBUFFER == target); |
333 GrGLvoid deleteRenderbuffers(GrGLsizei n,const GrGLuint *renderBuffers) ove
rride { | 245 |
334 | 246 // a renderBufferID of 0 is acceptable - it unbinds the bound render buf
fer |
335 // first potentially unbind the buffers | 247 GrRenderBufferObj *renderBuffer = FIND(renderBufferID, GrRenderBufferObj
, |
336 if (this->getRenderBuffer()) { | 248 kRenderBuffer_ObjTypes); |
337 for (int i = 0; i < n; ++i) { | 249 |
338 | 250 this->setRenderBuffer(renderBuffer); |
339 if (renderBuffers[i] == | 251 } |
340 this->getRenderBuffer()->getID()) { | 252 |
341 // this ID is the current render buffer - make no | 253 GrGLvoid deleteTextures(GrGLsizei n, const GrGLuint* textures) override { |
342 // render buffer be bound | 254 // first potentially unbind the texture |
343 this->setRenderBuffer(nullptr); | 255 for (unsigned int i = 0; i < kDefaultMaxTextureUnits; ++i) { |
344 } | 256 GrTextureUnitObj *pTU = this->getTextureUnit(i); |
345 } | 257 |
346 } | 258 if (pTU->getTexture()) { |
347 | 259 for (int j = 0; j < n; ++j) { |
348 // TODO: fuse the following block with DeleteTextures? | 260 |
349 // Open GL will remove a deleted render buffer from the active frame | 261 if (textures[j] == pTU->getTexture()->getID()) { |
350 // buffer but not from any other frame buffer | 262 // this ID is the current texture - revert the binding t
o 0 |
351 if (this->getFrameBuffer()) { | 263 pTU->setTexture(nullptr); |
352 | 264 } |
353 GrFrameBufferObj *frameBuffer = this->getFrameBuffer(); | 265 } |
354 | 266 } |
355 for (int i = 0; i < n; ++i) { | 267 } |
356 | 268 |
357 if (frameBuffer->getColor() && | 269 // TODO: fuse the following block with DeleteRenderBuffers? |
358 renderBuffers[i] == frameBuffer->getColor()->getID()) { | 270 // Open GL will remove a deleted render buffer from the active |
359 frameBuffer->setColor(nullptr); | 271 // frame buffer but not from any other frame buffer |
360 } | 272 if (this->getFrameBuffer()) { |
361 if (frameBuffer->getDepth() && | 273 |
362 renderBuffers[i] == frameBuffer->getDepth()->getID()) { | 274 GrFrameBufferObj *frameBuffer = this->getFrameBuffer(); |
363 frameBuffer->setDepth(nullptr); | 275 |
364 } | 276 for (int i = 0; i < n; ++i) { |
365 if (frameBuffer->getStencil() && | 277 |
366 renderBuffers[i] == frameBuffer->getStencil()->getID()) { | 278 if (frameBuffer->getColor() && |
367 frameBuffer->setStencil(nullptr); | 279 textures[i] == frameBuffer->getColor()->getID()) { |
368 } | 280 frameBuffer->setColor(nullptr); |
369 } | 281 } |
370 } | 282 if (frameBuffer->getDepth() && |
371 | 283 textures[i] == frameBuffer->getDepth()->getID()) { |
372 // then actually "delete" the buffers | 284 frameBuffer->setDepth(nullptr); |
373 for (int i = 0; i < n; ++i) { | 285 } |
374 GrRenderBufferObj *buffer = FIND(renderBuffers[i], GrRenderBufferOb
j, | 286 if (frameBuffer->getStencil() && |
375 kRenderBuffer_ObjTypes); | 287 textures[i] == frameBuffer->getStencil()->getID()) { |
376 GrAlwaysAssert(buffer); | 288 frameBuffer->setStencil(nullptr); |
377 | 289 } |
378 // OpenGL gives no guarantees if a render buffer is deleted | 290 } |
379 // while attached to something other than the currently | 291 } |
380 // bound frame buffer | 292 |
381 GrAlwaysAssert(!buffer->getColorBound()); | 293 // then actually "delete" the buffers |
382 GrAlwaysAssert(!buffer->getDepthBound()); | 294 for (int i = 0; i < n; ++i) { |
383 // However, at GrContext destroy time we release all GrRsources and
so stencil buffers | 295 GrTextureObj *buffer = FIND(textures[i], GrTextureObj, kTexture_ObjT
ypes); |
384 // may get deleted before FBOs that refer to them. | 296 GrAlwaysAssert(buffer); |
385 //GrAlwaysAssert(!buffer->getStencilBound()); | 297 |
386 | 298 // OpenGL gives no guarantees if a texture is deleted while attached
to |
387 GrAlwaysAssert(!buffer->getDeleted()); | 299 // something other than the currently bound frame buffer |
388 buffer->deleteAction(); | 300 GrAlwaysAssert(!buffer->getBound()); |
389 } | 301 |
390 } | 302 GrAlwaysAssert(!buffer->getDeleted()); |
391 | 303 buffer->deleteAction(); |
392 GrGLvoid framebufferRenderbuffer(GrGLenum target, | 304 } |
393 GrGLenum attachment, | 305 |
394 GrGLenum renderbuffertarget, | 306 } |
395 GrGLuint renderBufferID) override { | 307 |
396 | 308 GrGLvoid deleteFramebuffers(GrGLsizei n, const GrGLuint *frameBuffers) overr
ide { |
397 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target); | 309 |
398 GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment || | 310 // first potentially unbind the buffers |
399 GR_GL_DEPTH_ATTACHMENT == attachment || | 311 if (this->getFrameBuffer()) { |
400 GR_GL_STENCIL_ATTACHMENT == attachment); | 312 for (int i = 0; i < n; ++i) { |
401 GrAlwaysAssert(GR_GL_RENDERBUFFER == renderbuffertarget); | 313 |
402 | 314 if (frameBuffers[i] == |
403 GrFrameBufferObj *framebuffer = this->getFrameBuffer(); | 315 this->getFrameBuffer()->getID()) { |
404 // A render buffer cannot be attached to the default framebuffer | 316 // this ID is the current frame buffer - rebind to the defau
lt |
405 GrAlwaysAssert(framebuffer); | 317 this->setFrameBuffer(nullptr); |
406 | 318 } |
407 // a renderBufferID of 0 is acceptable - it unbinds the current | 319 } |
408 // render buffer | 320 } |
409 GrRenderBufferObj *renderbuffer = FIND(renderBufferID, GrRenderBufferOb
j, | 321 |
410 kRenderBuffer_ObjTypes); | 322 // then actually "delete" the buffers |
411 | 323 for (int i = 0; i < n; ++i) { |
412 switch (attachment) { | 324 GrFrameBufferObj *buffer = FIND(frameBuffers[i], GrFrameBufferObj, |
413 case GR_GL_COLOR_ATTACHMENT0: | 325 kFrameBuffer_ObjTypes); |
414 framebuffer->setColor(renderbuffer); | 326 GrAlwaysAssert(buffer); |
415 break; | 327 |
416 case GR_GL_DEPTH_ATTACHMENT: | 328 GrAlwaysAssert(!buffer->getDeleted()); |
417 framebuffer->setDepth(renderbuffer); | 329 buffer->deleteAction(); |
418 break; | 330 } |
419 case GR_GL_STENCIL_ATTACHMENT: | 331 } |
420 framebuffer->setStencil(renderbuffer); | 332 |
421 break; | 333 GrGLvoid deleteRenderbuffers(GrGLsizei n,const GrGLuint *renderBuffers) over
ride { |
422 default: | 334 |
423 GrAlwaysAssert(false); | 335 // first potentially unbind the buffers |
424 break; | 336 if (this->getRenderBuffer()) { |
425 }; | 337 for (int i = 0; i < n; ++i) { |
426 | 338 |
427 } | 339 if (renderBuffers[i] == |
428 | 340 this->getRenderBuffer()->getID()) { |
429 ///////////////////////////////////////////////////////////////////////////
///// | 341 // this ID is the current render buffer - make no |
430 GrGLvoid framebufferTexture2D(GrGLenum target, GrGLenum attachment, GrGLenu
m textarget, | 342 // render buffer be bound |
431 GrGLuint textureID, GrGLint level) override { | 343 this->setRenderBuffer(nullptr); |
432 | 344 } |
433 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target); | 345 } |
434 GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment || | 346 } |
435 GR_GL_DEPTH_ATTACHMENT == attachment || | 347 |
436 GR_GL_STENCIL_ATTACHMENT == attachment); | 348 // TODO: fuse the following block with DeleteTextures? |
437 GrAlwaysAssert(GR_GL_TEXTURE_2D == textarget); | 349 // Open GL will remove a deleted render buffer from the active frame |
438 | 350 // buffer but not from any other frame buffer |
439 GrFrameBufferObj *framebuffer = this->getFrameBuffer(); | 351 if (this->getFrameBuffer()) { |
440 // A texture cannot be attached to the default framebuffer | 352 |
441 GrAlwaysAssert(framebuffer); | 353 GrFrameBufferObj *frameBuffer = this->getFrameBuffer(); |
442 | 354 |
443 // A textureID of 0 is allowed - it unbinds the currently bound texture | 355 for (int i = 0; i < n; ++i) { |
444 GrTextureObj *texture = FIND(textureID, GrTextureObj, kTexture_ObjTypes
); | 356 |
445 if (texture) { | 357 if (frameBuffer->getColor() && |
446 // The texture shouldn't be bound to a texture unit - this | 358 renderBuffers[i] == frameBuffer->getColor()->getID()) { |
447 // could lead to a feedback loop | 359 frameBuffer->setColor(nullptr); |
448 GrAlwaysAssert(!texture->getBound()); | 360 } |
449 } | 361 if (frameBuffer->getDepth() && |
450 | 362 renderBuffers[i] == frameBuffer->getDepth()->getID()) { |
451 GrAlwaysAssert(0 == level); | 363 frameBuffer->setDepth(nullptr); |
452 | 364 } |
453 switch (attachment) { | 365 if (frameBuffer->getStencil() && |
454 case GR_GL_COLOR_ATTACHMENT0: | 366 renderBuffers[i] == frameBuffer->getStencil()->getID()) { |
455 framebuffer->setColor(texture); | 367 frameBuffer->setStencil(nullptr); |
456 break; | 368 } |
457 case GR_GL_DEPTH_ATTACHMENT: | 369 } |
458 framebuffer->setDepth(texture); | 370 } |
459 break; | 371 |
460 case GR_GL_STENCIL_ATTACHMENT: | 372 // then actually "delete" the buffers |
461 framebuffer->setStencil(texture); | 373 for (int i = 0; i < n; ++i) { |
462 break; | 374 GrRenderBufferObj *buffer = FIND(renderBuffers[i], GrRenderBufferObj
, |
463 default: | 375 kRenderBuffer_ObjTypes); |
464 GrAlwaysAssert(false); | 376 GrAlwaysAssert(buffer); |
465 break; | 377 |
466 }; | 378 // OpenGL gives no guarantees if a render buffer is deleted |
467 } | 379 // while attached to something other than the currently |
| 380 // bound frame buffer |
| 381 GrAlwaysAssert(!buffer->getColorBound()); |
| 382 GrAlwaysAssert(!buffer->getDepthBound()); |
| 383 // However, at GrContext destroy time we release all GrRsources and
so stencil buffers |
| 384 // may get deleted before FBOs that refer to them. |
| 385 //GrAlwaysAssert(!buffer->getStencilBound()); |
| 386 |
| 387 GrAlwaysAssert(!buffer->getDeleted()); |
| 388 buffer->deleteAction(); |
| 389 } |
| 390 } |
| 391 |
| 392 GrGLvoid framebufferRenderbuffer(GrGLenum target, |
| 393 GrGLenum attachment, |
| 394 GrGLenum renderbuffertarget, |
| 395 GrGLuint renderBufferID) override { |
| 396 |
| 397 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target); |
| 398 GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment || |
| 399 GR_GL_DEPTH_ATTACHMENT == attachment || |
| 400 GR_GL_STENCIL_ATTACHMENT == attachment); |
| 401 GrAlwaysAssert(GR_GL_RENDERBUFFER == renderbuffertarget); |
| 402 |
| 403 GrFrameBufferObj *framebuffer = this->getFrameBuffer(); |
| 404 // A render buffer cannot be attached to the default framebuffer |
| 405 GrAlwaysAssert(framebuffer); |
| 406 |
| 407 // a renderBufferID of 0 is acceptable - it unbinds the current |
| 408 // render buffer |
| 409 GrRenderBufferObj *renderbuffer = FIND(renderBufferID, GrRenderBufferObj
, |
| 410 kRenderBuffer_ObjTypes); |
| 411 |
| 412 switch (attachment) { |
| 413 case GR_GL_COLOR_ATTACHMENT0: |
| 414 framebuffer->setColor(renderbuffer); |
| 415 break; |
| 416 case GR_GL_DEPTH_ATTACHMENT: |
| 417 framebuffer->setDepth(renderbuffer); |
| 418 break; |
| 419 case GR_GL_STENCIL_ATTACHMENT: |
| 420 framebuffer->setStencil(renderbuffer); |
| 421 break; |
| 422 default: |
| 423 GrAlwaysAssert(false); |
| 424 break; |
| 425 }; |
| 426 |
| 427 } |
| 428 |
| 429 ////////////////////////////////////////////////////////////////////////////
//// |
| 430 GrGLvoid framebufferTexture2D(GrGLenum target, GrGLenum attachment, GrGLenum
textarget, |
| 431 GrGLuint textureID, GrGLint level) override { |
| 432 |
| 433 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target); |
| 434 GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment || |
| 435 GR_GL_DEPTH_ATTACHMENT == attachment || |
| 436 GR_GL_STENCIL_ATTACHMENT == attachment); |
| 437 GrAlwaysAssert(GR_GL_TEXTURE_2D == textarget); |
| 438 |
| 439 GrFrameBufferObj *framebuffer = this->getFrameBuffer(); |
| 440 // A texture cannot be attached to the default framebuffer |
| 441 GrAlwaysAssert(framebuffer); |
| 442 |
| 443 // A textureID of 0 is allowed - it unbinds the currently bound texture |
| 444 GrTextureObj *texture = FIND(textureID, GrTextureObj, kTexture_ObjTypes)
; |
| 445 if (texture) { |
| 446 // The texture shouldn't be bound to a texture unit - this |
| 447 // could lead to a feedback loop |
| 448 GrAlwaysAssert(!texture->getBound()); |
| 449 } |
| 450 |
| 451 GrAlwaysAssert(0 == level); |
| 452 |
| 453 switch (attachment) { |
| 454 case GR_GL_COLOR_ATTACHMENT0: |
| 455 framebuffer->setColor(texture); |
| 456 break; |
| 457 case GR_GL_DEPTH_ATTACHMENT: |
| 458 framebuffer->setDepth(texture); |
| 459 break; |
| 460 case GR_GL_STENCIL_ATTACHMENT: |
| 461 framebuffer->setStencil(texture); |
| 462 break; |
| 463 default: |
| 464 GrAlwaysAssert(false); |
| 465 break; |
| 466 }; |
| 467 } |
468 | 468 |
469 GrGLuint createProgram() override { | 469 GrGLuint createProgram() override { |
470 | 470 |
471 GrProgramObj *program = CREATE(GrProgramObj, kProgram_ObjTypes); | 471 GrProgramObj *program = CREATE(GrProgramObj, kProgram_ObjTypes); |
472 | 472 |
473 return program->getID(); | 473 return program->getID(); |
474 } | 474 } |
475 | 475 |
476 GrGLuint createShader(GrGLenum type) override { | 476 GrGLuint createShader(GrGLenum type) override { |
477 | 477 |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 const char* DebugInterface::kExtensions[] = { | 1222 const char* DebugInterface::kExtensions[] = { |
1223 "GL_ARB_framebuffer_object", | 1223 "GL_ARB_framebuffer_object", |
1224 "GL_ARB_blend_func_extended", | 1224 "GL_ARB_blend_func_extended", |
1225 "GL_ARB_timer_query", | 1225 "GL_ARB_timer_query", |
1226 "GL_ARB_draw_buffers", | 1226 "GL_ARB_draw_buffers", |
1227 "GL_ARB_occlusion_query", | 1227 "GL_ARB_occlusion_query", |
1228 "GL_EXT_stencil_wrap", | 1228 "GL_EXT_stencil_wrap", |
1229 nullptr, // signifies the end of the array. | 1229 nullptr, // signifies the end of the array. |
1230 }; | 1230 }; |
1231 | 1231 |
| 1232 class DebugGLContext : public sk_gpu_test::GLContext { |
| 1233 public: |
| 1234 DebugGLContext() { |
| 1235 this->init(new DebugInterface()); |
| 1236 } |
| 1237 |
| 1238 ~DebugGLContext() override { this->teardown(); } |
| 1239 |
| 1240 private: |
| 1241 void onPlatformMakeCurrent() const override {} |
| 1242 void onPlatformSwapBuffers() const override {} |
| 1243 GrGLFuncPtr onPlatformGetProcAddress(const char*) const override { return nu
llptr; } |
| 1244 }; |
1232 } // anonymous namespace | 1245 } // anonymous namespace |
1233 | 1246 |
1234 //////////////////////////////////////////////////////////////////////////////// | 1247 namespace sk_gpu_test { |
1235 | 1248 GLContext* CreateDebugGLContext() { |
1236 const GrGLInterface* GrGLCreateDebugInterface() { return new DebugInterface; } | 1249 GLContext* ctx = new DebugGLContext(); |
| 1250 if (ctx->isValid()) { |
| 1251 return ctx; |
| 1252 } |
| 1253 delete ctx; |
| 1254 return nullptr; |
| 1255 } |
| 1256 } |
OLD | NEW |