| 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 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 | 27 |
| 28 #include "core/html/canvas/WebGLFramebuffer.h" | 28 #include "core/html/canvas/WebGLFramebuffer.h" |
| 29 | 29 |
| 30 #include "core/html/canvas/WebGLRenderingContextBase.h" | 30 #include "core/html/canvas/WebGLRenderingContextBase.h" |
| 31 #include "platform/NotImplemented.h" | 31 #include "platform/NotImplemented.h" |
| 32 #include "wtf/Vector.h" |
| 32 | 33 |
| 33 namespace blink { | 34 namespace blink { |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 Platform3DObject objectOrZero(WebGLObject* object) | 38 Platform3DObject objectOrZero(WebGLObject* object) |
| 38 { | 39 { |
| 39 return object ? object->object() : 0; | 40 return object ? object->object() : 0; |
| 40 } | 41 } |
| 41 | 42 |
| 42 class WebGLRenderbufferAttachment final : public WebGLFramebuffer::WebGLAtta
chment { | 43 class WebGLRenderbufferAttachment final : public WebGLFramebuffer::WebGLAtta
chment { |
| 43 public: | 44 public: |
| 44 static PassRefPtr<WebGLFramebuffer::WebGLAttachment> create(WebGLRenderb
uffer*); | 45 static PassRefPtr<WebGLFramebuffer::WebGLAttachment> create(WebGLRenderb
uffer*); |
| 45 | 46 |
| 46 virtual void trace(Visitor*) override; | |
| 47 | |
| 48 private: | 47 private: |
| 49 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*); | 48 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*); |
| 50 WebGLRenderbufferAttachment() { } | 49 WebGLRenderbufferAttachment() { } |
| 51 | 50 |
| 52 virtual GLsizei width() const override; | 51 virtual GLsizei width() const override; |
| 53 virtual GLsizei height() const override; | 52 virtual GLsizei height() const override; |
| 54 virtual GLenum format() const override; | 53 virtual GLenum format() const override; |
| 55 virtual GLenum type() const override; | 54 virtual GLenum type() const override; |
| 56 virtual WebGLSharedObject* object() const override; | 55 virtual WebGLSharedObject* object() const override; |
| 57 virtual bool isSharedObject(WebGLSharedObject*) const override; | 56 virtual bool isSharedObject(WebGLSharedObject*) const override; |
| 58 virtual bool valid() const override; | 57 virtual bool valid() const override; |
| 59 virtual void onDetached(blink::WebGraphicsContext3D*) override; | 58 virtual void onDetached(blink::WebGraphicsContext3D*) override; |
| 60 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) ove
rride; | 59 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) ove
rride; |
| 61 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) o
verride; | 60 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) o
verride; |
| 62 | 61 |
| 63 RefPtr<WebGLRenderbuffer> m_renderbuffer; | 62 RefPtr<WebGLRenderbuffer> m_renderbuffer; |
| 64 }; | 63 }; |
| 65 | 64 |
| 66 PassRefPtr<WebGLFramebuffer::WebGLAttachment> WebGLRenderbufferAttachment::c
reate(WebGLRenderbuffer* renderbuffer) | 65 PassRefPtr<WebGLFramebuffer::WebGLAttachment> WebGLRenderbufferAttachment::c
reate(WebGLRenderbuffer* renderbuffer) |
| 67 { | 66 { |
| 68 return adoptRef(new WebGLRenderbufferAttachment(renderbuffer)); | 67 return adoptRef(new WebGLRenderbufferAttachment(renderbuffer)); |
| 69 } | 68 } |
| 70 | 69 |
| 71 void WebGLRenderbufferAttachment::trace(Visitor* visitor) | |
| 72 { | |
| 73 visitor->trace(m_renderbuffer); | |
| 74 WebGLFramebuffer::WebGLAttachment::trace(visitor); | |
| 75 } | |
| 76 | |
| 77 WebGLRenderbufferAttachment::WebGLRenderbufferAttachment(WebGLRenderbuffer*
renderbuffer) | 70 WebGLRenderbufferAttachment::WebGLRenderbufferAttachment(WebGLRenderbuffer*
renderbuffer) |
| 78 : m_renderbuffer(renderbuffer) | 71 : m_renderbuffer(renderbuffer) |
| 79 { | 72 { |
| 80 } | 73 } |
| 81 | 74 |
| 82 GLsizei WebGLRenderbufferAttachment::width() const | 75 GLsizei WebGLRenderbufferAttachment::width() const |
| 83 { | 76 { |
| 84 return m_renderbuffer->width(); | 77 return m_renderbuffer->width(); |
| 85 } | 78 } |
| 86 | 79 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 GLenum WebGLRenderbufferAttachment::type() const | 137 GLenum WebGLRenderbufferAttachment::type() const |
| 145 { | 138 { |
| 146 notImplemented(); | 139 notImplemented(); |
| 147 return 0; | 140 return 0; |
| 148 } | 141 } |
| 149 | 142 |
| 150 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachmen
t { | 143 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachmen
t { |
| 151 public: | 144 public: |
| 152 static PassRefPtr<WebGLFramebuffer::WebGLAttachment> create(WebGLTexture
*, GLenum target, GLint level); | 145 static PassRefPtr<WebGLFramebuffer::WebGLAttachment> create(WebGLTexture
*, GLenum target, GLint level); |
| 153 | 146 |
| 154 virtual void trace(Visitor*) override; | |
| 155 | |
| 156 private: | 147 private: |
| 157 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level); | 148 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level); |
| 158 WebGLTextureAttachment() { } | 149 WebGLTextureAttachment() { } |
| 159 | 150 |
| 160 virtual GLsizei width() const override; | 151 virtual GLsizei width() const override; |
| 161 virtual GLsizei height() const override; | 152 virtual GLsizei height() const override; |
| 162 virtual GLenum format() const override; | 153 virtual GLenum format() const override; |
| 163 virtual GLenum type() const override; | 154 virtual GLenum type() const override; |
| 164 virtual WebGLSharedObject* object() const override; | 155 virtual WebGLSharedObject* object() const override; |
| 165 virtual bool isSharedObject(WebGLSharedObject*) const override; | 156 virtual bool isSharedObject(WebGLSharedObject*) const override; |
| 166 virtual bool valid() const override; | 157 virtual bool valid() const override; |
| 167 virtual void onDetached(blink::WebGraphicsContext3D*) override; | 158 virtual void onDetached(blink::WebGraphicsContext3D*) override; |
| 168 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) ove
rride; | 159 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) ove
rride; |
| 169 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) o
verride; | 160 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) o
verride; |
| 170 | 161 |
| 171 RefPtr<WebGLTexture> m_texture; | 162 RefPtr<WebGLTexture> m_texture; |
| 172 GLenum m_target; | 163 GLenum m_target; |
| 173 GLint m_level; | 164 GLint m_level; |
| 174 }; | 165 }; |
| 175 | 166 |
| 176 PassRefPtr<WebGLFramebuffer::WebGLAttachment> WebGLTextureAttachment::create
(WebGLTexture* texture, GLenum target, GLint level) | 167 PassRefPtr<WebGLFramebuffer::WebGLAttachment> WebGLTextureAttachment::create
(WebGLTexture* texture, GLenum target, GLint level) |
| 177 { | 168 { |
| 178 return adoptRef(new WebGLTextureAttachment(texture, target, level)); | 169 return adoptRef(new WebGLTextureAttachment(texture, target, level)); |
| 179 } | 170 } |
| 180 | 171 |
| 181 void WebGLTextureAttachment::trace(Visitor* visitor) | |
| 182 { | |
| 183 visitor->trace(m_texture); | |
| 184 WebGLFramebuffer::WebGLAttachment::trace(visitor); | |
| 185 } | |
| 186 | |
| 187 WebGLTextureAttachment::WebGLTextureAttachment(WebGLTexture* texture, GLenum
target, GLint level) | 172 WebGLTextureAttachment::WebGLTextureAttachment(WebGLTexture* texture, GLenum
target, GLint level) |
| 188 : m_texture(texture) | 173 : m_texture(texture) |
| 189 , m_target(target) | 174 , m_target(target) |
| 190 , m_level(level) | 175 , m_level(level) |
| 191 { | 176 { |
| 192 } | 177 } |
| 193 | 178 |
| 194 GLsizei WebGLTextureAttachment::width() const | 179 GLsizei WebGLTextureAttachment::width() const |
| 195 { | 180 { |
| 196 return m_texture->getWidth(m_target, m_level); | 181 return m_texture->getWidth(m_target, m_level); |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 { | 606 { |
| 622 int index = static_cast<int>(drawBuffer - GL_DRAW_BUFFER0_EXT); | 607 int index = static_cast<int>(drawBuffer - GL_DRAW_BUFFER0_EXT); |
| 623 ASSERT(index >= 0); | 608 ASSERT(index >= 0); |
| 624 if (index < static_cast<int>(m_drawBuffers.size())) | 609 if (index < static_cast<int>(m_drawBuffers.size())) |
| 625 return m_drawBuffers[index]; | 610 return m_drawBuffers[index]; |
| 626 if (drawBuffer == GL_DRAW_BUFFER0_EXT) | 611 if (drawBuffer == GL_DRAW_BUFFER0_EXT) |
| 627 return GL_COLOR_ATTACHMENT0; | 612 return GL_COLOR_ATTACHMENT0; |
| 628 return GL_NONE; | 613 return GL_NONE; |
| 629 } | 614 } |
| 630 | 615 |
| 631 void WebGLFramebuffer::trace(Visitor* visitor) | |
| 632 { | |
| 633 #if ENABLE(OILPAN) | |
| 634 visitor->trace(m_attachments); | |
| 635 #endif | |
| 636 WebGLContextObject::trace(visitor); | |
| 637 } | 616 } |
| 638 | |
| 639 } | |
| OLD | NEW |