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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 { | 325 { |
326 ASSERT(isBound()); | 326 ASSERT(isBound()); |
327 WebGLAttachment* attachmentObject = getAttachment(attachment); | 327 WebGLAttachment* attachmentObject = getAttachment(attachment); |
328 if (attachmentObject) | 328 if (attachmentObject) |
329 attachmentObject->attach(context()->webContext(), attachmentPoint); | 329 attachmentObject->attach(context()->webContext(), attachmentPoint); |
330 } | 330 } |
331 | 331 |
332 WebGLSharedObject* WebGLFramebuffer::getAttachmentObject(GLenum attachment) cons
t | 332 WebGLSharedObject* WebGLFramebuffer::getAttachmentObject(GLenum attachment) cons
t |
333 { | 333 { |
334 if (!object()) | 334 if (!object()) |
335 return 0; | 335 return nullptr; |
336 WebGLAttachment* attachmentObject = getAttachment(attachment); | 336 WebGLAttachment* attachmentObject = getAttachment(attachment); |
337 return attachmentObject ? attachmentObject->object() : 0; | 337 return attachmentObject ? attachmentObject->object() : nullptr; |
338 } | 338 } |
339 | 339 |
340 bool WebGLFramebuffer::isAttachmentComplete(WebGLAttachment* attachedObject, GLe
num attachment, const char** reason) const | 340 bool WebGLFramebuffer::isAttachmentComplete(WebGLAttachment* attachedObject, GLe
num attachment, const char** reason) const |
341 { | 341 { |
342 ASSERT(attachedObject && attachedObject->valid()); | 342 ASSERT(attachedObject && attachedObject->valid()); |
343 ASSERT(reason); | 343 ASSERT(reason); |
344 | 344 |
345 GLenum internalformat = attachedObject->format(); | 345 GLenum internalformat = attachedObject->format(); |
346 WebGLSharedObject* object = attachedObject->object(); | 346 WebGLSharedObject* object = attachedObject->object(); |
347 ASSERT(object && (object->isTexture() || object->isRenderbuffer())); | 347 ASSERT(object && (object->isTexture() || object->isRenderbuffer())); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 { | 460 { |
461 ASSERT(isBound()); | 461 ASSERT(isBound()); |
462 if (!object()) | 462 if (!object()) |
463 return; | 463 return; |
464 if (!attachment) | 464 if (!attachment) |
465 return; | 465 return; |
466 | 466 |
467 bool checkMore = true; | 467 bool checkMore = true; |
468 while (checkMore) { | 468 while (checkMore) { |
469 checkMore = false; | 469 checkMore = false; |
470 for (AttachmentMap::iterator it = m_attachments.begin(); it != m_attachm
ents.end(); ++it) { | 470 for (const auto& it : m_attachments) { |
471 WebGLAttachment* attachmentObject = it->value.get(); | 471 WebGLAttachment* attachmentObject = it.value.get(); |
472 if (attachmentObject->isSharedObject(attachment)) { | 472 if (attachmentObject->isSharedObject(attachment)) { |
473 GLenum attachmentType = it->key; | 473 GLenum attachmentType = it.key; |
474 attachmentObject->unattach(context()->webContext(), attachmentTy
pe); | 474 attachmentObject->unattach(context()->webContext(), attachmentTy
pe); |
475 removeAttachmentFromBoundFramebuffer(attachmentType); | 475 removeAttachmentFromBoundFramebuffer(attachmentType); |
476 checkMore = true; | 476 checkMore = true; |
477 break; | 477 break; |
478 } | 478 } |
479 } | 479 } |
480 } | 480 } |
481 } | 481 } |
482 | 482 |
483 GLenum WebGLFramebuffer::colorBufferFormat() const | 483 GLenum WebGLFramebuffer::colorBufferFormat() const |
484 { | 484 { |
485 if (!object()) | 485 if (!object()) |
486 return 0; | 486 return 0; |
487 WebGLAttachment* attachment = getAttachment(GL_COLOR_ATTACHMENT0); | 487 WebGLAttachment* attachment = getAttachment(GL_COLOR_ATTACHMENT0); |
488 if (!attachment) | 488 if (!attachment) |
489 return 0; | 489 return 0; |
490 return attachment->format(); | 490 return attachment->format(); |
491 } | 491 } |
492 | 492 |
493 GLenum WebGLFramebuffer::checkStatus(const char** reason) const | 493 GLenum WebGLFramebuffer::checkStatus(const char** reason) const |
494 { | 494 { |
495 unsigned count = 0; | 495 unsigned count = 0; |
496 GLsizei width = 0, height = 0; | 496 GLsizei width = 0, height = 0; |
497 bool haveDepth = false; | 497 bool haveDepth = false; |
498 bool haveStencil = false; | 498 bool haveStencil = false; |
499 bool haveDepthStencil = false; | 499 bool haveDepthStencil = false; |
500 for (AttachmentMap::const_iterator it = m_attachments.begin(); it != m_attac
hments.end(); ++it) { | 500 for (const auto& it : m_attachments) { |
501 WebGLAttachment* attachment = it->value.get(); | 501 WebGLAttachment* attachment = it.value.get(); |
502 if (!isAttachmentComplete(attachment, it->key, reason)) | 502 if (!isAttachmentComplete(attachment, it.key, reason)) |
503 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 503 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
504 if (!attachment->valid()) { | 504 if (!attachment->valid()) { |
505 *reason = "attachment is not valid"; | 505 *reason = "attachment is not valid"; |
506 return GL_FRAMEBUFFER_UNSUPPORTED; | 506 return GL_FRAMEBUFFER_UNSUPPORTED; |
507 } | 507 } |
508 if (!attachment->format()) { | 508 if (!attachment->format()) { |
509 *reason = "attachment is an unsupported format"; | 509 *reason = "attachment is an unsupported format"; |
510 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 510 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
511 } | 511 } |
512 switch (it->key) { | 512 switch (it.key) { |
513 case GL_DEPTH_ATTACHMENT: | 513 case GL_DEPTH_ATTACHMENT: |
514 haveDepth = true; | 514 haveDepth = true; |
515 break; | 515 break; |
516 case GL_STENCIL_ATTACHMENT: | 516 case GL_STENCIL_ATTACHMENT: |
517 haveStencil = true; | 517 haveStencil = true; |
518 break; | 518 break; |
519 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: | 519 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: |
520 haveDepthStencil = true; | 520 haveDepthStencil = true; |
521 break; | 521 break; |
522 } | 522 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 void WebGLFramebuffer::deleteObjectImpl(blink::WebGraphicsContext3D* context3d,
Platform3DObject object) | 565 void WebGLFramebuffer::deleteObjectImpl(blink::WebGraphicsContext3D* context3d,
Platform3DObject object) |
566 { | 566 { |
567 #if !ENABLE(OILPAN) | 567 #if !ENABLE(OILPAN) |
568 // With Oilpan, both the AttachmentMap and its WebGLAttachment objects are | 568 // With Oilpan, both the AttachmentMap and its WebGLAttachment objects are |
569 // GCed objects and cannot be accessed, as they may have been finalized | 569 // GCed objects and cannot be accessed, as they may have been finalized |
570 // already during the same GC sweep. | 570 // already during the same GC sweep. |
571 // | 571 // |
572 // The WebGLAttachment-derived classes instead handle detachment | 572 // The WebGLAttachment-derived classes instead handle detachment |
573 // on their own when finalizing, so the explicit notification is | 573 // on their own when finalizing, so the explicit notification is |
574 // not needed. | 574 // not needed. |
575 for (AttachmentMap::iterator it = m_attachments.begin(); it != m_attachments
.end(); ++it) | 575 for (const auto& attachment : m_attachments) |
576 it->value->onDetached(context3d); | 576 attachment.value->onDetached(context3d); |
577 #endif | 577 #endif |
578 | 578 |
579 context3d->deleteFramebuffer(object); | 579 context3d->deleteFramebuffer(object); |
580 } | 580 } |
581 | 581 |
582 bool WebGLFramebuffer::isBound() const | 582 bool WebGLFramebuffer::isBound() const |
583 { | 583 { |
584 return (context()->m_framebufferBinding.get() == this); | 584 return (context()->m_framebufferBinding.get() == this); |
585 } | 585 } |
586 | 586 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 | 631 |
632 void WebGLFramebuffer::trace(Visitor* visitor) | 632 void WebGLFramebuffer::trace(Visitor* visitor) |
633 { | 633 { |
634 #if ENABLE(OILPAN) | 634 #if ENABLE(OILPAN) |
635 visitor->trace(m_attachments); | 635 visitor->trace(m_attachments); |
636 #endif | 636 #endif |
637 WebGLContextObject::trace(visitor); | 637 WebGLContextObject::trace(visitor); |
638 } | 638 } |
639 | 639 |
640 } | 640 } |
OLD | NEW |