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