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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 PassRefPtr<WebGLFramebuffer> WebGLFramebuffer::create(WebGLRenderingContextBase*
ctx) | 256 PassRefPtr<WebGLFramebuffer> WebGLFramebuffer::create(WebGLRenderingContextBase*
ctx) |
257 { | 257 { |
258 return adoptRef(new WebGLFramebuffer(ctx)); | 258 return adoptRef(new WebGLFramebuffer(ctx)); |
259 } | 259 } |
260 | 260 |
261 WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContextBase* ctx) | 261 WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContextBase* ctx) |
262 : WebGLContextObject(ctx) | 262 : WebGLContextObject(ctx) |
263 , m_hasEverBeenBound(false) | 263 , m_hasEverBeenBound(false) |
264 { | 264 { |
265 ScriptWrappable::init(this); | 265 ScriptWrappable::init(this); |
266 setObject(ctx->webGraphicsContext3D()->createFramebuffer()); | 266 setObject(ctx->webContext()->createFramebuffer()); |
267 } | 267 } |
268 | 268 |
269 WebGLFramebuffer::~WebGLFramebuffer() | 269 WebGLFramebuffer::~WebGLFramebuffer() |
270 { | 270 { |
271 deleteObject(0); | 271 deleteObject(0); |
272 } | 272 } |
273 | 273 |
274 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum attachment, GLenu
m texTarget, WebGLTexture* texture, GLint level) | 274 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum attachment, GLenu
m texTarget, WebGLTexture* texture, GLint level) |
275 { | 275 { |
276 ASSERT(isBound()); | 276 ASSERT(isBound()); |
(...skipping 18 matching lines...) Expand all Loading... |
295 drawBuffersIfNecessary(false); | 295 drawBuffersIfNecessary(false); |
296 renderbuffer->onAttached(); | 296 renderbuffer->onAttached(); |
297 } | 297 } |
298 } | 298 } |
299 | 299 |
300 void WebGLFramebuffer::attach(GLenum attachment, GLenum attachmentPoint) | 300 void WebGLFramebuffer::attach(GLenum attachment, GLenum attachmentPoint) |
301 { | 301 { |
302 ASSERT(isBound()); | 302 ASSERT(isBound()); |
303 WebGLAttachment* attachmentObject = getAttachment(attachment); | 303 WebGLAttachment* attachmentObject = getAttachment(attachment); |
304 if (attachmentObject) | 304 if (attachmentObject) |
305 attachmentObject->attach(context()->webGraphicsContext3D(), attachmentPo
int); | 305 attachmentObject->attach(context()->webContext(), attachmentPoint); |
306 } | 306 } |
307 | 307 |
308 WebGLSharedObject* WebGLFramebuffer::getAttachmentObject(GLenum attachment) cons
t | 308 WebGLSharedObject* WebGLFramebuffer::getAttachmentObject(GLenum attachment) cons
t |
309 { | 309 { |
310 if (!object()) | 310 if (!object()) |
311 return 0; | 311 return 0; |
312 WebGLAttachment* attachmentObject = getAttachment(attachment); | 312 WebGLAttachment* attachmentObject = getAttachment(attachment); |
313 return attachmentObject ? attachmentObject->object() : 0; | 313 return attachmentObject ? attachmentObject->object() : 0; |
314 } | 314 } |
315 | 315 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 } | 406 } |
407 | 407 |
408 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(GLenum attachment) | 408 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(GLenum attachment) |
409 { | 409 { |
410 ASSERT(isBound()); | 410 ASSERT(isBound()); |
411 if (!object()) | 411 if (!object()) |
412 return; | 412 return; |
413 | 413 |
414 WebGLAttachment* attachmentObject = getAttachment(attachment); | 414 WebGLAttachment* attachmentObject = getAttachment(attachment); |
415 if (attachmentObject) { | 415 if (attachmentObject) { |
416 attachmentObject->onDetached(context()->webGraphicsContext3D()); | 416 attachmentObject->onDetached(context()->webContext()); |
417 m_attachments.remove(attachment); | 417 m_attachments.remove(attachment); |
418 drawBuffersIfNecessary(false); | 418 drawBuffersIfNecessary(false); |
419 switch (attachment) { | 419 switch (attachment) { |
420 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: | 420 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: |
421 attach(GL_DEPTH_ATTACHMENT, GL_DEPTH_ATTACHMENT); | 421 attach(GL_DEPTH_ATTACHMENT, GL_DEPTH_ATTACHMENT); |
422 attach(GL_STENCIL_ATTACHMENT, GL_STENCIL_ATTACHMENT); | 422 attach(GL_STENCIL_ATTACHMENT, GL_STENCIL_ATTACHMENT); |
423 break; | 423 break; |
424 case GL_DEPTH_ATTACHMENT: | 424 case GL_DEPTH_ATTACHMENT: |
425 attach(GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL, GL_DEPTH_ATTACHMENT); | 425 attach(GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL, GL_DEPTH_ATTACHMENT); |
426 break; | 426 break; |
(...skipping 12 matching lines...) Expand all Loading... |
439 if (!attachment) | 439 if (!attachment) |
440 return; | 440 return; |
441 | 441 |
442 bool checkMore = true; | 442 bool checkMore = true; |
443 while (checkMore) { | 443 while (checkMore) { |
444 checkMore = false; | 444 checkMore = false; |
445 for (AttachmentMap::iterator it = m_attachments.begin(); it != m_attachm
ents.end(); ++it) { | 445 for (AttachmentMap::iterator it = m_attachments.begin(); it != m_attachm
ents.end(); ++it) { |
446 WebGLAttachment* attachmentObject = it->value.get(); | 446 WebGLAttachment* attachmentObject = it->value.get(); |
447 if (attachmentObject->isSharedObject(attachment)) { | 447 if (attachmentObject->isSharedObject(attachment)) { |
448 GLenum attachmentType = it->key; | 448 GLenum attachmentType = it->key; |
449 attachmentObject->unattach(context()->webGraphicsContext3D(), at
tachmentType); | 449 attachmentObject->unattach(context()->webContext(), attachmentTy
pe); |
450 removeAttachmentFromBoundFramebuffer(attachmentType); | 450 removeAttachmentFromBoundFramebuffer(attachmentType); |
451 checkMore = true; | 451 checkMore = true; |
452 break; | 452 break; |
453 } | 453 } |
454 } | 454 } |
455 } | 455 } |
456 } | 456 } |
457 | 457 |
458 GLsizei WebGLFramebuffer::colorBufferWidth() const | 458 GLsizei WebGLFramebuffer::colorBufferWidth() const |
459 { | 459 { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 reset = true; | 594 reset = true; |
595 } | 595 } |
596 } else { | 596 } else { |
597 if (m_filteredDrawBuffers[i] != GL_NONE) { | 597 if (m_filteredDrawBuffers[i] != GL_NONE) { |
598 m_filteredDrawBuffers[i] = GL_NONE; | 598 m_filteredDrawBuffers[i] = GL_NONE; |
599 reset = true; | 599 reset = true; |
600 } | 600 } |
601 } | 601 } |
602 } | 602 } |
603 if (reset) { | 603 if (reset) { |
604 context()->webGraphicsContext3D()->drawBuffersEXT( | 604 context()->webContext()->drawBuffersEXT( |
605 m_filteredDrawBuffers.size(), m_filteredDrawBuffers.data()); | 605 m_filteredDrawBuffers.size(), m_filteredDrawBuffers.data()); |
606 } | 606 } |
607 } | 607 } |
608 | 608 |
609 GLenum WebGLFramebuffer::getDrawBuffer(GLenum drawBuffer) | 609 GLenum WebGLFramebuffer::getDrawBuffer(GLenum drawBuffer) |
610 { | 610 { |
611 int index = static_cast<int>(drawBuffer - GL_DRAW_BUFFER0_EXT); | 611 int index = static_cast<int>(drawBuffer - GL_DRAW_BUFFER0_EXT); |
612 ASSERT(index >= 0); | 612 ASSERT(index >= 0); |
613 if (index < static_cast<int>(m_drawBuffers.size())) | 613 if (index < static_cast<int>(m_drawBuffers.size())) |
614 return m_drawBuffers[index]; | 614 return m_drawBuffers[index]; |
615 if (drawBuffer == GL_DRAW_BUFFER0_EXT) | 615 if (drawBuffer == GL_DRAW_BUFFER0_EXT) |
616 return GL_COLOR_ATTACHMENT0; | 616 return GL_COLOR_ATTACHMENT0; |
617 return GL_NONE; | 617 return GL_NONE; |
618 } | 618 } |
619 | 619 |
620 } | 620 } |
OLD | NEW |