Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 31 #include "modules/webgl/WebGLRenderingContextBase.h" | 31 #include "modules/webgl/WebGLRenderingContextBase.h" |
| 32 #include "modules/webgl/WebGLTexture.h" | 32 #include "modules/webgl/WebGLTexture.h" |
| 33 #include "platform/NotImplemented.h" | 33 #include "platform/NotImplemented.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 class WebGLRenderbufferAttachment final : public WebGLFramebuffer::WebGLAttachme nt { | 39 class WebGLRenderbufferAttachment final : public WebGLFramebuffer::WebGLAttachme nt { |
| 40 public: | 40 public: |
| 41 static PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> create(WebG LRenderbuffer*); | 41 static WebGLFramebuffer::WebGLAttachment* create(WebGLRenderbuffer*); |
| 42 | 42 |
| 43 DECLARE_VIRTUAL_TRACE(); | 43 DECLARE_VIRTUAL_TRACE(); |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*); | 46 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*); |
| 47 WebGLRenderbufferAttachment() { } | 47 WebGLRenderbufferAttachment() { } |
| 48 | 48 |
| 49 GLsizei width() const override; | 49 GLsizei width() const override; |
| 50 GLsizei height() const override; | 50 GLsizei height() const override; |
| 51 GLenum format() const override; | 51 GLenum format() const override; |
| 52 GLenum type() const override; | 52 GLenum type() const override; |
| 53 WebGLSharedObject* object() const override; | 53 WebGLSharedObject* object() const override; |
| 54 bool isSharedObject(WebGLSharedObject*) const override; | 54 bool isSharedObject(WebGLSharedObject*) const override; |
| 55 bool valid() const override; | 55 bool valid() const override; |
| 56 void onDetached(WebGraphicsContext3D*) override; | 56 void onDetached(WebGraphicsContext3D*) override; |
| 57 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e; | 57 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e; |
| 58 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide; | 58 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide; |
| 59 | 59 |
| 60 RefPtrWillBeMember<WebGLRenderbuffer> m_renderbuffer; | 60 Member<WebGLRenderbuffer> m_renderbuffer; |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> WebGLRenderbufferAttac hment::create(WebGLRenderbuffer* renderbuffer) | 63 WebGLFramebuffer::WebGLAttachment* WebGLRenderbufferAttachment::create(WebGLRend erbuffer* renderbuffer) |
| 64 { | 64 { |
| 65 return adoptRefWillBeNoop(new WebGLRenderbufferAttachment(renderbuffer)); | 65 return new WebGLRenderbufferAttachment(renderbuffer); |
| 66 } | 66 } |
| 67 | 67 |
| 68 DEFINE_TRACE(WebGLRenderbufferAttachment) | 68 DEFINE_TRACE(WebGLRenderbufferAttachment) |
| 69 { | 69 { |
| 70 visitor->trace(m_renderbuffer); | 70 visitor->trace(m_renderbuffer); |
| 71 WebGLFramebuffer::WebGLAttachment::trace(visitor); | 71 WebGLFramebuffer::WebGLAttachment::trace(visitor); |
| 72 } | 72 } |
| 73 | 73 |
| 74 WebGLRenderbufferAttachment::WebGLRenderbufferAttachment(WebGLRenderbuffer* rend erbuffer) | 74 WebGLRenderbufferAttachment::WebGLRenderbufferAttachment(WebGLRenderbuffer* rend erbuffer) |
| 75 : m_renderbuffer(renderbuffer) | 75 : m_renderbuffer(renderbuffer) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { | 133 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
| 134 context->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, GL_RENDERB UFFER, 0); | 134 context->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, GL_RENDERB UFFER, 0); |
| 135 context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, GL_RENDE RBUFFER, 0); | 135 context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, GL_RENDE RBUFFER, 0); |
| 136 } else { | 136 } else { |
| 137 context->framebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, 0) ; | 137 context->framebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, 0) ; |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 GLenum WebGLRenderbufferAttachment::type() const | 141 GLenum WebGLRenderbufferAttachment::type() const |
| 142 { | 142 { |
| 143 notImplemented(); | |
| 143 return 0; | 144 return 0; |
| 144 } | 145 } |
| 145 | 146 |
| 146 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachment { | 147 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachment { |
| 147 public: | 148 public: |
| 148 static PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> create(WebG LTexture*, GLenum target, GLint level); | 149 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe t, GLint level); |
| 149 | 150 |
| 150 DECLARE_VIRTUAL_TRACE(); | 151 DECLARE_VIRTUAL_TRACE(); |
| 151 | 152 |
| 152 private: | 153 private: |
| 153 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level); | 154 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level); |
| 154 WebGLTextureAttachment() { } | 155 WebGLTextureAttachment() { } |
| 155 | 156 |
| 156 GLsizei width() const override; | 157 GLsizei width() const override; |
| 157 GLsizei height() const override; | 158 GLsizei height() const override; |
| 158 GLenum format() const override; | 159 GLenum format() const override; |
| 159 GLenum type() const override; | 160 GLenum type() const override; |
| 160 WebGLSharedObject* object() const override; | 161 WebGLSharedObject* object() const override; |
| 161 bool isSharedObject(WebGLSharedObject*) const override; | 162 bool isSharedObject(WebGLSharedObject*) const override; |
| 162 bool valid() const override; | 163 bool valid() const override; |
| 163 void onDetached(WebGraphicsContext3D*) override; | 164 void onDetached(WebGraphicsContext3D*) override; |
| 164 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e; | 165 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e; |
| 165 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide; | 166 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide; |
| 166 | 167 |
| 167 RefPtrWillBeMember<WebGLTexture> m_texture; | 168 Member<WebGLTexture> m_texture; |
| 168 GLenum m_target; | 169 GLenum m_target; |
| 169 GLint m_level; | 170 GLint m_level; |
| 170 }; | 171 }; |
| 171 | 172 |
| 172 PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> WebGLTextureAttachment ::create(WebGLTexture* texture, GLenum target, GLint level) | 173 WebGLFramebuffer::WebGLAttachment* WebGLTextureAttachment::create(WebGLTexture* texture, GLenum target, GLint level) |
| 173 { | 174 { |
| 174 return adoptRefWillBeNoop(new WebGLTextureAttachment(texture, target, level) ); | 175 return new WebGLTextureAttachment(texture, target, level); |
| 175 } | 176 } |
| 176 | 177 |
| 177 DEFINE_TRACE(WebGLTextureAttachment) | 178 DEFINE_TRACE(WebGLTextureAttachment) |
| 178 { | 179 { |
| 179 visitor->trace(m_texture); | 180 visitor->trace(m_texture); |
| 180 WebGLFramebuffer::WebGLAttachment::trace(visitor); | 181 WebGLFramebuffer::WebGLAttachment::trace(visitor); |
| 181 } | 182 } |
| 182 | 183 |
| 183 WebGLTextureAttachment::WebGLTextureAttachment(WebGLTexture* texture, GLenum tar get, GLint level) | 184 WebGLTextureAttachment::WebGLTextureAttachment(WebGLTexture* texture, GLenum tar get, GLint level) |
| 184 : m_texture(texture) | 185 : m_texture(texture) |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 } // anonymous namespace | 318 } // anonymous namespace |
| 318 | 319 |
| 319 WebGLFramebuffer::WebGLAttachment::WebGLAttachment() | 320 WebGLFramebuffer::WebGLAttachment::WebGLAttachment() |
| 320 { | 321 { |
| 321 } | 322 } |
| 322 | 323 |
| 323 WebGLFramebuffer::WebGLAttachment::~WebGLAttachment() | 324 WebGLFramebuffer::WebGLAttachment::~WebGLAttachment() |
| 324 { | 325 { |
| 325 } | 326 } |
| 326 | 327 |
| 327 PassRefPtrWillBeRawPtr<WebGLFramebuffer> WebGLFramebuffer::create(WebGLRendering ContextBase* ctx) | 328 WebGLFramebuffer* WebGLFramebuffer::create(WebGLRenderingContextBase* ctx) |
| 328 { | 329 { |
| 329 return adoptRefWillBeNoop(new WebGLFramebuffer(ctx)); | 330 return new WebGLFramebuffer(ctx); |
| 330 } | 331 } |
| 331 | 332 |
| 332 WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContextBase* ctx) | 333 WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContextBase* ctx) |
| 333 : WebGLContextObject(ctx) | 334 : WebGLContextObject(ctx) |
| 334 , m_object(ctx->webContext()->createFramebuffer()) | 335 , m_object(ctx->webContext()->createFramebuffer()) |
| 335 , m_hasEverBeenBound(false) | 336 , m_hasEverBeenBound(false) |
| 336 , m_readBuffer(GL_COLOR_ATTACHMENT0) | 337 , m_readBuffer(GL_COLOR_ATTACHMENT0) |
| 337 { | 338 { |
| 338 } | 339 } |
| 339 | 340 |
| 340 WebGLFramebuffer::~WebGLFramebuffer() | 341 WebGLFramebuffer::~WebGLFramebuffer() |
| 341 { | 342 { |
| 342 // Delete the platform framebuffer resource. Explicit detachment | 343 // Delete the platform framebuffer resource. |
| 343 // is for the benefit of Oilpan, where the framebuffer object | 344 // When the framebuffer object and the WebGLRenderingContextBase object |
| 344 // isn't detached when it and the WebGLRenderingContextBase object | 345 // which is registered with are both finalized, the framebuffer object isn't detached. |
| 345 // it is registered with are both finalized. Without Oilpan, the | 346 // Thus we detach() it here. |
| 346 // object will have been detached. | |
| 347 // | |
| 348 // To keep the code regular, the trivial detach()ment is always | |
| 349 // performed. | |
| 350 detachAndDeleteObject(); | 347 detachAndDeleteObject(); |
| 351 } | 348 } |
| 352 | 349 |
| 353 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, GLenum at tachment, GLenum texTarget, WebGLTexture* texture, GLint level) | 350 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, GLenum at tachment, GLenum texTarget, WebGLTexture* texture, GLint level) |
| 354 { | 351 { |
| 355 ASSERT(isBound(target)); | 352 ASSERT(isBound(target)); |
| 356 removeAttachmentFromBoundFramebuffer(target, attachment); | 353 removeAttachmentFromBoundFramebuffer(target, attachment); |
| 357 if (!m_object) | 354 if (!m_object) |
| 358 return; | 355 return; |
| 359 if (texture && texture->object()) { | 356 if (texture && texture->object()) { |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 583 { | 580 { |
| 584 #if !ENABLE(OILPAN) | 581 #if !ENABLE(OILPAN) |
| 585 // With Oilpan, both the AttachmentMap and its WebGLAttachment objects are | 582 // With Oilpan, both the AttachmentMap and its WebGLAttachment objects are |
| 586 // GCed objects and cannot be accessed, as they may have been finalized | 583 // GCed objects and cannot be accessed, as they may have been finalized |
| 587 // already during the same GC sweep. | 584 // already during the same GC sweep. |
| 588 // | 585 // |
| 589 // The WebGLAttachment-derived classes instead handle detachment | 586 // The WebGLAttachment-derived classes instead handle detachment |
| 590 // on their own when finalizing, so the explicit notification is | 587 // on their own when finalizing, so the explicit notification is |
| 591 // not needed. | 588 // not needed. |
| 592 for (const auto& attachment : m_attachments) | 589 for (const auto& attachment : m_attachments) |
| 593 attachment.value->onDetached(context3d); | 590 attachment.value->onDetached(context3d); |
|
haraken
2015/08/05 04:12:19
I guess this is an existing bug of oilpan builds.
peria
2015/08/06 05:47:00
Done.
| |
| 594 #endif | 591 #endif |
| 595 | 592 |
| 596 context3d->deleteFramebuffer(m_object); | 593 context3d->deleteFramebuffer(m_object); |
| 597 m_object = 0; | 594 m_object = 0; |
| 598 } | 595 } |
| 599 | 596 |
| 600 bool WebGLFramebuffer::isBound(GLenum target) const | 597 bool WebGLFramebuffer::isBound(GLenum target) const |
| 601 { | 598 { |
| 602 return (context()->getFramebufferBinding(target) == this); | 599 return (context()->getFramebufferBinding(target) == this); |
| 603 } | 600 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 656 return false; | 653 return false; |
| 657 if (format) | 654 if (format) |
| 658 *format = image->format(); | 655 *format = image->format(); |
| 659 if (type) | 656 if (type) |
| 660 *type = image->type(); | 657 *type = image->type(); |
| 661 return true; | 658 return true; |
| 662 } | 659 } |
| 663 | 660 |
| 664 DEFINE_TRACE(WebGLFramebuffer) | 661 DEFINE_TRACE(WebGLFramebuffer) |
| 665 { | 662 { |
| 666 #if ENABLE(OILPAN) | |
| 667 visitor->trace(m_attachments); | 663 visitor->trace(m_attachments); |
| 668 #endif | |
| 669 WebGLContextObject::trace(visitor); | 664 WebGLContextObject::trace(visitor); |
| 670 } | 665 } |
| 671 | 666 |
| 672 } | 667 } |
| OLD | NEW |