| 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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 GC3Denum WebGLFramebuffer::getColorBufferFormat() const | 417 GC3Denum WebGLFramebuffer::getColorBufferFormat() const |
| 418 { | 418 { |
| 419 if (!object()) | 419 if (!object()) |
| 420 return 0; | 420 return 0; |
| 421 WebGLAttachment* attachment = getAttachment(GraphicsContext3D::COLOR_ATTACHM
ENT0); | 421 WebGLAttachment* attachment = getAttachment(GraphicsContext3D::COLOR_ATTACHM
ENT0); |
| 422 if (!attachment) | 422 if (!attachment) |
| 423 return 0; | 423 return 0; |
| 424 return attachment->getFormat(); | 424 return attachment->getFormat(); |
| 425 } | 425 } |
| 426 | 426 |
| 427 GC3Denum WebGLFramebuffer::checkStatus(const char** reason) const | 427 GC3Denum WebGLFramebuffer::checkStatus(WebGLRenderingContext* context, WebGLShar
edObject::AcquireMode neededAccessMode, const char** reason) const |
| 428 { | 428 { |
| 429 unsigned int count = 0; | 429 unsigned int count = 0; |
| 430 GC3Dsizei width = 0, height = 0; | 430 GC3Dsizei width = 0, height = 0; |
| 431 bool haveDepth = false; | 431 bool haveDepth = false; |
| 432 bool haveStencil = false; | 432 bool haveStencil = false; |
| 433 bool haveDepthStencil = false; | 433 bool haveDepthStencil = false; |
| 434 for (AttachmentMap::const_iterator it = m_attachments.begin(); it != m_attac
hments.end(); ++it) { | 434 for (AttachmentMap::const_iterator it = m_attachments.begin(); it != m_attac
hments.end(); ++it) { |
| 435 WebGLAttachment* attachment = it->value.get(); | 435 WebGLAttachment* attachment = it->value.get(); |
| 436 if (!isAttachmentComplete(attachment, it->key, reason)) | 436 if (!isAttachmentComplete(attachment, it->key, reason)) |
| 437 return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 437 return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
| 438 if (!attachment->isValid()) { | 438 if (!attachment->isValid()) { |
| 439 *reason = "attachment is not valid"; | 439 *reason = "attachment is not valid"; |
| 440 return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; | 440 return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; |
| 441 } | 441 } |
| 442 WebGLSharedObject* object = attachment->getObject(); |
| 443 if (object && !object->isAcquiredForContext(context, neededAccessMode, t
rue, 0, reason)) |
| 444 return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
| 442 if (!attachment->getFormat()) { | 445 if (!attachment->getFormat()) { |
| 443 *reason = "attachment is an unsupported format"; | 446 *reason = "attachment is an unsupported format"; |
| 444 return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 447 return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
| 445 } | 448 } |
| 446 switch (it->key) { | 449 switch (it->key) { |
| 447 case GraphicsContext3D::DEPTH_ATTACHMENT: | 450 case GraphicsContext3D::DEPTH_ATTACHMENT: |
| 448 haveDepth = true; | 451 haveDepth = true; |
| 449 break; | 452 break; |
| 450 case GraphicsContext3D::STENCIL_ATTACHMENT: | 453 case GraphicsContext3D::STENCIL_ATTACHMENT: |
| 451 haveStencil = true; | 454 haveStencil = true; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 474 return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 477 return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
| 475 } | 478 } |
| 476 // WebGL specific: no conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments. | 479 // WebGL specific: no conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments. |
| 477 if ((haveDepthStencil && (haveDepth || haveStencil)) || (haveDepth && haveSt
encil)) { | 480 if ((haveDepthStencil && (haveDepth || haveStencil)) || (haveDepth && haveSt
encil)) { |
| 478 *reason = "conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments"; | 481 *reason = "conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments"; |
| 479 return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; | 482 return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; |
| 480 } | 483 } |
| 481 return GraphicsContext3D::FRAMEBUFFER_COMPLETE; | 484 return GraphicsContext3D::FRAMEBUFFER_COMPLETE; |
| 482 } | 485 } |
| 483 | 486 |
| 484 bool WebGLFramebuffer::onAccess(GraphicsContext3D* context3d, const char** reaso
n) | 487 bool WebGLFramebuffer::onAccess(WebGLRenderingContext* context, WebGLSharedObjec
t::AcquireMode neededAccessMode, const char** reason) |
| 485 { | 488 { |
| 486 if (checkStatus(reason) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) | 489 if (checkStatus(context, neededAccessMode, reason) != GraphicsContext3D::FRA
MEBUFFER_COMPLETE) |
| 487 return false; | 490 return false; |
| 488 return true; | 491 return true; |
| 489 } | 492 } |
| 490 | 493 |
| 491 bool WebGLFramebuffer::hasStencilBuffer() const | 494 bool WebGLFramebuffer::hasStencilBuffer() const |
| 492 { | 495 { |
| 493 WebGLAttachment* attachment = getAttachment(GraphicsContext3D::STENCIL_ATTAC
HMENT); | 496 WebGLAttachment* attachment = getAttachment(GraphicsContext3D::STENCIL_ATTAC
HMENT); |
| 494 if (!attachment) | 497 if (!attachment) |
| 495 attachment = getAttachment(GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT); | 498 attachment = getAttachment(GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT); |
| 496 return attachment && attachment->isValid(); | 499 return attachment && attachment->isValid(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 int index = static_cast<int>(drawBuffer - Extensions3D::DRAW_BUFFER0_EXT); | 551 int index = static_cast<int>(drawBuffer - Extensions3D::DRAW_BUFFER0_EXT); |
| 549 ASSERT(index >= 0); | 552 ASSERT(index >= 0); |
| 550 if (index < static_cast<int>(m_drawBuffers.size())) | 553 if (index < static_cast<int>(m_drawBuffers.size())) |
| 551 return m_drawBuffers[index]; | 554 return m_drawBuffers[index]; |
| 552 if (drawBuffer == Extensions3D::DRAW_BUFFER0_EXT) | 555 if (drawBuffer == Extensions3D::DRAW_BUFFER0_EXT) |
| 553 return GraphicsContext3D::COLOR_ATTACHMENT0; | 556 return GraphicsContext3D::COLOR_ATTACHMENT0; |
| 554 return GraphicsContext3D::NONE; | 557 return GraphicsContext3D::NONE; |
| 555 } | 558 } |
| 556 | 559 |
| 557 } | 560 } |
| OLD | NEW |