Modified: branches/chromium/1180/Source/WebCore/html/canvas/WebGLFramebuffer.cpp (120839 => 120840)
--- branches/chromium/1180/Source/WebCore/html/canvas/WebGLFramebuffer.cpp 2012-06-20 18:18:47 UTC (rev 120839)
+++ branches/chromium/1180/Source/WebCore/html/canvas/WebGLFramebuffer.cpp 2012-06-20 18:22:37 UTC (rev 120840)
@@ -128,7 +128,7 @@
void WebGLRenderbufferAttachment::unattach(GraphicsContext3D* context, GC3Denum attachment)
{
- if (attachment == GraphicsContext3D::DEPTH_STENCIL) {
+ if (attachment == GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT) {
context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, 0);
context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, 0);
} else
@@ -283,11 +283,10 @@
void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GC3Denum attachment, GC3Denum texTarget, WebGLTexture* texture, GC3Dint level)
{
ASSERT(isBound());
+ removeAttachmentFromBoundFramebuffer(attachment);
if (!object())
return;
- removeAttachmentFromBoundFramebuffer(attachment);
if (texture && texture->object()) {
-
m_attachments.add(attachment, WebGLTextureAttachment::create(texture, texTarget, level));
texture->onAttached();
}
@@ -296,9 +295,9 @@
void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GC3Denum attachment, WebGLRenderbuffer* renderbuffer)
{
ASSERT(isBound());
+ removeAttachmentFromBoundFramebuffer(attachment);
if (!object())
return;
- removeAttachmentFromBoundFramebuffer(attachment);
if (renderbuffer && renderbuffer->object()) {
m_attachments.add(attachment, WebGLRenderbufferAttachment::create(renderbuffer));
renderbuffer->onAttached();
@@ -337,6 +336,18 @@
if (attachmentObject) {
attachmentObject->onDetached(context()->graphicsContext3D());
m_attachments.remove(attachment);
+ switch (attachment) {
+ case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
+ attach(GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::DEPTH_ATTACHMENT);
+ attach(GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::STENCIL_ATTACHMENT);
+ break;
+ case GraphicsContext3D::DEPTH_ATTACHMENT:
+ attach(GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT, GraphicsContext3D::DEPTH_ATTACHMENT);
+ break;
+ case GraphicsContext3D::STENCIL_ATTACHMENT:
+ attach(GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT, GraphicsContext3D::STENCIL_ATTACHMENT);
+ break;
+ }
}
}
Modified: branches/chromium/1180/Source/WebCore/html/canvas/WebGLFramebuffer.h (120839 => 120840)
--- branches/chromium/1180/Source/WebCore/html/canvas/WebGLFramebuffer.h 2012-06-20 18:18:47 UTC (rev 120839)
+++ branches/chromium/1180/Source/WebCore/html/canvas/WebGLFramebuffer.h 2012-06-20 18:22:37 UTC (rev 120840)
@@ -71,9 +71,6 @@
void removeAttachmentFromBoundFramebuffer(GC3Denum);
WebGLSharedObject* getAttachmentObject(GC3Denum) const;
- // attach 'attachment' at 'attachmentPoint'.
- void attach(GC3Denum attachment, GC3Denum attachmentPoint);
-
GC3Denum getColorBufferFormat() const;
GC3Dsizei getColorBufferWidth() const;
GC3Dsizei getColorBufferHeight() const;
@@ -114,6 +111,9 @@
// Check if the framebuffer is currently bound.
bool isBound() const;
+ // attach 'attachment' at 'attachmentPoint'.
+ void attach(GC3Denum attachment, GC3Denum attachmentPoint);
+
typedef WTF::HashMap<GC3Denum, RefPtr<WebGLAttachment> > AttachmentMap;
AttachmentMap m_attachments;
Modified: branches/chromium/1180/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (120839 => 120840)
--- branches/chromium/1180/Source/WebCore/html/canvas/WebGLRenderingContext.cpp 2012-06-20 18:18:47 UTC (rev 120839)
+++ branches/chromium/1180/Source/WebCore/html/canvas/WebGLRenderingContext.cpp 2012-06-20 18:22:37 UTC (rev 120840)
@@ -2059,50 +2059,25 @@
return;
}
Platform3DObject bufferObject = objectOrZero(buffer);
- bool reattachDepth = false;
- bool reattachStencil = false;
- bool reattachDepthStencilDepth = false;
- bool reattachDepthStencilStencil = false;
switch (attachment) {
case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
m_context->framebufferRenderbuffer(target, GraphicsContext3D::DEPTH_ATTACHMENT, renderbuffertarget, bufferObject);
m_context->framebufferRenderbuffer(target, GraphicsContext3D::STENCIL_ATTACHMENT, renderbuffertarget, bufferObject);
- if (!bufferObject) {
- reattachDepth = true;
- reattachStencil = true;
- }
break;
case GraphicsContext3D::DEPTH_ATTACHMENT:
m_context->framebufferRenderbuffer(target, attachment, renderbuffertarget, bufferObject);
- if (!bufferObject)
- reattachDepthStencilDepth = true;
break;
case GraphicsContext3D::STENCIL_ATTACHMENT:
m_context->framebufferRenderbuffer(target, attachment, renderbuffertarget, bufferObject);
- if (!bufferObject)
- reattachDepthStencilStencil = true;
break;
default:
m_context->framebufferRenderbuffer(target, attachment, renderbuffertarget, bufferObject);
}
m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, buffer);
- reattachDepthStencilAttachments(reattachDepth, reattachStencil, reattachDepthStencilDepth, reattachDepthStencilStencil);
applyStencilTest();
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::reattachDepthStencilAttachments(bool reattachDepth, bool reattachStencil, bool reattachDepthStencilDepth, bool reattachDepthStencilStencil)
-{
- if (reattachDepth)
- m_framebufferBinding->attach(GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::DEPTH_ATTACHMENT);
- if (reattachStencil)
- m_framebufferBinding->attach(GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::STENCIL_ATTACHMENT);
- if (reattachDepthStencilDepth)
- m_framebufferBinding->attach(GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT, GraphicsContext3D::DEPTH_ATTACHMENT);
- if (reattachDepthStencilStencil)
- m_framebufferBinding->attach(GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT, GraphicsContext3D::STENCIL_ATTACHMENT);
-}
-
void WebGLRenderingContext::framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum textarget, WebGLTexture* texture, GC3Dint level, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
@@ -2124,34 +2099,21 @@
return;
}
Platform3DObject textureObject = objectOrZero(texture);
- bool reattachDepth = false;
- bool reattachStencil = false;
- bool reattachDepthStencilDepth = false;
- bool reattachDepthStencilStencil = false;
switch (attachment) {
case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
m_context->framebufferTexture2D(target, GraphicsContext3D::DEPTH_ATTACHMENT, textarget, textureObject, level);
m_context->framebufferTexture2D(target, GraphicsContext3D::STENCIL_ATTACHMENT, textarget, textureObject, level);
- if (!textureObject) {
- reattachDepth = true;
- reattachStencil = true;
- }
break;
case GraphicsContext3D::DEPTH_ATTACHMENT:
m_context->framebufferTexture2D(target, attachment, textarget, textureObject, level);
- if (!textureObject)
- reattachDepthStencilDepth = true;
break;
case GraphicsContext3D::STENCIL_ATTACHMENT:
m_context->framebufferTexture2D(target, attachment, textarget, textureObject, level);
- if (!textureObject)
- reattachDepthStencilStencil = true;
break;
default:
m_context->framebufferTexture2D(target, attachment, textarget, textureObject, level);
}
m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget, texture, level);
- reattachDepthStencilAttachments(reattachDepth, reattachStencil, reattachDepthStencilDepth, reattachDepthStencilStencil);
applyStencilTest();
cleanupAfterGraphicsCall(false);
}
@@ -2470,7 +2432,7 @@
case GraphicsContext3D::CURRENT_PROGRAM:
return WebGLGetInfo(PassRefPtr<WebGLProgram>(m_currentProgram));
case GraphicsContext3D::DEPTH_BITS:
- if (!m_attributes.depth)
+ if (!m_framebufferBinding && !m_attributes.depth)
return WebGLGetInfo(intZero);
return getIntParameter(pname);
case GraphicsContext3D::DEPTH_CLEAR_VALUE:
@@ -2565,7 +2527,7 @@
case GraphicsContext3D::STENCIL_BACK_WRITEMASK:
return getUnsignedIntParameter(pname);
case GraphicsContext3D::STENCIL_BITS:
- if (!m_attributes.stencil)
+ if (!m_framebufferBinding && !m_attributes.stencil)
return WebGLGetInfo(intZero);
return getIntParameter(pname);
case GraphicsContext3D::STENCIL_CLEAR_VALUE:
Modified: branches/chromium/1180/Source/WebCore/html/canvas/WebGLRenderingContext.h (120839 => 120840)
--- branches/chromium/1180/Source/WebCore/html/canvas/WebGLRenderingContext.h 2012-06-20 18:18:47 UTC (rev 120839)
+++ branches/chromium/1180/Source/WebCore/html/canvas/WebGLRenderingContext.h 2012-06-20 18:22:37 UTC (rev 120840)
@@ -368,9 +368,6 @@
// Adds a compressed texture format.
void addCompressedTextureFormat(GC3Denum);
- // Reattaches depth and stencil attachments after one has been unattached.
- void reattachDepthStencilAttachments(bool reattachDepth, bool reattachStencil, bool reattachDepthStencilDepth, bool reattachDepthStencilStencil);
-
#if ENABLE(VIDEO)
PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, ExceptionCode&);
#endif