OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 { | 458 { |
459 ASSERT(isBound()); | 459 ASSERT(isBound()); |
460 if (!object()) | 460 if (!object()) |
461 return; | 461 return; |
462 if (!attachment) | 462 if (!attachment) |
463 return; | 463 return; |
464 | 464 |
465 bool checkMore = true; | 465 bool checkMore = true; |
466 while (checkMore) { | 466 while (checkMore) { |
467 checkMore = false; | 467 checkMore = false; |
468 for (AttachmentMap::iterator it = m_attachments.begin(); it != m_attachm
ents.end(); ++it) { | 468 for (const auto& it : m_attachments) { |
469 WebGLAttachment* attachmentObject = it->value.get(); | 469 WebGLAttachment* attachmentObject = it.value.get(); |
470 if (attachmentObject->isSharedObject(attachment)) { | 470 if (attachmentObject->isSharedObject(attachment)) { |
471 GLenum attachmentType = it->key; | 471 GLenum attachmentType = it.key; |
472 attachmentObject->unattach(context()->webContext(), attachmentTy
pe); | 472 attachmentObject->unattach(context()->webContext(), attachmentTy
pe); |
473 removeAttachmentFromBoundFramebuffer(attachmentType); | 473 removeAttachmentFromBoundFramebuffer(attachmentType); |
474 checkMore = true; | 474 checkMore = true; |
475 break; | 475 break; |
476 } | 476 } |
477 } | 477 } |
478 } | 478 } |
479 } | 479 } |
480 | 480 |
481 GLenum WebGLFramebuffer::colorBufferFormat() const | 481 GLenum WebGLFramebuffer::colorBufferFormat() const |
482 { | 482 { |
483 if (!object()) | 483 if (!object()) |
484 return 0; | 484 return 0; |
485 WebGLAttachment* attachment = getAttachment(GL_COLOR_ATTACHMENT0); | 485 WebGLAttachment* attachment = getAttachment(GL_COLOR_ATTACHMENT0); |
486 if (!attachment) | 486 if (!attachment) |
487 return 0; | 487 return 0; |
488 return attachment->format(); | 488 return attachment->format(); |
489 } | 489 } |
490 | 490 |
491 GLenum WebGLFramebuffer::checkStatus(const char** reason) const | 491 GLenum WebGLFramebuffer::checkStatus(const char** reason) const |
492 { | 492 { |
493 unsigned count = 0; | 493 unsigned count = 0; |
494 GLsizei width = 0, height = 0; | 494 GLsizei width = 0, height = 0; |
495 bool haveDepth = false; | 495 bool haveDepth = false; |
496 bool haveStencil = false; | 496 bool haveStencil = false; |
497 bool haveDepthStencil = false; | 497 bool haveDepthStencil = false; |
498 for (AttachmentMap::const_iterator it = m_attachments.begin(); it != m_attac
hments.end(); ++it) { | 498 for (const auto& it : m_attachments) { |
499 WebGLAttachment* attachment = it->value.get(); | 499 WebGLAttachment* attachment = it.value.get(); |
500 if (!isAttachmentComplete(attachment, it->key, reason)) | 500 if (!isAttachmentComplete(attachment, it.key, reason)) |
501 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 501 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
502 if (!attachment->valid()) { | 502 if (!attachment->valid()) { |
503 *reason = "attachment is not valid"; | 503 *reason = "attachment is not valid"; |
504 return GL_FRAMEBUFFER_UNSUPPORTED; | 504 return GL_FRAMEBUFFER_UNSUPPORTED; |
505 } | 505 } |
506 if (!attachment->format()) { | 506 if (!attachment->format()) { |
507 *reason = "attachment is an unsupported format"; | 507 *reason = "attachment is an unsupported format"; |
508 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 508 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
509 } | 509 } |
510 switch (it->key) { | 510 switch (it.key) { |
511 case GL_DEPTH_ATTACHMENT: | 511 case GL_DEPTH_ATTACHMENT: |
512 haveDepth = true; | 512 haveDepth = true; |
513 break; | 513 break; |
514 case GL_STENCIL_ATTACHMENT: | 514 case GL_STENCIL_ATTACHMENT: |
515 haveStencil = true; | 515 haveStencil = true; |
516 break; | 516 break; |
517 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: | 517 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: |
518 haveDepthStencil = true; | 518 haveDepthStencil = true; |
519 break; | 519 break; |
520 } | 520 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 void WebGLFramebuffer::deleteObjectImpl(blink::WebGraphicsContext3D* context3d,
Platform3DObject object) | 563 void WebGLFramebuffer::deleteObjectImpl(blink::WebGraphicsContext3D* context3d,
Platform3DObject object) |
564 { | 564 { |
565 #if !ENABLE(OILPAN) | 565 #if !ENABLE(OILPAN) |
566 // With Oilpan, both the AttachmentMap and its WebGLAttachment objects are | 566 // With Oilpan, both the AttachmentMap and its WebGLAttachment objects are |
567 // GCed objects and cannot be accessed, as they may have been finalized | 567 // GCed objects and cannot be accessed, as they may have been finalized |
568 // already during the same GC sweep. | 568 // already during the same GC sweep. |
569 // | 569 // |
570 // The WebGLAttachment-derived classes instead handle detachment | 570 // The WebGLAttachment-derived classes instead handle detachment |
571 // on their own when finalizing, so the explicit notification is | 571 // on their own when finalizing, so the explicit notification is |
572 // not needed. | 572 // not needed. |
573 for (AttachmentMap::iterator it = m_attachments.begin(); it != m_attachments
.end(); ++it) | 573 for (const auto& attachment : m_attachments) |
574 it->value->onDetached(context3d); | 574 attachment.value->onDetached(context3d); |
575 #endif | 575 #endif |
576 | 576 |
577 context3d->deleteFramebuffer(object); | 577 context3d->deleteFramebuffer(object); |
578 } | 578 } |
579 | 579 |
580 bool WebGLFramebuffer::isBound() const | 580 bool WebGLFramebuffer::isBound() const |
581 { | 581 { |
582 return (context()->m_framebufferBinding.get() == this); | 582 return (context()->m_framebufferBinding.get() == this); |
583 } | 583 } |
584 | 584 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 | 629 |
630 void WebGLFramebuffer::trace(Visitor* visitor) | 630 void WebGLFramebuffer::trace(Visitor* visitor) |
631 { | 631 { |
632 #if ENABLE(OILPAN) | 632 #if ENABLE(OILPAN) |
633 visitor->trace(m_attachments); | 633 visitor->trace(m_attachments); |
634 #endif | 634 #endif |
635 WebGLContextObject::trace(visitor); | 635 WebGLContextObject::trace(visitor); |
636 } | 636 } |
637 | 637 |
638 } | 638 } |
OLD | NEW |