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 23 matching lines...) Expand all Loading... | |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 Platform3DObject objectOrZero(WebGLObject* object) | 37 Platform3DObject objectOrZero(WebGLObject* object) |
38 { | 38 { |
39 return object ? object->object() : 0; | 39 return object ? object->object() : 0; |
40 } | 40 } |
41 | 41 |
42 class WebGLRenderbufferAttachment FINAL : public WebGLFramebuffer::WebGLAtta chment { | 42 class WebGLRenderbufferAttachment FINAL : public WebGLFramebuffer::WebGLAtta chment { |
43 public: | 43 public: |
44 static PassRefPtr<WebGLFramebuffer::WebGLAttachment> create(WebGLRenderb uffer*); | 44 static PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> create( WebGLRenderbuffer*); |
45 | |
46 virtual void trace(Visitor*) OVERRIDE; | |
45 | 47 |
46 private: | 48 private: |
47 WebGLRenderbufferAttachment(WebGLRenderbuffer*); | 49 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*); |
50 WebGLRenderbufferAttachment() { } | |
51 | |
48 virtual GLsizei width() const OVERRIDE; | 52 virtual GLsizei width() const OVERRIDE; |
49 virtual GLsizei height() const OVERRIDE; | 53 virtual GLsizei height() const OVERRIDE; |
50 virtual GLenum format() const OVERRIDE; | 54 virtual GLenum format() const OVERRIDE; |
51 virtual GLenum type() const OVERRIDE; | 55 virtual GLenum type() const OVERRIDE; |
52 virtual WebGLSharedObject* object() const OVERRIDE; | 56 virtual WebGLSharedObject* object() const OVERRIDE; |
53 virtual bool isSharedObject(WebGLSharedObject*) const OVERRIDE; | 57 virtual bool isSharedObject(WebGLSharedObject*) const OVERRIDE; |
54 virtual bool valid() const OVERRIDE; | 58 virtual bool valid() const OVERRIDE; |
55 virtual void onDetached(blink::WebGraphicsContext3D*) OVERRIDE; | 59 virtual void onDetached(blink::WebGraphicsContext3D*) OVERRIDE; |
56 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) OVE RRIDE; | 60 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) OVE RRIDE; |
57 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) O VERRIDE; | 61 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) O VERRIDE; |
58 | 62 |
59 WebGLRenderbufferAttachment() { }; | 63 RefPtrWillBeMember<WebGLRenderbuffer> m_renderbuffer; |
60 | |
61 RefPtr<WebGLRenderbuffer> m_renderbuffer; | |
62 }; | 64 }; |
63 | 65 |
64 PassRefPtr<WebGLFramebuffer::WebGLAttachment> WebGLRenderbufferAttachment::c reate(WebGLRenderbuffer* renderbuffer) | 66 PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> WebGLRenderbufferA ttachment::create(WebGLRenderbuffer* renderbuffer) |
65 { | 67 { |
66 return adoptRef(new WebGLRenderbufferAttachment(renderbuffer)); | 68 return adoptRefWillBeNoop(new WebGLRenderbufferAttachment(renderbuffer)) ; |
69 } | |
70 | |
71 void WebGLRenderbufferAttachment::trace(Visitor* visitor) | |
72 { | |
73 visitor->trace(m_renderbuffer); | |
74 WebGLFramebuffer::WebGLAttachment::trace(visitor); | |
67 } | 75 } |
68 | 76 |
69 WebGLRenderbufferAttachment::WebGLRenderbufferAttachment(WebGLRenderbuffer* renderbuffer) | 77 WebGLRenderbufferAttachment::WebGLRenderbufferAttachment(WebGLRenderbuffer* renderbuffer) |
70 : m_renderbuffer(renderbuffer) | 78 : m_renderbuffer(renderbuffer) |
71 { | 79 { |
72 } | 80 } |
73 | 81 |
74 GLsizei WebGLRenderbufferAttachment::width() const | 82 GLsizei WebGLRenderbufferAttachment::width() const |
75 { | 83 { |
76 return m_renderbuffer->width(); | 84 return m_renderbuffer->width(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 } | 142 } |
135 | 143 |
136 GLenum WebGLRenderbufferAttachment::type() const | 144 GLenum WebGLRenderbufferAttachment::type() const |
137 { | 145 { |
138 notImplemented(); | 146 notImplemented(); |
139 return 0; | 147 return 0; |
140 } | 148 } |
141 | 149 |
142 class WebGLTextureAttachment FINAL : public WebGLFramebuffer::WebGLAttachmen t { | 150 class WebGLTextureAttachment FINAL : public WebGLFramebuffer::WebGLAttachmen t { |
143 public: | 151 public: |
144 static PassRefPtr<WebGLFramebuffer::WebGLAttachment> create(WebGLTexture *, GLenum target, GLint level); | 152 static PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> create( WebGLTexture*, GLenum target, GLint level); |
153 | |
154 virtual void trace(Visitor*) OVERRIDE; | |
145 | 155 |
146 private: | 156 private: |
147 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level); | 157 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level); |
158 WebGLTextureAttachment() { } | |
159 | |
148 virtual GLsizei width() const OVERRIDE; | 160 virtual GLsizei width() const OVERRIDE; |
149 virtual GLsizei height() const OVERRIDE; | 161 virtual GLsizei height() const OVERRIDE; |
150 virtual GLenum format() const OVERRIDE; | 162 virtual GLenum format() const OVERRIDE; |
151 virtual GLenum type() const OVERRIDE; | 163 virtual GLenum type() const OVERRIDE; |
152 virtual WebGLSharedObject* object() const OVERRIDE; | 164 virtual WebGLSharedObject* object() const OVERRIDE; |
153 virtual bool isSharedObject(WebGLSharedObject*) const OVERRIDE; | 165 virtual bool isSharedObject(WebGLSharedObject*) const OVERRIDE; |
154 virtual bool valid() const OVERRIDE; | 166 virtual bool valid() const OVERRIDE; |
155 virtual void onDetached(blink::WebGraphicsContext3D*) OVERRIDE; | 167 virtual void onDetached(blink::WebGraphicsContext3D*) OVERRIDE; |
156 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) OVE RRIDE; | 168 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) OVE RRIDE; |
157 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) O VERRIDE; | 169 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) O VERRIDE; |
158 | 170 |
159 WebGLTextureAttachment() { }; | 171 RefPtrWillBeMember<WebGLTexture> m_texture; |
160 | |
161 RefPtr<WebGLTexture> m_texture; | |
162 GLenum m_target; | 172 GLenum m_target; |
163 GLint m_level; | 173 GLint m_level; |
164 }; | 174 }; |
165 | 175 |
166 PassRefPtr<WebGLFramebuffer::WebGLAttachment> WebGLTextureAttachment::create (WebGLTexture* texture, GLenum target, GLint level) | 176 PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> WebGLTextureAttach ment::create(WebGLTexture* texture, GLenum target, GLint level) |
167 { | 177 { |
168 return adoptRef(new WebGLTextureAttachment(texture, target, level)); | 178 return adoptRefWillBeNoop(new WebGLTextureAttachment(texture, target, le vel)); |
179 } | |
180 | |
181 void WebGLTextureAttachment::trace(Visitor* visitor) | |
182 { | |
183 visitor->trace(m_texture); | |
184 WebGLFramebuffer::WebGLAttachment::trace(visitor); | |
169 } | 185 } |
170 | 186 |
171 WebGLTextureAttachment::WebGLTextureAttachment(WebGLTexture* texture, GLenum target, GLint level) | 187 WebGLTextureAttachment::WebGLTextureAttachment(WebGLTexture* texture, GLenum target, GLint level) |
172 : m_texture(texture) | 188 : m_texture(texture) |
173 , m_target(target) | 189 , m_target(target) |
174 , m_level(level) | 190 , m_level(level) |
175 { | 191 { |
176 } | 192 } |
177 | 193 |
178 GLsizei WebGLTextureAttachment::width() const | 194 GLsizei WebGLTextureAttachment::width() const |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 } // anonymous namespace | 262 } // anonymous namespace |
247 | 263 |
248 WebGLFramebuffer::WebGLAttachment::WebGLAttachment() | 264 WebGLFramebuffer::WebGLAttachment::WebGLAttachment() |
249 { | 265 { |
250 } | 266 } |
251 | 267 |
252 WebGLFramebuffer::WebGLAttachment::~WebGLAttachment() | 268 WebGLFramebuffer::WebGLAttachment::~WebGLAttachment() |
253 { | 269 { |
254 } | 270 } |
255 | 271 |
256 PassRefPtr<WebGLFramebuffer> WebGLFramebuffer::create(WebGLRenderingContextBase* ctx) | 272 PassRefPtrWillBeRawPtr<WebGLFramebuffer> WebGLFramebuffer::create(WebGLRendering ContextBase* ctx) |
257 { | 273 { |
258 return adoptRef(new WebGLFramebuffer(ctx)); | 274 return adoptRefWillBeNoop(new WebGLFramebuffer(ctx)); |
259 } | 275 } |
260 | 276 |
261 WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContextBase* ctx) | 277 WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContextBase* ctx) |
262 : WebGLContextObject(ctx) | 278 : WebGLContextObject(ctx) |
263 , m_hasEverBeenBound(false) | 279 , m_hasEverBeenBound(false) |
264 { | 280 { |
265 ScriptWrappable::init(this); | 281 ScriptWrappable::init(this); |
266 setObject(ctx->webContext()->createFramebuffer()); | 282 setObject(ctx->webContext()->createFramebuffer()); |
267 } | 283 } |
268 | 284 |
269 WebGLFramebuffer::~WebGLFramebuffer() | 285 WebGLFramebuffer::~WebGLFramebuffer() |
270 { | 286 { |
287 detach(); | |
haraken
2014/07/11 01:55:02
Just help me understand: Why was non-oilpan code w
sof
2014/07/11 04:54:10
detach() enables the final deleteObject() to thoro
haraken
2014/07/11 05:27:54
Would you help me understand where the WebGLObject
sof
2014/07/11 05:40:09
WebGLRenderingContextBase::detachAndRemoveAllObjec
haraken
2014/07/11 05:41:34
ah, makes sense. Thanks.
| |
271 deleteObject(0); | 288 deleteObject(0); |
272 } | 289 } |
273 | 290 |
274 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum attachment, GLenu m texTarget, WebGLTexture* texture, GLint level) | 291 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum attachment, GLenu m texTarget, WebGLTexture* texture, GLint level) |
275 { | 292 { |
276 ASSERT(isBound()); | 293 ASSERT(isBound()); |
277 removeAttachmentFromBoundFramebuffer(attachment); | 294 removeAttachmentFromBoundFramebuffer(attachment); |
278 if (!object()) | 295 if (!object()) |
279 return; | 296 return; |
280 if (texture && texture->object()) { | 297 if (texture && texture->object()) { |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
532 bool WebGLFramebuffer::hasStencilBuffer() const | 549 bool WebGLFramebuffer::hasStencilBuffer() const |
533 { | 550 { |
534 WebGLAttachment* attachment = getAttachment(GL_STENCIL_ATTACHMENT); | 551 WebGLAttachment* attachment = getAttachment(GL_STENCIL_ATTACHMENT); |
535 if (!attachment) | 552 if (!attachment) |
536 attachment = getAttachment(GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL); | 553 attachment = getAttachment(GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL); |
537 return attachment && attachment->valid(); | 554 return attachment && attachment->valid(); |
538 } | 555 } |
539 | 556 |
540 void WebGLFramebuffer::deleteObjectImpl(blink::WebGraphicsContext3D* context3d, Platform3DObject object) | 557 void WebGLFramebuffer::deleteObjectImpl(blink::WebGraphicsContext3D* context3d, Platform3DObject object) |
541 { | 558 { |
559 #if !ENABLE(OILPAN) | |
542 for (AttachmentMap::iterator it = m_attachments.begin(); it != m_attachments .end(); ++it) | 560 for (AttachmentMap::iterator it = m_attachments.begin(); it != m_attachments .end(); ++it) |
543 it->value->onDetached(context3d); | 561 it->value->onDetached(context3d); |
562 #endif | |
544 | 563 |
545 context3d->deleteFramebuffer(object); | 564 context3d->deleteFramebuffer(object); |
546 } | 565 } |
547 | 566 |
548 bool WebGLFramebuffer::isBound() const | 567 bool WebGLFramebuffer::isBound() const |
549 { | 568 { |
550 return (context()->m_framebufferBinding.get() == this); | 569 return (context()->m_framebufferBinding.get() == this); |
551 } | 570 } |
552 | 571 |
553 void WebGLFramebuffer::drawBuffers(const Vector<GLenum>& bufs) | 572 void WebGLFramebuffer::drawBuffers(const Vector<GLenum>& bufs) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
588 { | 607 { |
589 int index = static_cast<int>(drawBuffer - GL_DRAW_BUFFER0_EXT); | 608 int index = static_cast<int>(drawBuffer - GL_DRAW_BUFFER0_EXT); |
590 ASSERT(index >= 0); | 609 ASSERT(index >= 0); |
591 if (index < static_cast<int>(m_drawBuffers.size())) | 610 if (index < static_cast<int>(m_drawBuffers.size())) |
592 return m_drawBuffers[index]; | 611 return m_drawBuffers[index]; |
593 if (drawBuffer == GL_DRAW_BUFFER0_EXT) | 612 if (drawBuffer == GL_DRAW_BUFFER0_EXT) |
594 return GL_COLOR_ATTACHMENT0; | 613 return GL_COLOR_ATTACHMENT0; |
595 return GL_NONE; | 614 return GL_NONE; |
596 } | 615 } |
597 | 616 |
617 void WebGLFramebuffer::trace(Visitor* visitor) | |
618 { | |
619 visitor->trace(m_attachments); | |
620 WebGLContextObject::trace(visitor); | |
598 } | 621 } |
622 | |
623 } | |
OLD | NEW |