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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 { | 598 { |
599 m_drawBuffers = bufs; | 599 m_drawBuffers = bufs; |
600 m_filteredDrawBuffers.resize(m_drawBuffers.size()); | 600 m_filteredDrawBuffers.resize(m_drawBuffers.size()); |
601 for (size_t i = 0; i < m_filteredDrawBuffers.size(); ++i) | 601 for (size_t i = 0; i < m_filteredDrawBuffers.size(); ++i) |
602 m_filteredDrawBuffers[i] = GL_NONE; | 602 m_filteredDrawBuffers[i] = GL_NONE; |
603 drawBuffersIfNecessary(true); | 603 drawBuffersIfNecessary(true); |
604 } | 604 } |
605 | 605 |
606 void WebGLFramebuffer::drawBuffersIfNecessary(bool force) | 606 void WebGLFramebuffer::drawBuffersIfNecessary(bool force) |
607 { | 607 { |
608 if (!context()->extensionEnabled(WebGLDrawBuffersName)) | 608 if (context()->isWebGL2OrHigher() |
609 return; | 609 || context()->extensionEnabled(WebGLDrawBuffersName)) { |
610 bool reset = force; | 610 bool reset = force; |
611 // This filtering works around graphics driver bugs on Mac OS X. | 611 // This filtering works around graphics driver bugs on Mac OS X. |
612 for (size_t i = 0; i < m_drawBuffers.size(); ++i) { | 612 for (size_t i = 0; i < m_drawBuffers.size(); ++i) { |
613 if (m_drawBuffers[i] != GL_NONE && getAttachment(m_drawBuffers[i])) { | 613 if (m_drawBuffers[i] != GL_NONE && getAttachment(m_drawBuffers[i]))
{ |
614 if (m_filteredDrawBuffers[i] != m_drawBuffers[i]) { | 614 if (m_filteredDrawBuffers[i] != m_drawBuffers[i]) { |
615 m_filteredDrawBuffers[i] = m_drawBuffers[i]; | 615 m_filteredDrawBuffers[i] = m_drawBuffers[i]; |
616 reset = true; | 616 reset = true; |
617 } | 617 } |
618 } else { | 618 } else { |
619 if (m_filteredDrawBuffers[i] != GL_NONE) { | 619 if (m_filteredDrawBuffers[i] != GL_NONE) { |
620 m_filteredDrawBuffers[i] = GL_NONE; | 620 m_filteredDrawBuffers[i] = GL_NONE; |
621 reset = true; | 621 reset = true; |
| 622 } |
622 } | 623 } |
623 } | 624 } |
624 } | 625 if (reset) { |
625 if (reset) { | 626 context()->webContext()->drawBuffersEXT( |
626 context()->webContext()->drawBuffersEXT( | 627 m_filteredDrawBuffers.size(), m_filteredDrawBuffers.data()); |
627 m_filteredDrawBuffers.size(), m_filteredDrawBuffers.data()); | 628 } |
628 } | 629 } |
629 } | 630 } |
630 | 631 |
631 GLenum WebGLFramebuffer::getDrawBuffer(GLenum drawBuffer) | 632 GLenum WebGLFramebuffer::getDrawBuffer(GLenum drawBuffer) |
632 { | 633 { |
633 int index = static_cast<int>(drawBuffer - GL_DRAW_BUFFER0_EXT); | 634 int index = static_cast<int>(drawBuffer - GL_DRAW_BUFFER0_EXT); |
634 ASSERT(index >= 0); | 635 ASSERT(index >= 0); |
635 if (index < static_cast<int>(m_drawBuffers.size())) | 636 if (index < static_cast<int>(m_drawBuffers.size())) |
636 return m_drawBuffers[index]; | 637 return m_drawBuffers[index]; |
637 if (drawBuffer == GL_DRAW_BUFFER0_EXT) | 638 if (drawBuffer == GL_DRAW_BUFFER0_EXT) |
(...skipping 15 matching lines...) Expand all Loading... |
653 return true; | 654 return true; |
654 } | 655 } |
655 | 656 |
656 DEFINE_TRACE(WebGLFramebuffer) | 657 DEFINE_TRACE(WebGLFramebuffer) |
657 { | 658 { |
658 visitor->trace(m_attachments); | 659 visitor->trace(m_attachments); |
659 WebGLContextObject::trace(visitor); | 660 WebGLContextObject::trace(visitor); |
660 } | 661 } |
661 | 662 |
662 } | 663 } |
OLD | NEW |