<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[162105] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/162105">162105</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2014-01-15 17:51:38 -0800 (Wed, 15 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WebGL] Resizing and entering/exiting full screen draws garbage
https://bugs.webkit.org/show_bug.cgi?id=127077

Reviewed by Dean Jackson.

* platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
(WebCore::GraphicsContext3D::reshapeFBOs): Simplified logic regarding FBO switching.
(WebCore::GraphicsContext3D::resolveMultisamplingIfNecessary): Make sure a few things
are turned off that might affect blitting data from one FBO to another.
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::prepareTexture): Actually turn dithering off!
(WebCore::GraphicsContext3D::reshape): Mark the context as dirty when resizing so that
the GL view is redrawn during resizing events.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsopenglGraphicsContext3DOpenGLcpp">trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsopenglGraphicsContext3DOpenGLCommoncpp">trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (162104 => 162105)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-16 01:06:40 UTC (rev 162104)
+++ trunk/Source/WebCore/ChangeLog        2014-01-16 01:51:38 UTC (rev 162105)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2014-01-15  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        [WebGL] Resizing and entering/exiting full screen draws garbage
+        https://bugs.webkit.org/show_bug.cgi?id=127077
+
+        Reviewed by Dean Jackson.
+
+        * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
+        (WebCore::GraphicsContext3D::reshapeFBOs): Simplified logic regarding FBO switching.
+        (WebCore::GraphicsContext3D::resolveMultisamplingIfNecessary): Make sure a few things
+        are turned off that might affect blitting data from one FBO to another.
+        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
+        (WebCore::GraphicsContext3D::prepareTexture): Actually turn dithering off!
+        (WebCore::GraphicsContext3D::reshape): Mark the context as dirty when resizing so that
+        the GL view is redrawn during resizing events.
+
</ins><span class="cx"> 2014-01-15  Roger Fong  &lt;roger_fong@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove unnecessary call to webGLContextCreated
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsopenglGraphicsContext3DOpenGLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp (162104 => 162105)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp        2014-01-16 01:06:40 UTC (rev 162104)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp        2014-01-16 01:51:38 UTC (rev 162105)
</span><span class="lines">@@ -101,8 +101,6 @@
</span><span class="cx"> #endif
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool mustRestoreFBO = false;
-
</del><span class="cx">     // Resize multisample FBO.
</span><span class="cx">     if (m_attrs.antialias) {
</span><span class="cx">         GLint maxSampleCount;
</span><span class="lines">@@ -110,10 +108,7 @@
</span><span class="cx">         GLint sampleCount = std::min(8, maxSampleCount);
</span><span class="cx">         if (sampleCount &gt; maxSampleCount)
</span><span class="cx">             sampleCount = maxSampleCount;
</span><del>-        if (m_state.boundFBO != m_multisampleFBO) {
-            ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
-            mustRestoreFBO = true;
-        }
</del><ins>+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
</ins><span class="cx">         ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_multisampleColorBuffer);
</span><span class="cx">         ::glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleCount, m_internalColorFormat, width, height);
</span><span class="cx">         ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, m_multisampleColorBuffer);
</span><span class="lines">@@ -133,11 +128,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // resize regular FBO
</span><del>-    if (m_state.boundFBO != m_fbo) {
-        mustRestoreFBO = true;
-        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
-    }
-
</del><ins>+    ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
</ins><span class="cx">     ASSERT(m_texture);
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     ::glBindRenderbuffer(GL_RENDERBUFFER, m_texture);
</span><span class="lines">@@ -164,15 +155,20 @@
</span><span class="cx">             ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
</span><span class="cx">         ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
</span><span class="cx">     }
</span><ins>+
</ins><span class="cx">     if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) {
</span><span class="cx">         // FIXME: cleanup
</span><span class="cx">         notImplemented();
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    bool mustRestoreFBO = true;
</ins><span class="cx">     if (m_attrs.antialias) {
</span><span class="cx">         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
</span><span class="cx">         if (m_state.boundFBO == m_multisampleFBO)
</span><span class="cx">             mustRestoreFBO = false;
</span><ins>+    } else {
+        if (m_state.boundFBO == m_fbo)
+            mustRestoreFBO = false;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return mustRestoreFBO;
</span><span class="lines">@@ -181,7 +177,9 @@
</span><span class="cx"> void GraphicsContext3D::resolveMultisamplingIfNecessary(const IntRect&amp; rect)
</span><span class="cx"> {
</span><span class="cx">     TemporaryOpenGLSetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
</span><del>-    TemporaryOpenGLSetting scopedDither(GL_SCISSOR_TEST, GL_FALSE);
</del><ins>+    TemporaryOpenGLSetting scopedDither(GL_DITHER, GL_FALSE);
+    TemporaryOpenGLSetting scopedDepth(GL_DEPTH_TEST, GL_FALSE);
+    TemporaryOpenGLSetting scopedStencil(GL_STENCIL_TEST, GL_FALSE);
</ins><span class="cx"> 
</span><span class="cx">     ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
</span><span class="cx">     ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsopenglGraphicsContext3DOpenGLCommoncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp (162104 => 162105)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp        2014-01-16 01:06:40 UTC (rev 162104)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp        2014-01-16 01:51:38 UTC (rev 162105)
</span><span class="lines">@@ -208,7 +208,7 @@
</span><span class="cx">     makeContextCurrent();
</span><span class="cx"> 
</span><span class="cx">     TemporaryOpenGLSetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
</span><del>-    TemporaryOpenGLSetting scopedDither(GL_SCISSOR_TEST, GL_FALSE);
</del><ins>+    TemporaryOpenGLSetting scopedDither(GL_DITHER, GL_FALSE);
</ins><span class="cx">     
</span><span class="cx">     if (m_attrs.antialias)
</span><span class="cx">         resolveMultisamplingIfNecessary();
</span><span class="lines">@@ -269,6 +269,8 @@
</span><span class="cx">     if (width == m_currentWidth &amp;&amp; height == m_currentHeight)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    markContextChanged();
+
</ins><span class="cx"> #if (PLATFORM(EFL) || PLATFORM(NIX)) &amp;&amp; USE(GRAPHICS_SURFACE)
</span><span class="cx">     ::glFlush(); // Make sure all GL calls have been committed before resizing.
</span><span class="cx">     createGraphicsSurfaces(IntSize(width, height));
</span><span class="lines">@@ -280,13 +282,16 @@
</span><span class="cx">     makeContextCurrent();
</span><span class="cx">     validateAttributes();
</span><span class="cx"> 
</span><ins>+    TemporaryOpenGLSetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
+    TemporaryOpenGLSetting scopedDither(GL_DITHER, GL_FALSE);
+    
</ins><span class="cx">     bool mustRestoreFBO = reshapeFBOs(IntSize(width, height));
</span><span class="cx"> 
</span><span class="cx">     // Initialize renderbuffers to 0.
</span><span class="cx">     GLfloat clearColor[] = {0, 0, 0, 0}, clearDepth = 0;
</span><span class="cx">     GLint clearStencil = 0;
</span><span class="cx">     GLboolean colorMask[] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE}, depthMask = GL_TRUE;
</span><del>-    GLuint stencilMask = 0xffffffff;
</del><ins>+    GLuint stencilMask = 0xffffffff, stencilMaskBack = 0xffffffff;
</ins><span class="cx">     GLbitfield clearMask = GL_COLOR_BUFFER_BIT;
</span><span class="cx">     ::glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor);
</span><span class="cx">     ::glClearColor(0, 0, 0, 0);
</span><span class="lines">@@ -303,13 +308,12 @@
</span><span class="cx">         ::glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &amp;clearStencil);
</span><span class="cx">         ::glClearStencil(0);
</span><span class="cx">         ::glGetIntegerv(GL_STENCIL_WRITEMASK, reinterpret_cast&lt;GLint*&gt;(&amp;stencilMask));
</span><ins>+        ::glGetIntegerv(GL_STENCIL_BACK_WRITEMASK, reinterpret_cast&lt;GLint*&gt;(&amp;stencilMaskBack));
</ins><span class="cx">         ::glStencilMaskSeparate(GL_FRONT, 0xffffffff);
</span><ins>+        ::glStencilMaskSeparate(GL_BACK, 0xffffffff);
</ins><span class="cx">         clearMask |= GL_STENCIL_BUFFER_BIT;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    TemporaryOpenGLSetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
-    TemporaryOpenGLSetting scopedDither(GL_SCISSOR_TEST, GL_FALSE);
-
</del><span class="cx">     ::glClear(clearMask);
</span><span class="cx"> 
</span><span class="cx">     ::glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
</span><span class="lines">@@ -321,6 +325,7 @@
</span><span class="cx">     if (m_attrs.stencil) {
</span><span class="cx">         ::glClearStencil(clearStencil);
</span><span class="cx">         ::glStencilMaskSeparate(GL_FRONT, stencilMask);
</span><ins>+        ::glStencilMaskSeparate(GL_BACK, stencilMaskBack);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (mustRestoreFBO)
</span></span></pre>
</div>
</div>

</body>
</html>