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 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 WebGLRenderbufferAttachment(WebGLRenderbuffer*); |
| 48 virtual GLsizei width() const OVERRIDE; | 50 virtual GLsizei width() const OVERRIDE; |
| 49 virtual GLsizei height() const OVERRIDE; | 51 virtual GLsizei height() const OVERRIDE; |
| 50 virtual GLenum format() const OVERRIDE; | 52 virtual GLenum format() const OVERRIDE; |
| 51 virtual GLenum type() const OVERRIDE; | 53 virtual GLenum type() const OVERRIDE; |
| 52 virtual WebGLSharedObject* object() const OVERRIDE; | 54 virtual WebGLSharedObject* object() const OVERRIDE; |
| 53 virtual bool isSharedObject(WebGLSharedObject*) const OVERRIDE; | 55 virtual bool isSharedObject(WebGLSharedObject*) const OVERRIDE; |
| 54 virtual bool valid() const OVERRIDE; | 56 virtual bool valid() const OVERRIDE; |
| 55 virtual void onDetached(blink::WebGraphicsContext3D*) OVERRIDE; | 57 virtual void onDetached(blink::WebGraphicsContext3D*) OVERRIDE; |
| 56 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) OVE RRIDE; | 58 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) OVE RRIDE; |
| 57 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) O VERRIDE; | 59 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) O VERRIDE; |
| 58 | 60 |
| 59 WebGLRenderbufferAttachment() { }; | 61 WebGLRenderbufferAttachment() { }; |
| 60 | 62 |
| 61 RefPtr<WebGLRenderbuffer> m_renderbuffer; | 63 RefPtrWillBeMember<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); |
| 148 virtual GLsizei width() const OVERRIDE; | 158 virtual GLsizei width() const OVERRIDE; |
| 149 virtual GLsizei height() const OVERRIDE; | 159 virtual GLsizei height() const OVERRIDE; |
| 150 virtual GLenum format() const OVERRIDE; | 160 virtual GLenum format() const OVERRIDE; |
| 151 virtual GLenum type() const OVERRIDE; | 161 virtual GLenum type() const OVERRIDE; |
| 152 virtual WebGLSharedObject* object() const OVERRIDE; | 162 virtual WebGLSharedObject* object() const OVERRIDE; |
| 153 virtual bool isSharedObject(WebGLSharedObject*) const OVERRIDE; | 163 virtual bool isSharedObject(WebGLSharedObject*) const OVERRIDE; |
| 154 virtual bool valid() const OVERRIDE; | 164 virtual bool valid() const OVERRIDE; |
| 155 virtual void onDetached(blink::WebGraphicsContext3D*) OVERRIDE; | 165 virtual void onDetached(blink::WebGraphicsContext3D*) OVERRIDE; |
| 156 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) OVE RRIDE; | 166 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) OVE RRIDE; |
| 157 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) O VERRIDE; | 167 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) O VERRIDE; |
| 158 | 168 |
| 159 WebGLTextureAttachment() { }; | 169 WebGLTextureAttachment() { }; |
| 160 | 170 |
| 161 RefPtr<WebGLTexture> m_texture; | 171 RefPtrWillBeMember<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 { |
| 271 deleteObject(0); | 287 deleteObject(0); |
|
haraken
2014/07/02 07:47:38
Are you sure that this doesn't touch on-heap objec
sof
2014/07/02 11:43:52
Commented on at https://codereview.chromium.org/36
| |
| 272 } | 288 } |
| 273 | 289 |
| 274 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum attachment, GLenu m texTarget, WebGLTexture* texture, GLint level) | 290 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum attachment, GLenu m texTarget, WebGLTexture* texture, GLint level) |
| 275 { | 291 { |
| 276 ASSERT(isBound()); | 292 ASSERT(isBound()); |
| 277 removeAttachmentFromBoundFramebuffer(attachment); | 293 removeAttachmentFromBoundFramebuffer(attachment); |
| 278 if (!object()) | 294 if (!object()) |
| 279 return; | 295 return; |
| 280 if (texture && texture->object()) { | 296 if (texture && texture->object()) { |
| 281 m_attachments.add(attachment, WebGLTextureAttachment::create(texture, te xTarget, level)); | 297 m_attachments.add(attachment, WebGLTextureAttachment::create(texture, te xTarget, level)); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 588 { | 604 { |
| 589 int index = static_cast<int>(drawBuffer - GL_DRAW_BUFFER0_EXT); | 605 int index = static_cast<int>(drawBuffer - GL_DRAW_BUFFER0_EXT); |
| 590 ASSERT(index >= 0); | 606 ASSERT(index >= 0); |
| 591 if (index < static_cast<int>(m_drawBuffers.size())) | 607 if (index < static_cast<int>(m_drawBuffers.size())) |
| 592 return m_drawBuffers[index]; | 608 return m_drawBuffers[index]; |
| 593 if (drawBuffer == GL_DRAW_BUFFER0_EXT) | 609 if (drawBuffer == GL_DRAW_BUFFER0_EXT) |
| 594 return GL_COLOR_ATTACHMENT0; | 610 return GL_COLOR_ATTACHMENT0; |
| 595 return GL_NONE; | 611 return GL_NONE; |
| 596 } | 612 } |
| 597 | 613 |
| 614 void WebGLFramebuffer::trace(Visitor* visitor) | |
| 615 { | |
| 616 visitor->trace(m_attachments); | |
| 617 WebGLContextObject::trace(visitor); | |
| 598 } | 618 } |
| 619 | |
| 620 } | |
| OLD | NEW |