Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: src/gpu/gl/debug/GrGLCreateDebugInterface.cpp

Issue 544233002: "NULL !=" = NULL (Closed) Base URL: https://skia.googlesource.com/skia.git@are
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/debug/GrDebugGL.cpp ('k') | src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
10 #include "gl/GrGLInterface.h" 10 #include "gl/GrGLInterface.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 249
250 // TODO: fuse the following block with DeleteRenderBuffers? 250 // TODO: fuse the following block with DeleteRenderBuffers?
251 // Open GL will remove a deleted render buffer from the active 251 // Open GL will remove a deleted render buffer from the active
252 // frame buffer but not from any other frame buffer 252 // frame buffer but not from any other frame buffer
253 if (GrDebugGL::getInstance()->getFrameBuffer()) { 253 if (GrDebugGL::getInstance()->getFrameBuffer()) {
254 254
255 GrFrameBufferObj *frameBuffer = GrDebugGL::getInstance()->getFrameBuffe r(); 255 GrFrameBufferObj *frameBuffer = GrDebugGL::getInstance()->getFrameBuffe r();
256 256
257 for (int i = 0; i < n; ++i) { 257 for (int i = 0; i < n; ++i) {
258 258
259 if (NULL != frameBuffer->getColor() && 259 if (frameBuffer->getColor() &&
260 textures[i] == frameBuffer->getColor()->getID()) { 260 textures[i] == frameBuffer->getColor()->getID()) {
261 frameBuffer->setColor(NULL); 261 frameBuffer->setColor(NULL);
262 } 262 }
263 if (NULL != frameBuffer->getDepth() && 263 if (frameBuffer->getDepth() &&
264 textures[i] == frameBuffer->getDepth()->getID()) { 264 textures[i] == frameBuffer->getDepth()->getID()) {
265 frameBuffer->setDepth(NULL); 265 frameBuffer->setDepth(NULL);
266 } 266 }
267 if (NULL != frameBuffer->getStencil() && 267 if (frameBuffer->getStencil() &&
268 textures[i] == frameBuffer->getStencil()->getID()) { 268 textures[i] == frameBuffer->getStencil()->getID()) {
269 frameBuffer->setStencil(NULL); 269 frameBuffer->setStencil(NULL);
270 } 270 }
271 } 271 }
272 } 272 }
273 273
274 // then actually "delete" the buffers 274 // then actually "delete" the buffers
275 for (int i = 0; i < n; ++i) { 275 for (int i = 0; i < n; ++i) {
276 GrTextureObj *buffer = GR_FIND(textures[i], 276 GrTextureObj *buffer = GR_FIND(textures[i],
277 GrTextureObj, 277 GrTextureObj,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 // TODO: fuse the following block with DeleteTextures? 334 // TODO: fuse the following block with DeleteTextures?
335 // Open GL will remove a deleted render buffer from the active frame 335 // Open GL will remove a deleted render buffer from the active frame
336 // buffer but not from any other frame buffer 336 // buffer but not from any other frame buffer
337 if (GrDebugGL::getInstance()->getFrameBuffer()) { 337 if (GrDebugGL::getInstance()->getFrameBuffer()) {
338 338
339 GrFrameBufferObj *frameBuffer = 339 GrFrameBufferObj *frameBuffer =
340 GrDebugGL::getInstance()->getFrameBuffer(); 340 GrDebugGL::getInstance()->getFrameBuffer();
341 341
342 for (int i = 0; i < n; ++i) { 342 for (int i = 0; i < n; ++i) {
343 343
344 if (NULL != frameBuffer->getColor() && 344 if (frameBuffer->getColor() &&
345 renderBuffers[i] == frameBuffer->getColor()->getID()) { 345 renderBuffers[i] == frameBuffer->getColor()->getID()) {
346 frameBuffer->setColor(NULL); 346 frameBuffer->setColor(NULL);
347 } 347 }
348 if (NULL != frameBuffer->getDepth() && 348 if (frameBuffer->getDepth() &&
349 renderBuffers[i] == frameBuffer->getDepth()->getID()) { 349 renderBuffers[i] == frameBuffer->getDepth()->getID()) {
350 frameBuffer->setDepth(NULL); 350 frameBuffer->setDepth(NULL);
351 } 351 }
352 if (NULL != frameBuffer->getStencil() && 352 if (frameBuffer->getStencil() &&
353 renderBuffers[i] == frameBuffer->getStencil()->getID()) { 353 renderBuffers[i] == frameBuffer->getStencil()->getID()) {
354 frameBuffer->setStencil(NULL); 354 frameBuffer->setStencil(NULL);
355 } 355 }
356 } 356 }
357 } 357 }
358 358
359 // then actually "delete" the buffers 359 // then actually "delete" the buffers
360 for (int i = 0; i < n; ++i) { 360 for (int i = 0; i < n; ++i) {
361 GrRenderBufferObj *buffer = GR_FIND(renderBuffers[i], 361 GrRenderBufferObj *buffer = GR_FIND(renderBuffers[i],
362 GrRenderBufferObj, 362 GrRenderBufferObj,
(...skipping 20 matching lines...) Expand all
383 GrGLuint renderBuff erID) { 383 GrGLuint renderBuff erID) {
384 384
385 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target); 385 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target);
386 GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment || 386 GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment ||
387 GR_GL_DEPTH_ATTACHMENT == attachment || 387 GR_GL_DEPTH_ATTACHMENT == attachment ||
388 GR_GL_STENCIL_ATTACHMENT == attachment); 388 GR_GL_STENCIL_ATTACHMENT == attachment);
389 GrAlwaysAssert(GR_GL_RENDERBUFFER == renderbuffertarget); 389 GrAlwaysAssert(GR_GL_RENDERBUFFER == renderbuffertarget);
390 390
391 GrFrameBufferObj *framebuffer = GrDebugGL::getInstance()->getFrameBuffer(); 391 GrFrameBufferObj *framebuffer = GrDebugGL::getInstance()->getFrameBuffer();
392 // A render buffer cannot be attached to the default framebuffer 392 // A render buffer cannot be attached to the default framebuffer
393 GrAlwaysAssert(NULL != framebuffer); 393 GrAlwaysAssert(framebuffer);
394 394
395 // a renderBufferID of 0 is acceptable - it unbinds the current 395 // a renderBufferID of 0 is acceptable - it unbinds the current
396 // render buffer 396 // render buffer
397 GrRenderBufferObj *renderbuffer = GR_FIND(renderBufferID, 397 GrRenderBufferObj *renderbuffer = GR_FIND(renderBufferID,
398 GrRenderBufferObj, 398 GrRenderBufferObj,
399 GrDebugGL::kRenderBuffer_ObjTypes ); 399 GrDebugGL::kRenderBuffer_ObjTypes );
400 400
401 switch (attachment) { 401 switch (attachment) {
402 case GR_GL_COLOR_ATTACHMENT0: 402 case GR_GL_COLOR_ATTACHMENT0:
403 framebuffer->setColor(renderbuffer); 403 framebuffer->setColor(renderbuffer);
(...skipping 19 matching lines...) Expand all
423 GrGLint level) { 423 GrGLint level) {
424 424
425 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target); 425 GrAlwaysAssert(GR_GL_FRAMEBUFFER == target);
426 GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment || 426 GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment ||
427 GR_GL_DEPTH_ATTACHMENT == attachment || 427 GR_GL_DEPTH_ATTACHMENT == attachment ||
428 GR_GL_STENCIL_ATTACHMENT == attachment); 428 GR_GL_STENCIL_ATTACHMENT == attachment);
429 GrAlwaysAssert(GR_GL_TEXTURE_2D == textarget); 429 GrAlwaysAssert(GR_GL_TEXTURE_2D == textarget);
430 430
431 GrFrameBufferObj *framebuffer = GrDebugGL::getInstance()->getFrameBuffer(); 431 GrFrameBufferObj *framebuffer = GrDebugGL::getInstance()->getFrameBuffer();
432 // A texture cannot be attached to the default framebuffer 432 // A texture cannot be attached to the default framebuffer
433 GrAlwaysAssert(NULL != framebuffer); 433 GrAlwaysAssert(framebuffer);
434 434
435 // A textureID of 0 is allowed - it unbinds the currently bound texture 435 // A textureID of 0 is allowed - it unbinds the currently bound texture
436 GrTextureObj *texture = GR_FIND(textureID, GrTextureObj, 436 GrTextureObj *texture = GR_FIND(textureID, GrTextureObj,
437 GrDebugGL::kTexture_ObjTypes); 437 GrDebugGL::kTexture_ObjTypes);
438 if (texture) { 438 if (texture) {
439 // The texture shouldn't be bound to a texture unit - this 439 // The texture shouldn't be bound to a texture unit - this
440 // could lead to a feedback loop 440 // could lead to a feedback loop
441 GrAlwaysAssert(!texture->getBound()); 441 GrAlwaysAssert(!texture->getBound());
442 } 442 }
443 443
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 // someone is still using this vertex array so we can't delete it he re 559 // someone is still using this vertex array so we can't delete it he re
560 array->setMarkedForDeletion(); 560 array->setMarkedForDeletion();
561 } else { 561 } else {
562 array->deleteAction(); 562 array->deleteAction();
563 } 563 }
564 } 564 }
565 } 565 }
566 566
567 GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindVertexArray(GrGLuint id) { 567 GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindVertexArray(GrGLuint id) {
568 GrVertexArrayObj* array = GR_FIND(id, GrVertexArrayObj, GrDebugGL::kVertexAr ray_ObjTypes); 568 GrVertexArrayObj* array = GR_FIND(id, GrVertexArrayObj, GrDebugGL::kVertexAr ray_ObjTypes);
569 GrAlwaysAssert((0 == id) || NULL != array); 569 GrAlwaysAssert((0 == id) || array);
570 GrDebugGL::getInstance()->setVertexArray(array); 570 GrDebugGL::getInstance()->setVertexArray(array);
571 } 571 }
572 572
573 GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindBuffer(GrGLenum target, GrGLuint bufferI D) { 573 GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindBuffer(GrGLenum target, GrGLuint bufferI D) {
574 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || GR_GL_ELEMENT_ARRAY_BUFFER == target); 574 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || GR_GL_ELEMENT_ARRAY_BUFFER == target);
575 575
576 GrBufferObj *buffer = GR_FIND(bufferID, 576 GrBufferObj *buffer = GR_FIND(bufferID,
577 GrBufferObj, 577 GrBufferObj,
578 GrDebugGL::kBuffer_ObjTypes); 578 GrDebugGL::kBuffer_ObjTypes);
579 // 0 is a permissible bufferID - it unbinds the current buffer 579 // 0 is a permissible bufferID - it unbinds the current buffer
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 buffer = GrDebugGL::getInstance()->getArrayBuffer(); 637 buffer = GrDebugGL::getInstance()->getArrayBuffer();
638 break; 638 break;
639 case GR_GL_ELEMENT_ARRAY_BUFFER: 639 case GR_GL_ELEMENT_ARRAY_BUFFER:
640 buffer = GrDebugGL::getInstance()->getElementArrayBuffer(); 640 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
641 break; 641 break;
642 default: 642 default:
643 SkFAIL("Unexpected target to glMapBufferRange"); 643 SkFAIL("Unexpected target to glMapBufferRange");
644 break; 644 break;
645 } 645 }
646 646
647 if (NULL != buffer) { 647 if (buffer) {
648 GrAlwaysAssert(offset >= 0 && offset + length <= buffer->getSize()); 648 GrAlwaysAssert(offset >= 0 && offset + length <= buffer->getSize());
649 GrAlwaysAssert(!buffer->getMapped()); 649 GrAlwaysAssert(!buffer->getMapped());
650 buffer->setMapped(offset, length); 650 buffer->setMapped(offset, length);
651 return buffer->getDataPtr() + offset; 651 return buffer->getDataPtr() + offset;
652 } 652 }
653 653
654 GrAlwaysAssert(false); 654 GrAlwaysAssert(false);
655 return NULL; // no buffer bound to the target 655 return NULL; // no buffer bound to the target
656 } 656 }
657 657
(...skipping 30 matching lines...) Expand all
688 buffer = GrDebugGL::getInstance()->getArrayBuffer(); 688 buffer = GrDebugGL::getInstance()->getArrayBuffer();
689 break; 689 break;
690 case GR_GL_ELEMENT_ARRAY_BUFFER: 690 case GR_GL_ELEMENT_ARRAY_BUFFER:
691 buffer = GrDebugGL::getInstance()->getElementArrayBuffer(); 691 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
692 break; 692 break;
693 default: 693 default:
694 SkFAIL("Unexpected target to glUnmapBuffer"); 694 SkFAIL("Unexpected target to glUnmapBuffer");
695 break; 695 break;
696 } 696 }
697 697
698 if (NULL != buffer) { 698 if (buffer) {
699 GrAlwaysAssert(buffer->getMapped()); 699 GrAlwaysAssert(buffer->getMapped());
700 buffer->resetMapped(); 700 buffer->resetMapped();
701 return GR_GL_TRUE; 701 return GR_GL_TRUE;
702 } 702 }
703 703
704 GrAlwaysAssert(false); 704 GrAlwaysAssert(false);
705 return GR_GL_FALSE; // GR_GL_INVALID_OPERATION; 705 return GR_GL_FALSE; // GR_GL_INVALID_OPERATION;
706 } 706 }
707 707
708 GrGLvoid GR_GL_FUNCTION_TYPE debugGLFlushMappedBufferRange(GrGLenum target, 708 GrGLvoid GR_GL_FUNCTION_TYPE debugGLFlushMappedBufferRange(GrGLenum target,
709 GrGLintptr offset, 709 GrGLintptr offset,
710 GrGLsizeiptr length) { 710 GrGLsizeiptr length) {
711 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || 711 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
712 GR_GL_ELEMENT_ARRAY_BUFFER == target); 712 GR_GL_ELEMENT_ARRAY_BUFFER == target);
713 713
714 GrBufferObj *buffer = NULL; 714 GrBufferObj *buffer = NULL;
715 switch (target) { 715 switch (target) {
716 case GR_GL_ARRAY_BUFFER: 716 case GR_GL_ARRAY_BUFFER:
717 buffer = GrDebugGL::getInstance()->getArrayBuffer(); 717 buffer = GrDebugGL::getInstance()->getArrayBuffer();
718 break; 718 break;
719 case GR_GL_ELEMENT_ARRAY_BUFFER: 719 case GR_GL_ELEMENT_ARRAY_BUFFER:
720 buffer = GrDebugGL::getInstance()->getElementArrayBuffer(); 720 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
721 break; 721 break;
722 default: 722 default:
723 SkFAIL("Unexpected target to glUnmapBuffer"); 723 SkFAIL("Unexpected target to glUnmapBuffer");
724 break; 724 break;
725 } 725 }
726 726
727 if (NULL != buffer) { 727 if (buffer) {
728 GrAlwaysAssert(buffer->getMapped()); 728 GrAlwaysAssert(buffer->getMapped());
729 GrAlwaysAssert(offset >= 0 && (offset + length) <= buffer->getMappedLeng th()); 729 GrAlwaysAssert(offset >= 0 && (offset + length) <= buffer->getMappedLeng th());
730 } else { 730 } else {
731 GrAlwaysAssert(false); 731 GrAlwaysAssert(false);
732 } 732 }
733 } 733 }
734 734
735 735
736 GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetBufferParameteriv(GrGLenum target, 736 GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetBufferParameteriv(GrGLenum target,
737 GrGLenum value, 737 GrGLenum value,
(...skipping 12 matching lines...) Expand all
750 case GR_GL_ELEMENT_ARRAY_BUFFER: 750 case GR_GL_ELEMENT_ARRAY_BUFFER:
751 buffer = GrDebugGL::getInstance()->getElementArrayBuffer(); 751 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
752 break; 752 break;
753 } 753 }
754 754
755 GrAlwaysAssert(buffer); 755 GrAlwaysAssert(buffer);
756 756
757 switch (value) { 757 switch (value) {
758 case GR_GL_BUFFER_MAPPED: 758 case GR_GL_BUFFER_MAPPED:
759 *params = GR_GL_FALSE; 759 *params = GR_GL_FALSE;
760 if (NULL != buffer) 760 if (buffer)
761 *params = buffer->getMapped() ? GR_GL_TRUE : GR_GL_FALSE; 761 *params = buffer->getMapped() ? GR_GL_TRUE : GR_GL_FALSE;
762 break; 762 break;
763 case GR_GL_BUFFER_SIZE: 763 case GR_GL_BUFFER_SIZE:
764 *params = 0; 764 *params = 0;
765 if (NULL != buffer) 765 if (buffer)
766 *params = SkToInt(buffer->getSize()); 766 *params = SkToInt(buffer->getSize());
767 break; 767 break;
768 case GR_GL_BUFFER_USAGE: 768 case GR_GL_BUFFER_USAGE:
769 *params = GR_GL_STATIC_DRAW; 769 *params = GR_GL_STATIC_DRAW;
770 if (NULL != buffer) 770 if (buffer)
771 *params = buffer->getUsage(); 771 *params = buffer->getUsage();
772 break; 772 break;
773 default: 773 default:
774 SkFAIL("Unexpected value to glGetBufferParamateriv"); 774 SkFAIL("Unexpected value to glGetBufferParamateriv");
775 break; 775 break;
776 } 776 }
777 }; 777 };
778 } // end of namespace 778 } // end of namespace
779 779
780 //////////////////////////////////////////////////////////////////////////////// 780 ////////////////////////////////////////////////////////////////////////////////
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity; 973 functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity;
974 974
975 functions->fBindFragDataLocationIndexed = 975 functions->fBindFragDataLocationIndexed =
976 noOpGLBindFragDataLocationIndexed; 976 noOpGLBindFragDataLocationIndexed;
977 977
978 interface->fExtensions.init(kGL_GrGLStandard, functions->fGetString, functio ns->fGetStringi, 978 interface->fExtensions.init(kGL_GrGLStandard, functions->fGetString, functio ns->fGetStringi,
979 functions->fGetIntegerv); 979 functions->fGetIntegerv);
980 980
981 return interface; 981 return interface;
982 } 982 }
OLDNEW
« no previous file with comments | « src/gpu/gl/debug/GrDebugGL.cpp ('k') | src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698