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

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: addressed kbr@'s feedback 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(target, attachment);
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 m_attachments.add(attachment, WebGLTextureAttachment::create(texture, te xTarget, level));
303 drawBuffersIfNecessary(false); 303 drawBuffersIfNecessary(false);
304 texture->onAttached(); 304 texture->onAttached();
305 } 305 }
306 } 306 }
307 307
308 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum attachment, WebGL Renderbuffer* renderbuffer) 308 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, GLenum at tachment, WebGLRenderbuffer* renderbuffer)
309 { 309 {
310 ASSERT(isBound()); 310 ASSERT(isBound());
311 removeAttachmentFromBoundFramebuffer(attachment); 311 removeAttachmentFromBoundFramebuffer(target, attachment);
312 if (!m_object) 312 if (!m_object)
313 return; 313 return;
314 if (renderbuffer && renderbuffer->object()) { 314 if (renderbuffer && renderbuffer->object()) {
315 m_attachments.add(attachment, WebGLRenderbufferAttachment::create(render buffer)); 315 m_attachments.add(attachment, WebGLRenderbufferAttachment::create(render buffer));
316 drawBuffersIfNecessary(false); 316 drawBuffersIfNecessary(false);
317 renderbuffer->onAttached(); 317 renderbuffer->onAttached();
318 } 318 }
319 } 319 }
320 320
321 void WebGLFramebuffer::attach(GLenum attachment, GLenum attachmentPoint) 321 void WebGLFramebuffer::attach(GLenum target, GLenum attachment, GLenum attachmen tPoint)
322 { 322 {
323 ASSERT(isBound()); 323 ASSERT(isBound());
324 WebGLAttachment* attachmentObject = getAttachment(attachment); 324 WebGLAttachment* attachmentObject = getAttachment(target, attachment);
325 if (attachmentObject) 325 if (attachmentObject)
326 attachmentObject->attach(context()->webContext(), attachmentPoint); 326 attachmentObject->attach(context()->webContext(), target, attachmentPoin t);
327 } 327 }
328 328
329 WebGLSharedObject* WebGLFramebuffer::getAttachmentObject(GLenum attachment) cons t 329 WebGLSharedObject* WebGLFramebuffer::getAttachmentObject(GLenum attachment) cons t
330 { 330 {
331 if (!m_object) 331 if (!m_object)
332 return nullptr; 332 return nullptr;
333 WebGLAttachment* attachmentObject = getAttachment(attachment); 333 WebGLAttachment* attachmentObject = getAttachment(GL_FRAMEBUFFER, attachment );
334 return attachmentObject ? attachmentObject->object() : nullptr; 334 return attachmentObject ? attachmentObject->object() : nullptr;
335 } 335 }
336 336
337 bool WebGLFramebuffer::isAttachmentComplete(WebGLAttachment* attachedObject, GLe num attachment, const char** reason) const 337 bool WebGLFramebuffer::isAttachmentComplete(WebGLAttachment* attachedObject, GLe num attachment, const char** reason) const
338 { 338 {
339 ASSERT(attachedObject && attachedObject->valid()); 339 ASSERT(attachedObject && attachedObject->valid());
340 ASSERT(reason); 340 ASSERT(reason);
341 341
342 GLenum internalformat = attachedObject->format(); 342 GLenum internalformat = attachedObject->format();
343 WebGLSharedObject* object = attachedObject->object(); 343 WebGLSharedObject* object = attachedObject->object();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 return false; 414 return false;
415 } 415 }
416 416
417 if (!attachedObject->width() || !attachedObject->height()) { 417 if (!attachedObject->width() || !attachedObject->height()) {
418 *reason = "attachment has a 0 dimension"; 418 *reason = "attachment has a 0 dimension";
419 return false; 419 return false;
420 } 420 }
421 return true; 421 return true;
422 } 422 }
423 423
424 WebGLFramebuffer::WebGLAttachment* WebGLFramebuffer::getAttachment(GLenum attach ment) const 424 WebGLFramebuffer::WebGLAttachment* WebGLFramebuffer::getAttachment(GLenum target , GLenum attachment) const
Ken Russell (switch to Gerrit) 2015/06/04 02:45:33 The "target" argument is not used here any more an
yunchao 2015/06/09 10:37:54 Acknowledged.
425 { 425 {
426 const AttachmentMap::const_iterator it = m_attachments.find(attachment); 426 const AttachmentMap::const_iterator it = m_attachments.find(attachment);
427 return (it != m_attachments.end()) ? it->value.get() : 0; 427 return (it != m_attachments.end()) ? it->value.get() : 0;
428 } 428 }
429 429
430 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(GLenum attachment) 430 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(GLenum target, GLenu m attachment)
431 { 431 {
432 ASSERT(isBound()); 432 ASSERT(isBound());
433 if (!m_object) 433 if (!m_object)
434 return; 434 return;
435 435
436 WebGLAttachment* attachmentObject = getAttachment(attachment); 436 WebGLAttachment* attachmentObject = getAttachment(target, attachment);
437 if (attachmentObject) { 437 if (attachmentObject) {
438 attachmentObject->onDetached(context()->webContext()); 438 attachmentObject->onDetached(context()->webContext());
439 m_attachments.remove(attachment); 439 m_attachments.remove(attachment);
440 drawBuffersIfNecessary(false); 440 drawBuffersIfNecessary(false);
441 switch (attachment) { 441 switch (attachment) {
442 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: 442 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL:
443 attach(GL_DEPTH_ATTACHMENT, GL_DEPTH_ATTACHMENT); 443 attach(target, GL_DEPTH_ATTACHMENT, GL_DEPTH_ATTACHMENT);
444 attach(GL_STENCIL_ATTACHMENT, GL_STENCIL_ATTACHMENT); 444 attach(target, GL_STENCIL_ATTACHMENT, GL_STENCIL_ATTACHMENT);
445 break; 445 break;
446 case GL_DEPTH_ATTACHMENT: 446 case GL_DEPTH_ATTACHMENT:
447 attach(GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL, GL_DEPTH_ATTACHMENT); 447 attach(target, GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL, GL_DEPTH_ATTACHM ENT);
448 break; 448 break;
449 case GL_STENCIL_ATTACHMENT: 449 case GL_STENCIL_ATTACHMENT:
450 attach(GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL, GL_STENCIL_ATTACHMENT); 450 attach(target, GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL, GL_STENCIL_ATTAC HMENT);
451 break; 451 break;
452 } 452 }
453 } 453 }
454 } 454 }
455 455
456 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(WebGLSharedObject* a ttachment) 456 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(GLenum target, WebGL SharedObject* attachment)
457 { 457 {
458 ASSERT(isBound()); 458 ASSERT(isBound());
459 if (!m_object) 459 if (!m_object)
460 return; 460 return;
461 if (!attachment) 461 if (!attachment)
462 return; 462 return;
463 463
464 bool checkMore = true; 464 bool checkMore = true;
465 while (checkMore) { 465 while (checkMore) {
466 checkMore = false; 466 checkMore = false;
467 for (const auto& it : m_attachments) { 467 for (const auto& it : m_attachments) {
468 WebGLAttachment* attachmentObject = it.value.get(); 468 WebGLAttachment* attachmentObject = it.value.get();
469 if (attachmentObject->isSharedObject(attachment)) { 469 if (attachmentObject->isSharedObject(attachment)) {
470 GLenum attachmentType = it.key; 470 GLenum attachmentType = it.key;
471 attachmentObject->unattach(context()->webContext(), attachmentTy pe); 471 attachmentObject->unattach(context()->webContext(), target, atta chmentType);
472 removeAttachmentFromBoundFramebuffer(attachmentType); 472 removeAttachmentFromBoundFramebuffer(target, attachmentType);
473 checkMore = true; 473 checkMore = true;
474 break; 474 break;
475 } 475 }
476 } 476 }
477 } 477 }
478 } 478 }
479 479
480 GLenum WebGLFramebuffer::colorBufferFormat() const 480 GLenum WebGLFramebuffer::colorBufferFormat() const
481 { 481 {
482 if (!m_object) 482 if (!m_object)
483 return 0; 483 return 0;
484 WebGLAttachment* attachment = getAttachment(GL_COLOR_ATTACHMENT0); 484 WebGLAttachment* attachment = getAttachment(GL_FRAMEBUFFER, GL_COLOR_ATTACHM ENT0);
485 if (!attachment) 485 if (!attachment)
486 return 0; 486 return 0;
487 return attachment->format(); 487 return attachment->format();
488 } 488 }
489 489
490 GLenum WebGLFramebuffer::checkStatus(const char** reason) const 490 GLenum WebGLFramebuffer::checkStatus(const char** reason, GLenum target) const
Ken Russell (switch to Gerrit) 2015/06/04 02:45:33 The "target" argument is unused here and should be
yunchao 2015/06/09 10:37:54 Acknowledged.
491 { 491 {
492 unsigned count = 0; 492 unsigned count = 0;
493 GLsizei width = 0, height = 0; 493 GLsizei width = 0, height = 0;
494 bool haveDepth = false; 494 bool haveDepth = false;
495 bool haveStencil = false; 495 bool haveStencil = false;
496 bool haveDepthStencil = false; 496 bool haveDepthStencil = false;
497 for (const auto& it : m_attachments) { 497 for (const auto& it : m_attachments) {
498 WebGLAttachment* attachment = it.value.get(); 498 WebGLAttachment* attachment = it.value.get();
499 if (!isAttachmentComplete(attachment, it.key, reason)) 499 if (!isAttachmentComplete(attachment, it.key, reason))
500 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; 500 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(WebGraphicsContext3D* context3d, const char** re ason) 547 bool WebGLFramebuffer::onAccess(WebGraphicsContext3D* context3d, GLenum target, const char** reason)
548 { 548 {
549 if (checkStatus(reason) != GL_FRAMEBUFFER_COMPLETE) 549 if (checkStatus(reason, target) != 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_FRAMEBUFFER, GL_STENCIL_ATTAC HMENT);
557 if (!attachment) 557 if (!attachment)
558 attachment = getAttachment(GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL); 558 attachment = getAttachment(GL_FRAMEBUFFER, GC3D_DEPTH_STENCIL_ATTACHMENT _WEBGL);
559 return attachment && attachment->valid(); 559 return attachment && attachment->valid();
560 } 560 }
561 561
562 void WebGLFramebuffer::deleteObjectImpl(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 //
(...skipping 22 matching lines...) Expand all
591 drawBuffersIfNecessary(true); 591 drawBuffersIfNecessary(true);
592 } 592 }
593 593
594 void WebGLFramebuffer::drawBuffersIfNecessary(bool force) 594 void WebGLFramebuffer::drawBuffersIfNecessary(bool force)
595 { 595 {
596 if (!context()->extensionEnabled(WebGLDrawBuffersName)) 596 if (!context()->extensionEnabled(WebGLDrawBuffersName))
597 return; 597 return;
598 bool reset = force; 598 bool reset = force;
599 // This filtering works around graphics driver bugs on Mac OS X. 599 // This filtering works around graphics driver bugs on Mac OS X.
600 for (size_t i = 0; i < m_drawBuffers.size(); ++i) { 600 for (size_t i = 0; i < m_drawBuffers.size(); ++i) {
601 if (m_drawBuffers[i] != GL_NONE && getAttachment(m_drawBuffers[i])) { 601 if (m_drawBuffers[i] != GL_NONE && getAttachment(GL_FRAMEBUFFER, m_drawB uffers[i])) {
602 if (m_filteredDrawBuffers[i] != m_drawBuffers[i]) { 602 if (m_filteredDrawBuffers[i] != m_drawBuffers[i]) {
603 m_filteredDrawBuffers[i] = m_drawBuffers[i]; 603 m_filteredDrawBuffers[i] = m_drawBuffers[i];
604 reset = true; 604 reset = true;
605 } 605 }
606 } else { 606 } else {
607 if (m_filteredDrawBuffers[i] != GL_NONE) { 607 if (m_filteredDrawBuffers[i] != GL_NONE) {
608 m_filteredDrawBuffers[i] = GL_NONE; 608 m_filteredDrawBuffers[i] = GL_NONE;
609 reset = true; 609 reset = true;
610 } 610 }
611 } 611 }
(...skipping 17 matching lines...) Expand all
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698