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

Side by Side Diff: Source/core/html/canvas/WebGLFramebuffer.cpp

Issue 1120953002: WebGL 2: add read/write framebuffer binding points to related APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(WebGraphicsContext3D*) override; 56 virtual void onDetached(WebGraphicsContext3D*) override;
57 virtual void attach(WebGraphicsContext3D*, GLenum attachment) override; 57 virtual void attach(WebGraphicsContext3D*, GLenum target, GLenum attachm ent) override;
58 virtual void unattach(WebGraphicsContext3D*, GLenum attachment) override ; 58 virtual void unattach(WebGraphicsContext3D*, GLenum target, GLenum attac hment) 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(WebGraphicsContext3D* context) 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(WebGraphicsContext3D* context, GLen um attachment) 120 void WebGLRenderbufferAttachment::attach(WebGraphicsContext3D* context, GLen um target, GLenum 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(target, GL_DEPTH_ATTACHMENT, GL_REN DERBUFFER, object);
125 context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHME NT, GL_RENDERBUFFER, objectOrZero(m_renderbuffer->emulatedStencilBuffer())); 125 context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, GL_R ENDERBUFFER, objectOrZero(m_renderbuffer->emulatedStencilBuffer()));
126 } else { 126 } else {
127 context->framebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_REND ERBUFFER, object); 127 context->framebufferRenderbuffer(target, attachment, GL_RENDERBUFFER , object);
128 } 128 }
129 } 129 }
130 130
131 void WebGLRenderbufferAttachment::unattach(WebGraphicsContext3D* context, GL enum attachment) 131 void WebGLRenderbufferAttachment::unattach(WebGraphicsContext3D* context, GL enum target, GLenum 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(target, GL_DEPTH_ATTACHMENT, GL_REN DERBUFFER, 0);
135 context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHME NT, GL_RENDERBUFFER, 0); 135 context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, GL_R ENDERBUFFER, 0);
136 } else { 136 } else {
137 context->framebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_REND ERBUFFER, 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 notImplemented();
144 return 0; 144 return 0;
145 } 145 }
146 146
147 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachmen t { 147 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachmen t {
148 public: 148 public:
149 static PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> create( WebGLTexture*, GLenum target, GLint level); 149 static PassRefPtrWillBeRawPtr<WebGLFramebuffer::WebGLAttachment> create( WebGLTexture*, GLenum target, GLint level);
150 150
151 DECLARE_VIRTUAL_TRACE(); 151 DECLARE_VIRTUAL_TRACE();
152 152
153 private: 153 private:
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(WebGraphicsContext3D*) override; 164 virtual void onDetached(WebGraphicsContext3D*) override;
165 virtual void attach(WebGraphicsContext3D*, GLenum attachment) override; 165 virtual void attach(WebGraphicsContext3D*, GLenum target, GLenum attachm ent) override;
166 virtual void unattach(WebGraphicsContext3D*, GLenum attachment) override ; 166 virtual void unattach(WebGraphicsContext3D*, GLenum target, GLenum attac hment) 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(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(WebGraphicsContext3D* context, GLenum at tachment) 226 void WebGLTextureAttachment::attach(WebGraphicsContext3D* context, GLenum ta rget, GLenum attachment)
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(target, attachment, m_target, object, m_le vel);
230 } 230 }
231 231
232 void WebGLTextureAttachment::unattach(WebGraphicsContext3D* context, GLenum attachment) 232 void WebGLTextureAttachment::unattach(WebGraphicsContext3D* context, GLenum target, 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(target, GL_DEPTH_ATTACHMENT, m_target, 0, m_level);
236 context->framebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, m_target, 0, m_level); 236 context->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, m_targe t, 0, m_level);
237 } else { 237 } else {
238 context->framebufferTexture2D(GL_FRAMEBUFFER, attachment, m_target, 0, m_level); 238 context->framebufferTexture2D(target, attachment, m_target, 0, m_lev el);
239 } 239 }
240 } 240 }
241 241
242 GLenum WebGLTextureAttachment::type() const 242 GLenum WebGLTextureAttachment::type() const
243 { 243 {
244 return m_texture->getType(m_target, m_level); 244 return m_texture->getType(m_target, m_level);
245 } 245 }
246 246
247 bool isColorRenderable(GLenum internalformat) 247 bool isColorRenderable(GLenum internalformat)
248 { 248 {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // is for the benefit of Oilpan, where the framebuffer object 285 // is for the benefit of Oilpan, where the framebuffer object
286 // isn't detached when it and the WebGLRenderingContextBase object 286 // isn't detached when it and the WebGLRenderingContextBase object
287 // it is registered with are both finalized. Without Oilpan, the 287 // it is registered with are both finalized. Without Oilpan, the
288 // object will have been detached. 288 // object will have been detached.
289 // 289 //
290 // To keep the code regular, the trivial detach()ment is always 290 // To keep the code regular, the trivial detach()ment is always
291 // performed. 291 // performed.
292 detachAndDeleteObject(); 292 detachAndDeleteObject();
293 } 293 }
294 294
295 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum attachment, GLenu m texTarget, WebGLTexture* texture, GLint level) 295 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, GLenum at tachment, GLenum texTarget, WebGLTexture* texture, GLint level)
296 { 296 {
297 ASSERT(isBound()); 297 ASSERT(isBound());
298 removeAttachmentFromBoundFramebuffer(attachment); 298 removeAttachmentFromBoundFramebuffer(attachment, target);
299 if (!m_object) 299 if (!m_object)
300 return; 300 return;
301 if (texture && texture->object()) { 301 if (texture && texture->object()) {
302 m_attachments.add(attachment, WebGLTextureAttachment::create(texture, te xTarget, level)); 302 if (target == GL_READ_FRAMEBUFFER)
303 m_readAttachments.add(attachment, WebGLTextureAttachment::create(tex ture, texTarget, level));
304 else
305 m_attachments.add(attachment, WebGLTextureAttachment::create(texture , texTarget, level));
303 drawBuffersIfNecessary(false); 306 drawBuffersIfNecessary(false);
304 texture->onAttached(); 307 texture->onAttached();
305 } 308 }
306 } 309 }
307 310
308 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum attachment, WebGL Renderbuffer* renderbuffer) 311 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, GLenum at tachment, WebGLRenderbuffer* renderbuffer)
309 { 312 {
310 ASSERT(isBound()); 313 ASSERT(isBound());
311 removeAttachmentFromBoundFramebuffer(attachment); 314 removeAttachmentFromBoundFramebuffer(attachment, target);
312 if (!m_object) 315 if (!m_object)
313 return; 316 return;
314 if (renderbuffer && renderbuffer->object()) { 317 if (renderbuffer && renderbuffer->object()) {
315 m_attachments.add(attachment, WebGLRenderbufferAttachment::create(render buffer)); 318 if (target == GL_READ_FRAMEBUFFER)
319 m_readAttachments.add(attachment, WebGLRenderbufferAttachment::creat e(renderbuffer));
320 else
321 m_attachments.add(attachment, WebGLRenderbufferAttachment::create(re nderbuffer));
316 drawBuffersIfNecessary(false); 322 drawBuffersIfNecessary(false);
317 renderbuffer->onAttached(); 323 renderbuffer->onAttached();
318 } 324 }
319 } 325 }
320 326
321 void WebGLFramebuffer::attach(GLenum attachment, GLenum attachmentPoint) 327 void WebGLFramebuffer::attach(GLenum target, GLenum attachment, GLenum attachmen tPoint)
322 { 328 {
323 ASSERT(isBound()); 329 ASSERT(isBound());
324 WebGLAttachment* attachmentObject = getAttachment(attachment); 330 WebGLAttachment* attachmentObject = getAttachment(attachment, target);
325 if (attachmentObject) 331 if (attachmentObject)
326 attachmentObject->attach(context()->webContext(), attachmentPoint); 332 attachmentObject->attach(context()->webContext(), target, attachmentPoin t);
327 } 333 }
328 334
329 WebGLSharedObject* WebGLFramebuffer::getAttachmentObject(GLenum attachment) cons t 335 WebGLSharedObject* WebGLFramebuffer::getAttachmentObject(GLenum attachment) cons t
330 { 336 {
331 if (!m_object) 337 if (!m_object)
332 return nullptr; 338 return nullptr;
333 WebGLAttachment* attachmentObject = getAttachment(attachment); 339 WebGLAttachment* attachmentObject = getAttachment(attachment);
334 return attachmentObject ? attachmentObject->object() : nullptr; 340 return attachmentObject ? attachmentObject->object() : nullptr;
335 } 341 }
336 342
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 return false; 420 return false;
415 } 421 }
416 422
417 if (!attachedObject->width() || !attachedObject->height()) { 423 if (!attachedObject->width() || !attachedObject->height()) {
418 *reason = "attachment has a 0 dimension"; 424 *reason = "attachment has a 0 dimension";
419 return false; 425 return false;
420 } 426 }
421 return true; 427 return true;
422 } 428 }
423 429
424 WebGLFramebuffer::WebGLAttachment* WebGLFramebuffer::getAttachment(GLenum attach ment) const 430 WebGLFramebuffer::WebGLAttachment* WebGLFramebuffer::getAttachment(GLenum attach ment, GLenum target) const
425 { 431 {
432 if (target == GL_READ_FRAMEBUFFER) {
433 const AttachmentMap::const_iterator it = m_readAttachments.find(attachme nt);
434 return (it != m_readAttachments.end()) ? it->value.get() : 0;
435 }
426 const AttachmentMap::const_iterator it = m_attachments.find(attachment); 436 const AttachmentMap::const_iterator it = m_attachments.find(attachment);
427 return (it != m_attachments.end()) ? it->value.get() : 0; 437 return (it != m_attachments.end()) ? it->value.get() : 0;
428 } 438 }
429 439
430 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(GLenum attachment) 440 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(GLenum attachment, G Lenum target)
431 { 441 {
432 ASSERT(isBound()); 442 ASSERT(isBound());
433 if (!m_object) 443 if (!m_object)
434 return; 444 return;
435 445
436 WebGLAttachment* attachmentObject = getAttachment(attachment); 446 WebGLAttachment* attachmentObject = getAttachment(attachment, target);
437 if (attachmentObject) { 447 if (attachmentObject) {
438 attachmentObject->onDetached(context()->webContext()); 448 attachmentObject->onDetached(context()->webContext());
439 m_attachments.remove(attachment); 449 if (target == GL_READ_FRAMEBUFFER)
450 m_readAttachments.remove(attachment);
451 else
452 m_attachments.remove(attachment);
440 drawBuffersIfNecessary(false); 453 drawBuffersIfNecessary(false);
441 switch (attachment) { 454 switch (attachment) {
442 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: 455 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL:
443 attach(GL_DEPTH_ATTACHMENT, GL_DEPTH_ATTACHMENT); 456 attach(target, GL_DEPTH_ATTACHMENT, GL_DEPTH_ATTACHMENT);
444 attach(GL_STENCIL_ATTACHMENT, GL_STENCIL_ATTACHMENT); 457 attach(target, GL_STENCIL_ATTACHMENT, GL_STENCIL_ATTACHMENT);
445 break; 458 break;
446 case GL_DEPTH_ATTACHMENT: 459 case GL_DEPTH_ATTACHMENT:
447 attach(GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL, GL_DEPTH_ATTACHMENT); 460 attach(target, GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL, GL_DEPTH_ATTACHM ENT);
448 break; 461 break;
449 case GL_STENCIL_ATTACHMENT: 462 case GL_STENCIL_ATTACHMENT:
450 attach(GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL, GL_STENCIL_ATTACHMENT); 463 attach(target, GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL, GL_STENCIL_ATTAC HMENT);
451 break; 464 break;
452 } 465 }
453 } 466 }
454 } 467 }
455 468
456 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(WebGLSharedObject* a ttachment) 469 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(WebGLSharedObject* a ttachment, GLenum target)
457 { 470 {
458 ASSERT(isBound()); 471 ASSERT(isBound());
459 if (!m_object) 472 if (!m_object)
460 return; 473 return;
461 if (!attachment) 474 if (!attachment)
462 return; 475 return;
463 476
464 bool checkMore = true; 477 bool checkMore = true;
465 while (checkMore) { 478 while (checkMore) {
466 checkMore = false; 479 checkMore = false;
467 for (const auto& it : m_attachments) { 480 for (const auto& it : (target == GL_READ_FRAMEBUFFER ? m_readAttachments : m_attachments)) {
468 WebGLAttachment* attachmentObject = it.value.get(); 481 WebGLAttachment* attachmentObject = it.value.get();
469 if (attachmentObject->isSharedObject(attachment)) { 482 if (attachmentObject->isSharedObject(attachment)) {
470 GLenum attachmentType = it.key; 483 GLenum attachmentType = it.key;
471 attachmentObject->unattach(context()->webContext(), attachmentTy pe); 484 attachmentObject->unattach(context()->webContext(), target, atta chmentType);
472 removeAttachmentFromBoundFramebuffer(attachmentType); 485 removeAttachmentFromBoundFramebuffer(attachmentType, target);
473 checkMore = true; 486 checkMore = true;
474 break; 487 break;
475 } 488 }
476 } 489 }
477 } 490 }
478 } 491 }
479 492
480 GLenum WebGLFramebuffer::colorBufferFormat() const 493 GLenum WebGLFramebuffer::colorBufferFormat() const
481 { 494 {
482 if (!m_object) 495 if (!m_object)
483 return 0; 496 return 0;
484 WebGLAttachment* attachment = getAttachment(GL_COLOR_ATTACHMENT0); 497 WebGLAttachment* attachment = getAttachment(GL_COLOR_ATTACHMENT0);
485 if (!attachment) 498 if (!attachment)
486 return 0; 499 return 0;
487 return attachment->format(); 500 return attachment->format();
488 } 501 }
489 502
490 GLenum WebGLFramebuffer::checkStatus(const char** reason) const 503 GLenum WebGLFramebuffer::checkStatus(const char** reason, GLenum target) const
491 { 504 {
492 unsigned count = 0; 505 unsigned count = 0;
493 GLsizei width = 0, height = 0; 506 GLsizei width = 0, height = 0;
494 bool haveDepth = false; 507 bool haveDepth = false;
495 bool haveStencil = false; 508 bool haveStencil = false;
496 bool haveDepthStencil = false; 509 bool haveDepthStencil = false;
497 for (const auto& it : m_attachments) { 510 for (const auto& it : (target == GL_READ_FRAMEBUFFER ? m_readAttachments : m _attachments)) {
498 WebGLAttachment* attachment = it.value.get(); 511 WebGLAttachment* attachment = it.value.get();
499 if (!isAttachmentComplete(attachment, it.key, reason)) 512 if (!isAttachmentComplete(attachment, it.key, reason))
500 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; 513 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
501 if (!attachment->valid()) { 514 if (!attachment->valid()) {
502 *reason = "attachment is not valid"; 515 *reason = "attachment is not valid";
503 return GL_FRAMEBUFFER_UNSUPPORTED; 516 return GL_FRAMEBUFFER_UNSUPPORTED;
504 } 517 }
505 if (!attachment->format()) { 518 if (!attachment->format()) {
506 *reason = "attachment is an unsupported format"; 519 *reason = "attachment is an unsupported format";
507 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; 520 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
(...skipping 29 matching lines...) Expand all
537 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; 550 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
538 } 551 }
539 // WebGL specific: no conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments. 552 // WebGL specific: no conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments.
540 if ((haveDepthStencil && (haveDepth || haveStencil)) || (haveDepth && haveSt encil)) { 553 if ((haveDepthStencil && (haveDepth || haveStencil)) || (haveDepth && haveSt encil)) {
541 *reason = "conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments"; 554 *reason = "conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments";
542 return GL_FRAMEBUFFER_UNSUPPORTED; 555 return GL_FRAMEBUFFER_UNSUPPORTED;
543 } 556 }
544 return GL_FRAMEBUFFER_COMPLETE; 557 return GL_FRAMEBUFFER_COMPLETE;
545 } 558 }
546 559
547 bool WebGLFramebuffer::onAccess(WebGraphicsContext3D* context3d, const char** re ason) 560 bool WebGLFramebuffer::onAccess(WebGraphicsContext3D* context3d, const char** re ason, GLenum target)
548 { 561 {
549 if (checkStatus(reason) != GL_FRAMEBUFFER_COMPLETE) 562 if (checkStatus(reason, target) != GL_FRAMEBUFFER_COMPLETE)
550 return false; 563 return false;
551 return true; 564 return true;
552 } 565 }
553 566
554 bool WebGLFramebuffer::hasStencilBuffer() const 567 bool WebGLFramebuffer::hasStencilBuffer() const
555 { 568 {
556 WebGLAttachment* attachment = getAttachment(GL_STENCIL_ATTACHMENT); 569 WebGLAttachment* attachment = getAttachment(GL_STENCIL_ATTACHMENT);
557 if (!attachment) 570 if (!attachment)
558 attachment = getAttachment(GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL); 571 attachment = getAttachment(GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL);
559 return attachment && attachment->valid(); 572 return attachment && attachment->valid();
560 } 573 }
561 574
562 void WebGLFramebuffer::deleteObjectImpl(WebGraphicsContext3D* context3d) 575 void WebGLFramebuffer::deleteObjectImpl(WebGraphicsContext3D* context3d)
563 { 576 {
564 #if !ENABLE(OILPAN) 577 #if !ENABLE(OILPAN)
565 // With Oilpan, both the AttachmentMap and its WebGLAttachment objects are 578 // With Oilpan, both the AttachmentMap and its WebGLAttachment objects are
566 // GCed objects and cannot be accessed, as they may have been finalized 579 // GCed objects and cannot be accessed, as they may have been finalized
567 // already during the same GC sweep. 580 // already during the same GC sweep.
568 // 581 //
569 // The WebGLAttachment-derived classes instead handle detachment 582 // The WebGLAttachment-derived classes instead handle detachment
570 // on their own when finalizing, so the explicit notification is 583 // on their own when finalizing, so the explicit notification is
571 // not needed. 584 // not needed.
572 for (const auto& attachment : m_attachments) 585 for (const auto& attachment : m_attachments)
573 attachment.value->onDetached(context3d); 586 attachment.value->onDetached(context3d);
587 for (const auto& attachment : m_readAttachments)
588 attachment.value->onDetached(context3d);
574 #endif 589 #endif
575 590
576 context3d->deleteFramebuffer(m_object); 591 context3d->deleteFramebuffer(m_object);
577 m_object = 0; 592 m_object = 0;
578 } 593 }
579 594
580 bool WebGLFramebuffer::isBound() const 595 bool WebGLFramebuffer::isBound() const
581 { 596 {
582 return (context()->m_framebufferBinding.get() == this); 597 return (context()->m_framebufferBinding.get() == this);
583 } 598 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 return m_drawBuffers[index]; 639 return m_drawBuffers[index];
625 if (drawBuffer == GL_DRAW_BUFFER0_EXT) 640 if (drawBuffer == GL_DRAW_BUFFER0_EXT)
626 return GL_COLOR_ATTACHMENT0; 641 return GL_COLOR_ATTACHMENT0;
627 return GL_NONE; 642 return GL_NONE;
628 } 643 }
629 644
630 DEFINE_TRACE(WebGLFramebuffer) 645 DEFINE_TRACE(WebGLFramebuffer)
631 { 646 {
632 #if ENABLE(OILPAN) 647 #if ENABLE(OILPAN)
633 visitor->trace(m_attachments); 648 visitor->trace(m_attachments);
649 visitor->trace(m_readAttachments);
634 #endif 650 #endif
635 WebGLContextObject::trace(visitor); 651 WebGLContextObject::trace(visitor);
636 } 652 }
637 653
638 } 654 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698