| 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 { | 194 { |
| 195 } | 195 } |
| 196 | 196 |
| 197 WebGLFramebuffer* WebGLFramebuffer::create(WebGLRenderingContextBase* ctx) | 197 WebGLFramebuffer* WebGLFramebuffer::create(WebGLRenderingContextBase* ctx) |
| 198 { | 198 { |
| 199 return new WebGLFramebuffer(ctx); | 199 return new WebGLFramebuffer(ctx); |
| 200 } | 200 } |
| 201 | 201 |
| 202 WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContextBase* ctx) | 202 WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContextBase* ctx) |
| 203 : WebGLContextObject(ctx) | 203 : WebGLContextObject(ctx) |
| 204 , m_object(ctx->webContext()->createFramebuffer()) | 204 , m_object(0) |
| 205 , m_destructionInProgress(false) | 205 , m_destructionInProgress(false) |
| 206 , m_hasEverBeenBound(false) | 206 , m_hasEverBeenBound(false) |
| 207 , m_readBuffer(GL_COLOR_ATTACHMENT0) | 207 , m_readBuffer(GL_COLOR_ATTACHMENT0) |
| 208 { | 208 { |
| 209 ctx->contextGL()->GenFramebuffers(1, &m_object); |
| 209 } | 210 } |
| 210 | 211 |
| 211 WebGLFramebuffer::~WebGLFramebuffer() | 212 WebGLFramebuffer::~WebGLFramebuffer() |
| 212 { | 213 { |
| 213 // Attachments in |m_attachments| will be deleted from other | 214 // Attachments in |m_attachments| will be deleted from other |
| 214 // places, and we must not touch that map in deleteObjectImpl once | 215 // places, and we must not touch that map in deleteObjectImpl once |
| 215 // the destructor has been entered. | 216 // the destructor has been entered. |
| 216 m_destructionInProgress = true; | 217 m_destructionInProgress = true; |
| 217 | 218 |
| 218 // See the comment in WebGLObject::detachAndDeleteObject(). | 219 // See the comment in WebGLObject::detachAndDeleteObject(). |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 // Both the AttachmentMap and its WebGLAttachment objects are GCed | 361 // Both the AttachmentMap and its WebGLAttachment objects are GCed |
| 361 // objects and cannot be accessed after the destructor has been | 362 // objects and cannot be accessed after the destructor has been |
| 362 // entered, as they may have been finalized already during the | 363 // entered, as they may have been finalized already during the |
| 363 // same GC sweep. These attachments' OpenGL objects will be fully | 364 // same GC sweep. These attachments' OpenGL objects will be fully |
| 364 // destroyed once their JavaScript wrappers are collected. | 365 // destroyed once their JavaScript wrappers are collected. |
| 365 if (!m_destructionInProgress) { | 366 if (!m_destructionInProgress) { |
| 366 for (const auto& attachment : m_attachments) | 367 for (const auto& attachment : m_attachments) |
| 367 attachment.value->onDetached(context3d, gl); | 368 attachment.value->onDetached(context3d, gl); |
| 368 } | 369 } |
| 369 | 370 |
| 370 context3d->deleteFramebuffer(m_object); | 371 gl->DeleteFramebuffers(1, &m_object); |
| 371 m_object = 0; | 372 m_object = 0; |
| 372 } | 373 } |
| 373 | 374 |
| 374 bool WebGLFramebuffer::isBound(GLenum target) const | 375 bool WebGLFramebuffer::isBound(GLenum target) const |
| 375 { | 376 { |
| 376 return (context()->getFramebufferBinding(target) == this); | 377 return (context()->getFramebufferBinding(target) == this); |
| 377 } | 378 } |
| 378 | 379 |
| 379 void WebGLFramebuffer::drawBuffers(const Vector<GLenum>& bufs) | 380 void WebGLFramebuffer::drawBuffers(const Vector<GLenum>& bufs) |
| 380 { | 381 { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 return GL_NONE; | 423 return GL_NONE; |
| 423 } | 424 } |
| 424 | 425 |
| 425 DEFINE_TRACE(WebGLFramebuffer) | 426 DEFINE_TRACE(WebGLFramebuffer) |
| 426 { | 427 { |
| 427 visitor->trace(m_attachments); | 428 visitor->trace(m_attachments); |
| 428 WebGLContextObject::trace(visitor); | 429 WebGLContextObject::trace(visitor); |
| 429 } | 430 } |
| 430 | 431 |
| 431 } // namespace blink | 432 } // namespace blink |
| OLD | NEW |