| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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 "modules/webgl/WebGLFramebuffer.h" | 26 #include "modules/webgl/WebGLFramebuffer.h" |
| 27 | 27 |
| 28 #include "gpu/command_buffer/client/gles2_interface.h" |
| 28 #include "modules/webgl/WebGLRenderbuffer.h" | 29 #include "modules/webgl/WebGLRenderbuffer.h" |
| 29 #include "modules/webgl/WebGLRenderingContextBase.h" | 30 #include "modules/webgl/WebGLRenderingContextBase.h" |
| 30 #include "modules/webgl/WebGLTexture.h" | 31 #include "modules/webgl/WebGLTexture.h" |
| 31 #include "platform/NotImplemented.h" | 32 #include "platform/NotImplemented.h" |
| 32 | 33 |
| 33 namespace blink { | 34 namespace blink { |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 class WebGLRenderbufferAttachment final : public WebGLFramebuffer::WebGLAttachme
nt { | 38 class WebGLRenderbufferAttachment final : public WebGLFramebuffer::WebGLAttachme
nt { |
| 38 public: | 39 public: |
| 39 static WebGLFramebuffer::WebGLAttachment* create(WebGLRenderbuffer*); | 40 static WebGLFramebuffer::WebGLAttachment* create(WebGLRenderbuffer*); |
| 40 | 41 |
| 41 DECLARE_VIRTUAL_TRACE(); | 42 DECLARE_VIRTUAL_TRACE(); |
| 42 | 43 |
| 43 private: | 44 private: |
| 44 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*); | 45 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*); |
| 45 WebGLRenderbufferAttachment() { } | 46 WebGLRenderbufferAttachment() { } |
| 46 | 47 |
| 47 WebGLSharedObject* object() const override; | 48 WebGLSharedObject* object() const override; |
| 48 bool isSharedObject(WebGLSharedObject*) const override; | 49 bool isSharedObject(WebGLSharedObject*) const override; |
| 49 bool valid() const override; | 50 bool valid() const override; |
| 50 void onDetached(WebGraphicsContext3D*) override; | 51 void onDetached(WebGraphicsContext3D*) override; |
| 51 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid
e; | 52 void attach(gpu::gles2::GLES2Interface*, GLenum target, GLenum attachment) o
verride; |
| 52 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr
ide; | 53 void unattach(gpu::gles2::GLES2Interface*, GLenum target, GLenum attachment)
override; |
| 53 | 54 |
| 54 Member<WebGLRenderbuffer> m_renderbuffer; | 55 Member<WebGLRenderbuffer> m_renderbuffer; |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 WebGLFramebuffer::WebGLAttachment* WebGLRenderbufferAttachment::create(WebGLRend
erbuffer* renderbuffer) | 58 WebGLFramebuffer::WebGLAttachment* WebGLRenderbufferAttachment::create(WebGLRend
erbuffer* renderbuffer) |
| 58 { | 59 { |
| 59 return new WebGLRenderbufferAttachment(renderbuffer); | 60 return new WebGLRenderbufferAttachment(renderbuffer); |
| 60 } | 61 } |
| 61 | 62 |
| 62 DEFINE_TRACE(WebGLRenderbufferAttachment) | 63 DEFINE_TRACE(WebGLRenderbufferAttachment) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 83 bool WebGLRenderbufferAttachment::valid() const | 84 bool WebGLRenderbufferAttachment::valid() const |
| 84 { | 85 { |
| 85 return m_renderbuffer->object(); | 86 return m_renderbuffer->object(); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void WebGLRenderbufferAttachment::onDetached(WebGraphicsContext3D* context) | 89 void WebGLRenderbufferAttachment::onDetached(WebGraphicsContext3D* context) |
| 89 { | 90 { |
| 90 m_renderbuffer->onDetached(context); | 91 m_renderbuffer->onDetached(context); |
| 91 } | 92 } |
| 92 | 93 |
| 93 void WebGLRenderbufferAttachment::attach(WebGraphicsContext3D* context, GLenum t
arget, GLenum attachment) | 94 void WebGLRenderbufferAttachment::attach(gpu::gles2::GLES2Interface* gl, GLenum
target, GLenum attachment) |
| 94 { | 95 { |
| 95 Platform3DObject object = objectOrZero(m_renderbuffer.get()); | 96 Platform3DObject object = objectOrZero(m_renderbuffer.get()); |
| 96 context->framebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, object
); | 97 gl->FramebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, object); |
| 97 } | 98 } |
| 98 | 99 |
| 99 void WebGLRenderbufferAttachment::unattach(WebGraphicsContext3D* context, GLenum
target, GLenum attachment) | 100 void WebGLRenderbufferAttachment::unattach(gpu::gles2::GLES2Interface* gl, GLenu
m target, GLenum attachment) |
| 100 { | 101 { |
| 101 context->framebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, 0); | 102 gl->FramebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, 0); |
| 102 } | 103 } |
| 103 | 104 |
| 104 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachment { | 105 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachment { |
| 105 public: | 106 public: |
| 106 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe
t, GLint level, GLint layer); | 107 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe
t, GLint level, GLint layer); |
| 107 | 108 |
| 108 DECLARE_VIRTUAL_TRACE(); | 109 DECLARE_VIRTUAL_TRACE(); |
| 109 | 110 |
| 110 private: | 111 private: |
| 111 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level, GLint laye
r); | 112 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level, GLint laye
r); |
| 112 WebGLTextureAttachment() { } | 113 WebGLTextureAttachment() { } |
| 113 | 114 |
| 114 WebGLSharedObject* object() const override; | 115 WebGLSharedObject* object() const override; |
| 115 bool isSharedObject(WebGLSharedObject*) const override; | 116 bool isSharedObject(WebGLSharedObject*) const override; |
| 116 bool valid() const override; | 117 bool valid() const override; |
| 117 void onDetached(WebGraphicsContext3D*) override; | 118 void onDetached(WebGraphicsContext3D*) override; |
| 118 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid
e; | 119 void attach(gpu::gles2::GLES2Interface*, GLenum target, GLenum attachment) o
verride; |
| 119 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr
ide; | 120 void unattach(gpu::gles2::GLES2Interface*, GLenum target, GLenum attachment)
override; |
| 120 | 121 |
| 121 Member<WebGLTexture> m_texture; | 122 Member<WebGLTexture> m_texture; |
| 122 GLenum m_target; | 123 GLenum m_target; |
| 123 GLint m_level; | 124 GLint m_level; |
| 124 GLint m_layer; | 125 GLint m_layer; |
| 125 }; | 126 }; |
| 126 | 127 |
| 127 WebGLFramebuffer::WebGLAttachment* WebGLTextureAttachment::create(WebGLTexture*
texture, GLenum target, GLint level, GLint layer) | 128 WebGLFramebuffer::WebGLAttachment* WebGLTextureAttachment::create(WebGLTexture*
texture, GLenum target, GLint level, GLint layer) |
| 128 { | 129 { |
| 129 return new WebGLTextureAttachment(texture, target, level, layer); | 130 return new WebGLTextureAttachment(texture, target, level, layer); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 156 bool WebGLTextureAttachment::valid() const | 157 bool WebGLTextureAttachment::valid() const |
| 157 { | 158 { |
| 158 return m_texture->object(); | 159 return m_texture->object(); |
| 159 } | 160 } |
| 160 | 161 |
| 161 void WebGLTextureAttachment::onDetached(WebGraphicsContext3D* context) | 162 void WebGLTextureAttachment::onDetached(WebGraphicsContext3D* context) |
| 162 { | 163 { |
| 163 m_texture->onDetached(context); | 164 m_texture->onDetached(context); |
| 164 } | 165 } |
| 165 | 166 |
| 166 void WebGLTextureAttachment::attach(WebGraphicsContext3D* context, GLenum target
, GLenum attachment) | 167 void WebGLTextureAttachment::attach(gpu::gles2::GLES2Interface* gl, GLenum targe
t, GLenum attachment) |
| 167 { | 168 { |
| 168 Platform3DObject object = objectOrZero(m_texture.get()); | 169 Platform3DObject object = objectOrZero(m_texture.get()); |
| 169 if (m_target == GL_TEXTURE_3D || m_target == GL_TEXTURE_2D_ARRAY) { | 170 if (m_target == GL_TEXTURE_3D || m_target == GL_TEXTURE_2D_ARRAY) { |
| 170 context->framebufferTextureLayer(target, attachment, object, m_level, m_
layer); | 171 gl->FramebufferTextureLayer(target, attachment, object, m_level, m_layer
); |
| 171 } else { | 172 } else { |
| 172 context->framebufferTexture2D(target, attachment, m_target, object, m_le
vel); | 173 gl->FramebufferTexture2D(target, attachment, m_target, object, m_level); |
| 173 } | 174 } |
| 174 } | 175 } |
| 175 | 176 |
| 176 void WebGLTextureAttachment::unattach(WebGraphicsContext3D* context, GLenum targ
et, GLenum attachment) | 177 void WebGLTextureAttachment::unattach(gpu::gles2::GLES2Interface* gl, GLenum tar
get, GLenum attachment) |
| 177 { | 178 { |
| 178 // GL_DEPTH_STENCIL_ATTACHMENT attachment is valid in ES3. | 179 // GL_DEPTH_STENCIL_ATTACHMENT attachment is valid in ES3. |
| 179 if (m_target == GL_TEXTURE_3D || m_target == GL_TEXTURE_2D_ARRAY) { | 180 if (m_target == GL_TEXTURE_3D || m_target == GL_TEXTURE_2D_ARRAY) { |
| 180 context->framebufferTextureLayer(target, attachment, 0, m_level, m_layer
); | 181 gl->FramebufferTextureLayer(target, attachment, 0, m_level, m_layer); |
| 181 } else { | 182 } else { |
| 182 context->framebufferTexture2D(target, attachment, m_target, 0, m_level); | 183 gl->FramebufferTexture2D(target, attachment, m_target, 0, m_level); |
| 183 } | 184 } |
| 184 } | 185 } |
| 185 | 186 |
| 186 } // anonymous namespace | 187 } // anonymous namespace |
| 187 | 188 |
| 188 WebGLFramebuffer::WebGLAttachment::WebGLAttachment() | 189 WebGLFramebuffer::WebGLAttachment::WebGLAttachment() |
| 189 { | 190 { |
| 190 } | 191 } |
| 191 | 192 |
| 192 WebGLFramebuffer::WebGLAttachment::~WebGLAttachment() | 193 WebGLFramebuffer::WebGLAttachment::~WebGLAttachment() |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 drawBuffersIfNecessary(false); | 243 drawBuffersIfNecessary(false); |
| 243 renderbuffer->onAttached(); | 244 renderbuffer->onAttached(); |
| 244 } | 245 } |
| 245 } | 246 } |
| 246 | 247 |
| 247 void WebGLFramebuffer::attach(GLenum target, GLenum attachment, GLenum attachmen
tPoint) | 248 void WebGLFramebuffer::attach(GLenum target, GLenum attachment, GLenum attachmen
tPoint) |
| 248 { | 249 { |
| 249 ASSERT(isBound(target)); | 250 ASSERT(isBound(target)); |
| 250 WebGLAttachment* attachmentObject = getAttachment(attachment); | 251 WebGLAttachment* attachmentObject = getAttachment(attachment); |
| 251 if (attachmentObject) | 252 if (attachmentObject) |
| 252 attachmentObject->attach(context()->webContext(), target, attachmentPoin
t); | 253 attachmentObject->attach(context()->contextGL(), target, attachmentPoint
); |
| 253 } | 254 } |
| 254 | 255 |
| 255 WebGLSharedObject* WebGLFramebuffer::getAttachmentObject(GLenum attachment) cons
t | 256 WebGLSharedObject* WebGLFramebuffer::getAttachmentObject(GLenum attachment) cons
t |
| 256 { | 257 { |
| 257 if (!m_object) | 258 if (!m_object) |
| 258 return nullptr; | 259 return nullptr; |
| 259 WebGLAttachment* attachmentObject = getAttachment(attachment); | 260 WebGLAttachment* attachmentObject = getAttachment(attachment); |
| 260 return attachmentObject ? attachmentObject->object() : nullptr; | 261 return attachmentObject ? attachmentObject->object() : nullptr; |
| 261 } | 262 } |
| 262 | 263 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 if (!attachment) | 299 if (!attachment) |
| 299 return; | 300 return; |
| 300 | 301 |
| 301 bool checkMore = true; | 302 bool checkMore = true; |
| 302 while (checkMore) { | 303 while (checkMore) { |
| 303 checkMore = false; | 304 checkMore = false; |
| 304 for (const auto& it : m_attachments) { | 305 for (const auto& it : m_attachments) { |
| 305 WebGLAttachment* attachmentObject = it.value.get(); | 306 WebGLAttachment* attachmentObject = it.value.get(); |
| 306 if (attachmentObject->isSharedObject(attachment)) { | 307 if (attachmentObject->isSharedObject(attachment)) { |
| 307 GLenum attachmentType = it.key; | 308 GLenum attachmentType = it.key; |
| 308 attachmentObject->unattach(context()->webContext(), target, atta
chmentType); | 309 attachmentObject->unattach(context()->contextGL(), target, attac
hmentType); |
| 309 removeAttachmentFromBoundFramebuffer(target, attachmentType); | 310 removeAttachmentFromBoundFramebuffer(target, attachmentType); |
| 310 checkMore = true; | 311 checkMore = true; |
| 311 break; | 312 break; |
| 312 } | 313 } |
| 313 } | 314 } |
| 314 } | 315 } |
| 315 } | 316 } |
| 316 | 317 |
| 317 GLenum WebGLFramebuffer::checkDepthStencilStatus(const char** reason) const | 318 GLenum WebGLFramebuffer::checkDepthStencilStatus(const char** reason) const |
| 318 { | 319 { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 return GL_NONE; | 422 return GL_NONE; |
| 422 } | 423 } |
| 423 | 424 |
| 424 DEFINE_TRACE(WebGLFramebuffer) | 425 DEFINE_TRACE(WebGLFramebuffer) |
| 425 { | 426 { |
| 426 visitor->trace(m_attachments); | 427 visitor->trace(m_attachments); |
| 427 WebGLContextObject::trace(visitor); | 428 WebGLContextObject::trace(visitor); |
| 428 } | 429 } |
| 429 | 430 |
| 430 } // namespace blink | 431 } // namespace blink |
| OLD | NEW |