Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: Source/modules/webgl/WebGLFramebuffer.cpp

Issue 1234883002: [Oilpan] Migrate classes under module/webgl onto oilpan heap (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Detach extensions in dtor of RenderingContextBase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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 // Attachments in |m_attachments| will be deleted from other places, so we
343 // is for the benefit of Oilpan, where the framebuffer object 344 // clear it to avoid deleting those attachments in detachAndDeleteObject().
344 // isn't detached when it and the WebGLRenderingContextBase object 345 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
345 // it is registered with are both finalized. Without Oilpan, the 346
346 // object will have been detached. 347 // See the comment in WebGLObject::detachAndDeleteObject().
347 //
348 // To keep the code regular, the trivial detach()ment is always
349 // performed.
350 detachAndDeleteObject(); 348 detachAndDeleteObject();
351 } 349 }
352 350
353 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, GLenum at tachment, GLenum texTarget, WebGLTexture* texture, GLint level) 351 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, GLenum at tachment, GLenum texTarget, WebGLTexture* texture, GLint level)
354 { 352 {
355 ASSERT(isBound(target)); 353 ASSERT(isBound(target));
356 removeAttachmentFromBoundFramebuffer(target, attachment); 354 removeAttachmentFromBoundFramebuffer(target, attachment);
357 if (!m_object) 355 if (!m_object)
358 return; 356 return;
359 if (texture && texture->object()) { 357 if (texture && texture->object()) {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 bool WebGLFramebuffer::hasStencilBuffer() const 572 bool WebGLFramebuffer::hasStencilBuffer() const
575 { 573 {
576 WebGLAttachment* attachment = getAttachment(GL_STENCIL_ATTACHMENT); 574 WebGLAttachment* attachment = getAttachment(GL_STENCIL_ATTACHMENT);
577 if (!attachment) 575 if (!attachment)
578 attachment = getAttachment(GL_DEPTH_STENCIL_ATTACHMENT); 576 attachment = getAttachment(GL_DEPTH_STENCIL_ATTACHMENT);
579 return attachment && attachment->valid(); 577 return attachment && attachment->valid();
580 } 578 }
581 579
582 void WebGLFramebuffer::deleteObjectImpl(WebGraphicsContext3D* context3d) 580 void WebGLFramebuffer::deleteObjectImpl(WebGraphicsContext3D* context3d)
583 { 581 {
584 #if !ENABLE(OILPAN) 582 // 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
585 // With Oilpan, both the AttachmentMap and its WebGLAttachment objects are 583 // objects and cannot be accessed, as they may have been finalized
586 // 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 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.
593 attachment.value->onDetached(context3d); 590 for (const auto& attachment : m_attachments)
594 #endif 591 attachment.value->onDetached(context3d);
592 }
595 593
596 context3d->deleteFramebuffer(m_object); 594 context3d->deleteFramebuffer(m_object);
597 m_object = 0; 595 m_object = 0;
598 } 596 }
599 597
600 bool WebGLFramebuffer::isBound(GLenum target) const 598 bool WebGLFramebuffer::isBound(GLenum target) const
601 { 599 {
602 return (context()->getFramebufferBinding(target) == this); 600 return (context()->getFramebufferBinding(target) == this);
603 } 601 }
604 602
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 return false; 654 return false;
657 if (format) 655 if (format)
658 *format = image->format(); 656 *format = image->format();
659 if (type) 657 if (type)
660 *type = image->type(); 658 *type = image->type();
661 return true; 659 return true;
662 } 660 }
663 661
664 DEFINE_TRACE(WebGLFramebuffer) 662 DEFINE_TRACE(WebGLFramebuffer)
665 { 663 {
666 #if ENABLE(OILPAN)
667 visitor->trace(m_attachments); 664 visitor->trace(m_attachments);
668 #endif
669 WebGLContextObject::trace(visitor); 665 WebGLContextObject::trace(visitor);
670 } 666 }
671 667
672 } 668 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698