| 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 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 class WebGLRenderbufferAttachment final | 37 class WebGLRenderbufferAttachment final |
| 38 : public WebGLFramebuffer::WebGLAttachment { | 38 : public WebGLFramebuffer::WebGLAttachment { |
| 39 public: | 39 public: |
| 40 static WebGLFramebuffer::WebGLAttachment* create(WebGLRenderbuffer*); | 40 static WebGLFramebuffer::WebGLAttachment* create(WebGLRenderbuffer*); |
| 41 | 41 |
| 42 DECLARE_VIRTUAL_TRACE(); | 42 DECLARE_VIRTUAL_TRACE(); |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*); | 45 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*); |
| 46 WebGLRenderbufferAttachment() {} | |
| 47 | 46 |
| 48 WebGLSharedObject* object() const override; | 47 WebGLSharedObject* object() const override; |
| 49 bool isSharedObject(WebGLSharedObject*) const override; | 48 bool isSharedObject(WebGLSharedObject*) const override; |
| 50 bool valid() const override; | 49 bool valid() const override; |
| 51 void onDetached(gpu::gles2::GLES2Interface*) override; | 50 void onDetached(gpu::gles2::GLES2Interface*) override; |
| 52 void attach(gpu::gles2::GLES2Interface*, | 51 void attach(gpu::gles2::GLES2Interface*, |
| 53 GLenum target, | 52 GLenum target, |
| 54 GLenum attachment) override; | 53 GLenum attachment) override; |
| 55 void unattach(gpu::gles2::GLES2Interface*, | 54 void unattach(gpu::gles2::GLES2Interface*, |
| 56 GLenum target, | 55 GLenum target, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 GLint level, | 109 GLint level, |
| 111 GLint layer); | 110 GLint layer); |
| 112 | 111 |
| 113 DECLARE_VIRTUAL_TRACE(); | 112 DECLARE_VIRTUAL_TRACE(); |
| 114 | 113 |
| 115 private: | 114 private: |
| 116 WebGLTextureAttachment(WebGLTexture*, | 115 WebGLTextureAttachment(WebGLTexture*, |
| 117 GLenum target, | 116 GLenum target, |
| 118 GLint level, | 117 GLint level, |
| 119 GLint layer); | 118 GLint layer); |
| 120 WebGLTextureAttachment() {} | |
| 121 | 119 |
| 122 WebGLSharedObject* object() const override; | 120 WebGLSharedObject* object() const override; |
| 123 bool isSharedObject(WebGLSharedObject*) const override; | 121 bool isSharedObject(WebGLSharedObject*) const override; |
| 124 bool valid() const override; | 122 bool valid() const override; |
| 125 void onDetached(gpu::gles2::GLES2Interface*) override; | 123 void onDetached(gpu::gles2::GLES2Interface*) override; |
| 126 void attach(gpu::gles2::GLES2Interface*, | 124 void attach(gpu::gles2::GLES2Interface*, |
| 127 GLenum target, | 125 GLenum target, |
| 128 GLenum attachment) override; | 126 GLenum attachment) override; |
| 129 void unattach(gpu::gles2::GLES2Interface*, | 127 void unattach(gpu::gles2::GLES2Interface*, |
| 130 GLenum target, | 128 GLenum target, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 gl->FramebufferTextureLayer(target, attachment, 0, m_level, m_layer); | 188 gl->FramebufferTextureLayer(target, attachment, 0, m_level, m_layer); |
| 191 } else { | 189 } else { |
| 192 gl->FramebufferTexture2D(target, attachment, m_target, 0, m_level); | 190 gl->FramebufferTexture2D(target, attachment, m_target, 0, m_level); |
| 193 } | 191 } |
| 194 } | 192 } |
| 195 | 193 |
| 196 } // anonymous namespace | 194 } // anonymous namespace |
| 197 | 195 |
| 198 WebGLFramebuffer::WebGLAttachment::WebGLAttachment() {} | 196 WebGLFramebuffer::WebGLAttachment::WebGLAttachment() {} |
| 199 | 197 |
| 200 WebGLFramebuffer::WebGLAttachment::~WebGLAttachment() {} | |
| 201 | |
| 202 WebGLFramebuffer* WebGLFramebuffer::create(WebGLRenderingContextBase* ctx) { | 198 WebGLFramebuffer* WebGLFramebuffer::create(WebGLRenderingContextBase* ctx) { |
| 203 return new WebGLFramebuffer(ctx); | 199 return new WebGLFramebuffer(ctx); |
| 204 } | 200 } |
| 205 | 201 |
| 206 WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContextBase* ctx) | 202 WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContextBase* ctx) |
| 207 : WebGLContextObject(ctx), | 203 : WebGLContextObject(ctx), |
| 208 m_object(0), | 204 m_object(0), |
| 209 m_destructionInProgress(false), | |
| 210 m_hasEverBeenBound(false), | 205 m_hasEverBeenBound(false), |
| 211 m_webGL1DepthStencilConsistent(true), | 206 m_webGL1DepthStencilConsistent(true), |
| 212 m_readBuffer(GL_COLOR_ATTACHMENT0) { | 207 m_readBuffer(GL_COLOR_ATTACHMENT0) { |
| 213 ctx->contextGL()->GenFramebuffers(1, &m_object); | 208 ctx->contextGL()->GenFramebuffers(1, &m_object); |
| 214 } | 209 } |
| 215 | 210 |
| 216 WebGLFramebuffer::~WebGLFramebuffer() { | 211 WebGLFramebuffer::~WebGLFramebuffer() { |
| 217 // Attachments in |m_attachments| will be deleted from other | 212 runDestructor(); |
| 218 // places, and we must not touch that map in deleteObjectImpl once | |
| 219 // the destructor has been entered. | |
| 220 m_destructionInProgress = true; | |
| 221 | |
| 222 // See the comment in WebGLObject::detachAndDeleteObject(). | |
| 223 detachAndDeleteObject(); | |
| 224 } | 213 } |
| 225 | 214 |
| 226 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, | 215 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, |
| 227 GLenum attachment, | 216 GLenum attachment, |
| 228 GLenum texTarget, | 217 GLenum texTarget, |
| 229 WebGLTexture* texture, | 218 WebGLTexture* texture, |
| 230 GLint level, | 219 GLint level, |
| 231 GLint layer) { | 220 GLint layer) { |
| 232 DCHECK(m_object); | 221 DCHECK(m_object); |
| 233 DCHECK(isBound(target)); | 222 DCHECK(isBound(target)); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 attachment = getAttachment(GL_DEPTH_STENCIL_ATTACHMENT); | 365 attachment = getAttachment(GL_DEPTH_STENCIL_ATTACHMENT); |
| 377 return attachment && attachment->valid(); | 366 return attachment && attachment->valid(); |
| 378 } | 367 } |
| 379 | 368 |
| 380 void WebGLFramebuffer::deleteObjectImpl(gpu::gles2::GLES2Interface* gl) { | 369 void WebGLFramebuffer::deleteObjectImpl(gpu::gles2::GLES2Interface* gl) { |
| 381 // Both the AttachmentMap and its WebGLAttachment objects are GCed | 370 // Both the AttachmentMap and its WebGLAttachment objects are GCed |
| 382 // objects and cannot be accessed after the destructor has been | 371 // objects and cannot be accessed after the destructor has been |
| 383 // entered, as they may have been finalized already during the | 372 // entered, as they may have been finalized already during the |
| 384 // same GC sweep. These attachments' OpenGL objects will be fully | 373 // same GC sweep. These attachments' OpenGL objects will be fully |
| 385 // destroyed once their JavaScript wrappers are collected. | 374 // destroyed once their JavaScript wrappers are collected. |
| 386 if (!m_destructionInProgress) { | 375 if (!destructionInProgress()) { |
| 387 for (const auto& attachment : m_attachments) | 376 for (const auto& attachment : m_attachments) |
| 388 attachment.value->onDetached(gl); | 377 attachment.value->onDetached(gl); |
| 389 } | 378 } |
| 390 | 379 |
| 391 gl->DeleteFramebuffers(1, &m_object); | 380 gl->DeleteFramebuffers(1, &m_object); |
| 392 m_object = 0; | 381 m_object = 0; |
| 393 } | 382 } |
| 394 | 383 |
| 395 bool WebGLFramebuffer::isBound(GLenum target) const { | 384 bool WebGLFramebuffer::isBound(GLenum target) const { |
| 396 return (context()->getFramebufferBinding(target) == this); | 385 return (context()->getFramebufferBinding(target) == this); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 } | 539 } |
| 551 | 540 |
| 552 DEFINE_TRACE_WRAPPERS(WebGLFramebuffer) { | 541 DEFINE_TRACE_WRAPPERS(WebGLFramebuffer) { |
| 553 for (const auto& attachment : m_attachments) { | 542 for (const auto& attachment : m_attachments) { |
| 554 visitor->traceWrappers(attachment.value->object()); | 543 visitor->traceWrappers(attachment.value->object()); |
| 555 } | 544 } |
| 556 WebGLContextObject::traceWrappers(visitor); | 545 WebGLContextObject::traceWrappers(visitor); |
| 557 } | 546 } |
| 558 | 547 |
| 559 } // namespace blink | 548 } // namespace blink |
| OLD | NEW |