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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*); | 46 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*); |
47 WebGLRenderbufferAttachment() { } | 47 WebGLRenderbufferAttachment() { } |
48 | 48 |
49 virtual GLsizei width() const override; | 49 virtual GLsizei width() const override; |
50 virtual GLsizei height() const override; | 50 virtual GLsizei height() const override; |
51 virtual GLenum format() const override; | 51 virtual GLenum format() const override; |
52 virtual GLenum type() const override; | 52 virtual GLenum type() const override; |
53 virtual WebGLSharedObject* object() const override; | 53 virtual WebGLSharedObject* object() const override; |
54 virtual bool isSharedObject(WebGLSharedObject*) const override; | 54 virtual bool isSharedObject(WebGLSharedObject*) const override; |
55 virtual bool valid() const override; | 55 virtual bool valid() const override; |
56 virtual void onDetached(blink::WebGraphicsContext3D*) override; | 56 virtual void onDetached(WebGraphicsContext3D*) override; |
57 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) ove
rride; | 57 virtual void attach(WebGraphicsContext3D*, GLenum attachment) override; |
58 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) o
verride; | 58 virtual void unattach(WebGraphicsContext3D*, GLenum attachment) override
; |
59 | 59 |
60 RefPtrWillBeMember<WebGLRenderbuffer> m_renderbuffer; | 60 RefPtrWillBeMember<WebGLRenderbuffer> m_renderbuffer; |
61 }; | 61 }; |
62 | 62 |
63 PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> WebGLRenderbufferA
ttachment::create(WebGLRenderbuffer* renderbuffer) | 63 PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> WebGLRenderbufferA
ttachment::create(WebGLRenderbuffer* renderbuffer) |
64 { | 64 { |
65 return adoptRefWillBeNoop(new WebGLRenderbufferAttachment(renderbuffer))
; | 65 return adoptRefWillBeNoop(new WebGLRenderbufferAttachment(renderbuffer))
; |
66 } | 66 } |
67 | 67 |
68 DEFINE_TRACE(WebGLRenderbufferAttachment) | 68 DEFINE_TRACE(WebGLRenderbufferAttachment) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 bool WebGLRenderbufferAttachment::isSharedObject(WebGLSharedObject* object)
const | 105 bool WebGLRenderbufferAttachment::isSharedObject(WebGLSharedObject* object)
const |
106 { | 106 { |
107 return object == m_renderbuffer; | 107 return object == m_renderbuffer; |
108 } | 108 } |
109 | 109 |
110 bool WebGLRenderbufferAttachment::valid() const | 110 bool WebGLRenderbufferAttachment::valid() const |
111 { | 111 { |
112 return m_renderbuffer->object(); | 112 return m_renderbuffer->object(); |
113 } | 113 } |
114 | 114 |
115 void WebGLRenderbufferAttachment::onDetached(blink::WebGraphicsContext3D* co
ntext) | 115 void WebGLRenderbufferAttachment::onDetached(WebGraphicsContext3D* context) |
116 { | 116 { |
117 m_renderbuffer->onDetached(context); | 117 m_renderbuffer->onDetached(context); |
118 } | 118 } |
119 | 119 |
120 void WebGLRenderbufferAttachment::attach(blink::WebGraphicsContext3D* contex
t, GLenum attachment) | 120 void WebGLRenderbufferAttachment::attach(WebGraphicsContext3D* context, GLen
um attachment) |
121 { | 121 { |
122 Platform3DObject object = objectOrZero(m_renderbuffer.get()); | 122 Platform3DObject object = objectOrZero(m_renderbuffer.get()); |
123 if (attachment == GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL && m_renderbuffer-
>emulatedStencilBuffer()) { | 123 if (attachment == GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL && m_renderbuffer-
>emulatedStencilBuffer()) { |
124 context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT
, GL_RENDERBUFFER, object); | 124 context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT
, GL_RENDERBUFFER, object); |
125 context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHME
NT, GL_RENDERBUFFER, objectOrZero(m_renderbuffer->emulatedStencilBuffer())); | 125 context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHME
NT, GL_RENDERBUFFER, objectOrZero(m_renderbuffer->emulatedStencilBuffer())); |
126 } else { | 126 } else { |
127 context->framebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_REND
ERBUFFER, object); | 127 context->framebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_REND
ERBUFFER, object); |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 void WebGLRenderbufferAttachment::unattach(blink::WebGraphicsContext3D* cont
ext, GLenum attachment) | 131 void WebGLRenderbufferAttachment::unattach(WebGraphicsContext3D* context, GL
enum attachment) |
132 { | 132 { |
133 if (attachment == GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL) { | 133 if (attachment == GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL) { |
134 context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT
, GL_RENDERBUFFER, 0); | 134 context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT
, GL_RENDERBUFFER, 0); |
135 context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHME
NT, GL_RENDERBUFFER, 0); | 135 context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHME
NT, GL_RENDERBUFFER, 0); |
136 } else { | 136 } else { |
137 context->framebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_REND
ERBUFFER, 0); | 137 context->framebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_REND
ERBUFFER, 0); |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 GLenum WebGLRenderbufferAttachment::type() const | 141 GLenum WebGLRenderbufferAttachment::type() const |
(...skipping 12 matching lines...) Expand all Loading... |
154 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level); | 154 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level); |
155 WebGLTextureAttachment() { } | 155 WebGLTextureAttachment() { } |
156 | 156 |
157 virtual GLsizei width() const override; | 157 virtual GLsizei width() const override; |
158 virtual GLsizei height() const override; | 158 virtual GLsizei height() const override; |
159 virtual GLenum format() const override; | 159 virtual GLenum format() const override; |
160 virtual GLenum type() const override; | 160 virtual GLenum type() const override; |
161 virtual WebGLSharedObject* object() const override; | 161 virtual WebGLSharedObject* object() const override; |
162 virtual bool isSharedObject(WebGLSharedObject*) const override; | 162 virtual bool isSharedObject(WebGLSharedObject*) const override; |
163 virtual bool valid() const override; | 163 virtual bool valid() const override; |
164 virtual void onDetached(blink::WebGraphicsContext3D*) override; | 164 virtual void onDetached(WebGraphicsContext3D*) override; |
165 virtual void attach(blink::WebGraphicsContext3D*, GLenum attachment) ove
rride; | 165 virtual void attach(WebGraphicsContext3D*, GLenum attachment) override; |
166 virtual void unattach(blink::WebGraphicsContext3D*, GLenum attachment) o
verride; | 166 virtual void unattach(WebGraphicsContext3D*, GLenum attachment) override
; |
167 | 167 |
168 RefPtrWillBeMember<WebGLTexture> m_texture; | 168 RefPtrWillBeMember<WebGLTexture> m_texture; |
169 GLenum m_target; | 169 GLenum m_target; |
170 GLint m_level; | 170 GLint m_level; |
171 }; | 171 }; |
172 | 172 |
173 PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> WebGLTextureAttach
ment::create(WebGLTexture* texture, GLenum target, GLint level) | 173 PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> WebGLTextureAttach
ment::create(WebGLTexture* texture, GLenum target, GLint level) |
174 { | 174 { |
175 return adoptRefWillBeNoop(new WebGLTextureAttachment(texture, target, le
vel)); | 175 return adoptRefWillBeNoop(new WebGLTextureAttachment(texture, target, le
vel)); |
176 } | 176 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 bool WebGLTextureAttachment::isSharedObject(WebGLSharedObject* object) const | 211 bool WebGLTextureAttachment::isSharedObject(WebGLSharedObject* object) const |
212 { | 212 { |
213 return object == m_texture; | 213 return object == m_texture; |
214 } | 214 } |
215 | 215 |
216 bool WebGLTextureAttachment::valid() const | 216 bool WebGLTextureAttachment::valid() const |
217 { | 217 { |
218 return m_texture->object(); | 218 return m_texture->object(); |
219 } | 219 } |
220 | 220 |
221 void WebGLTextureAttachment::onDetached(blink::WebGraphicsContext3D* context
) | 221 void WebGLTextureAttachment::onDetached(WebGraphicsContext3D* context) |
222 { | 222 { |
223 m_texture->onDetached(context); | 223 m_texture->onDetached(context); |
224 } | 224 } |
225 | 225 |
226 void WebGLTextureAttachment::attach(blink::WebGraphicsContext3D* context, GL
enum attachment) | 226 void WebGLTextureAttachment::attach(WebGraphicsContext3D* context, GLenum at
tachment) |
227 { | 227 { |
228 Platform3DObject object = objectOrZero(m_texture.get()); | 228 Platform3DObject object = objectOrZero(m_texture.get()); |
229 context->framebufferTexture2D(GL_FRAMEBUFFER, attachment, m_target, obje
ct, m_level); | 229 context->framebufferTexture2D(GL_FRAMEBUFFER, attachment, m_target, obje
ct, m_level); |
230 } | 230 } |
231 | 231 |
232 void WebGLTextureAttachment::unattach(blink::WebGraphicsContext3D* context,
GLenum attachment) | 232 void WebGLTextureAttachment::unattach(WebGraphicsContext3D* context, GLenum
attachment) |
233 { | 233 { |
234 if (attachment == GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL) { | 234 if (attachment == GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL) { |
235 context->framebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m
_target, 0, m_level); | 235 context->framebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m
_target, 0, m_level); |
236 context->framebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
m_target, 0, m_level); | 236 context->framebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
m_target, 0, m_level); |
237 } else { | 237 } else { |
238 context->framebufferTexture2D(GL_FRAMEBUFFER, attachment, m_target,
0, m_level); | 238 context->framebufferTexture2D(GL_FRAMEBUFFER, attachment, m_target,
0, m_level); |
239 } | 239 } |
240 } | 240 } |
241 | 241 |
242 GLenum WebGLTextureAttachment::type() const | 242 GLenum WebGLTextureAttachment::type() const |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 537 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
538 } | 538 } |
539 // WebGL specific: no conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments. | 539 // WebGL specific: no conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments. |
540 if ((haveDepthStencil && (haveDepth || haveStencil)) || (haveDepth && haveSt
encil)) { | 540 if ((haveDepthStencil && (haveDepth || haveStencil)) || (haveDepth && haveSt
encil)) { |
541 *reason = "conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments"; | 541 *reason = "conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments"; |
542 return GL_FRAMEBUFFER_UNSUPPORTED; | 542 return GL_FRAMEBUFFER_UNSUPPORTED; |
543 } | 543 } |
544 return GL_FRAMEBUFFER_COMPLETE; | 544 return GL_FRAMEBUFFER_COMPLETE; |
545 } | 545 } |
546 | 546 |
547 bool WebGLFramebuffer::onAccess(blink::WebGraphicsContext3D* context3d, const ch
ar** reason) | 547 bool WebGLFramebuffer::onAccess(WebGraphicsContext3D* context3d, const char** re
ason) |
548 { | 548 { |
549 if (checkStatus(reason) != GL_FRAMEBUFFER_COMPLETE) | 549 if (checkStatus(reason) != GL_FRAMEBUFFER_COMPLETE) |
550 return false; | 550 return false; |
551 return true; | 551 return true; |
552 } | 552 } |
553 | 553 |
554 bool WebGLFramebuffer::hasStencilBuffer() const | 554 bool WebGLFramebuffer::hasStencilBuffer() const |
555 { | 555 { |
556 WebGLAttachment* attachment = getAttachment(GL_STENCIL_ATTACHMENT); | 556 WebGLAttachment* attachment = getAttachment(GL_STENCIL_ATTACHMENT); |
557 if (!attachment) | 557 if (!attachment) |
558 attachment = getAttachment(GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL); | 558 attachment = getAttachment(GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL); |
559 return attachment && attachment->valid(); | 559 return attachment && attachment->valid(); |
560 } | 560 } |
561 | 561 |
562 void WebGLFramebuffer::deleteObjectImpl(blink::WebGraphicsContext3D* context3d) | 562 void WebGLFramebuffer::deleteObjectImpl(WebGraphicsContext3D* context3d) |
563 { | 563 { |
564 #if !ENABLE(OILPAN) | 564 #if !ENABLE(OILPAN) |
565 // With Oilpan, both the AttachmentMap and its WebGLAttachment objects are | 565 // With Oilpan, both the AttachmentMap and its WebGLAttachment objects are |
566 // GCed objects and cannot be accessed, as they may have been finalized | 566 // GCed objects and cannot be accessed, as they may have been finalized |
567 // already during the same GC sweep. | 567 // already during the same GC sweep. |
568 // | 568 // |
569 // The WebGLAttachment-derived classes instead handle detachment | 569 // The WebGLAttachment-derived classes instead handle detachment |
570 // on their own when finalizing, so the explicit notification is | 570 // on their own when finalizing, so the explicit notification is |
571 // not needed. | 571 // not needed. |
572 for (const auto& attachment : m_attachments) | 572 for (const auto& attachment : m_attachments) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 | 629 |
630 DEFINE_TRACE(WebGLFramebuffer) | 630 DEFINE_TRACE(WebGLFramebuffer) |
631 { | 631 { |
632 #if ENABLE(OILPAN) | 632 #if ENABLE(OILPAN) |
633 visitor->trace(m_attachments); | 633 visitor->trace(m_attachments); |
634 #endif | 634 #endif |
635 WebGLContextObject::trace(visitor); | 635 WebGLContextObject::trace(visitor); |
636 } | 636 } |
637 | 637 |
638 } | 638 } |
OLD | NEW |