Chromium Code Reviews| Index: Source/modules/webgl/WebGLFramebuffer.cpp | 
| diff --git a/Source/modules/webgl/WebGLFramebuffer.cpp b/Source/modules/webgl/WebGLFramebuffer.cpp | 
| index e9dee4049417d46953014e526d414bf565c1c9bd..5853a219d8470c43ea8739db1798e220e2337186 100644 | 
| --- a/Source/modules/webgl/WebGLFramebuffer.cpp | 
| +++ b/Source/modules/webgl/WebGLFramebuffer.cpp | 
| @@ -38,7 +38,7 @@ namespace { | 
| class WebGLRenderbufferAttachment final : public WebGLFramebuffer::WebGLAttachment { | 
| public: | 
| - static PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> create(WebGLRenderbuffer*); | 
| + static WebGLFramebuffer::WebGLAttachment* create(WebGLRenderbuffer*); | 
| DECLARE_VIRTUAL_TRACE(); | 
| @@ -57,12 +57,12 @@ private: | 
| void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) override; | 
| void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) override; | 
| - RefPtrWillBeMember<WebGLRenderbuffer> m_renderbuffer; | 
| + Member<WebGLRenderbuffer> m_renderbuffer; | 
| }; | 
| -PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> WebGLRenderbufferAttachment::create(WebGLRenderbuffer* renderbuffer) | 
| +WebGLFramebuffer::WebGLAttachment* WebGLRenderbufferAttachment::create(WebGLRenderbuffer* renderbuffer) | 
| { | 
| - return adoptRefWillBeNoop(new WebGLRenderbufferAttachment(renderbuffer)); | 
| + return new WebGLRenderbufferAttachment(renderbuffer); | 
| } | 
| DEFINE_TRACE(WebGLRenderbufferAttachment) | 
| @@ -140,12 +140,13 @@ void WebGLRenderbufferAttachment::unattach(WebGraphicsContext3D* context, GLenum | 
| GLenum WebGLRenderbufferAttachment::type() const | 
| { | 
| + notImplemented(); | 
| return 0; | 
| } | 
| class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachment { | 
| public: | 
| - static PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> create(WebGLTexture*, GLenum target, GLint level); | 
| + static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum target, GLint level); | 
| DECLARE_VIRTUAL_TRACE(); | 
| @@ -164,14 +165,14 @@ private: | 
| void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) override; | 
| void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) override; | 
| - RefPtrWillBeMember<WebGLTexture> m_texture; | 
| + Member<WebGLTexture> m_texture; | 
| GLenum m_target; | 
| GLint m_level; | 
| }; | 
| -PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> WebGLTextureAttachment::create(WebGLTexture* texture, GLenum target, GLint level) | 
| +WebGLFramebuffer::WebGLAttachment* WebGLTextureAttachment::create(WebGLTexture* texture, GLenum target, GLint level) | 
| { | 
| - return adoptRefWillBeNoop(new WebGLTextureAttachment(texture, target, level)); | 
| + return new WebGLTextureAttachment(texture, target, level); | 
| } | 
| DEFINE_TRACE(WebGLTextureAttachment) | 
| @@ -324,9 +325,9 @@ WebGLFramebuffer::WebGLAttachment::~WebGLAttachment() | 
| { | 
| } | 
| -PassRefPtrWillBeRawPtr<WebGLFramebuffer> WebGLFramebuffer::create(WebGLRenderingContextBase* ctx) | 
| +WebGLFramebuffer* WebGLFramebuffer::create(WebGLRenderingContextBase* ctx) | 
| { | 
| - return adoptRefWillBeNoop(new WebGLFramebuffer(ctx)); | 
| + return new WebGLFramebuffer(ctx); | 
| } | 
| WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContextBase* ctx) | 
| @@ -339,14 +340,11 @@ WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContextBase* ctx) | 
| WebGLFramebuffer::~WebGLFramebuffer() | 
| { | 
| - // Delete the platform framebuffer resource. Explicit detachment | 
| - // is for the benefit of Oilpan, where the framebuffer object | 
| - // isn't detached when it and the WebGLRenderingContextBase object | 
| - // it is registered with are both finalized. Without Oilpan, the | 
| - // object will have been detached. | 
| - // | 
| - // To keep the code regular, the trivial detach()ment is always | 
| - // performed. | 
| + // Attachments in |m_attachments| will be deleted from other places, so we | 
| + // clear it to avoid deleting those attachments in detachAndDeleteObject(). | 
| + m_attachments.clear(); | 
| 
 
sof
2015/08/09 08:35:21
I don't think is quite correct with Oilpan:
 - if
 
haraken
2015/08/09 14:16:45
Yeah, you're right -- I think we can just remove t
 
sof
2015/08/09 15:07:37
That's fine, I think. The Oilpan changes made here
 
peria
2015/08/10 03:15:23
Thanks, I filed an issue to follow it up.
http://c
 
 | 
| + | 
| + // See the comment in WebGLObject::detachAndDeleteObject(). | 
| detachAndDeleteObject(); | 
| } | 
| @@ -581,17 +579,17 @@ bool WebGLFramebuffer::hasStencilBuffer() const | 
| void WebGLFramebuffer::deleteObjectImpl(WebGraphicsContext3D* context3d) | 
| { | 
| -#if !ENABLE(OILPAN) | 
| - // With Oilpan, both the AttachmentMap and its WebGLAttachment objects are | 
| - // GCed objects and cannot be accessed, as they may have been finalized | 
| + // Both the AttachmentMap and its WebGLAttachment objects are GCed | 
| 
 
sof
2015/08/09 08:35:20
The code and the comment is inconsistent now; do t
 
peria
2015/08/10 03:15:23
Removed latter half comment.
I think it is not nee
 
 | 
| + // objects and cannot be accessed, as they may have been finalized | 
| // already during the same GC sweep. | 
| // | 
| // The WebGLAttachment-derived classes instead handle detachment | 
| // on their own when finalizing, so the explicit notification is | 
| // not needed. | 
| - for (const auto& attachment : m_attachments) | 
| - attachment.value->onDetached(context3d); | 
| -#endif | 
| + if (!m_attachments.isEmpty()) { | 
| 
 
haraken
2015/08/07 07:43:58
This check won't be needed, since if the m_attache
 
peria
2015/08/10 03:15:23
Done.
 
 | 
| + for (const auto& attachment : m_attachments) | 
| + attachment.value->onDetached(context3d); | 
| + } | 
| context3d->deleteFramebuffer(m_object); | 
| m_object = 0; | 
| @@ -663,9 +661,7 @@ bool WebGLFramebuffer::getReadBufferFormatAndType(GLenum* format, GLenum* type) | 
| DEFINE_TRACE(WebGLFramebuffer) | 
| { | 
| -#if ENABLE(OILPAN) | 
| visitor->trace(m_attachments); | 
| -#endif | 
| WebGLContextObject::trace(visitor); | 
| } |