<!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>[181573] 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/181573">181573</a></dd>
<dt>Author</dt> <dd>roger_fong@apple.com</dd>
<dt>Date</dt> <dd>2015-03-16 12:30:20 -0700 (Mon, 16 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WebGL2] Multiple Render Targets.
https://bugs.webkit.org/show_bug.cgi?id=126994.
&lt;rdar://problem/15815766&gt;
Reviewed by Dean Jackson.
Tested by a modified version of the 1.0.3 conformance test:
conformance/extensions/webgl-draw-buffers.html
This test will be landed along with other modified extension conformance tests
once approval from Khronos is received.
* html/canvas/WebGL2RenderingContext.cpp:
(WebCore::WebGL2RenderingContext::drawBuffers): Mostly the same as WebGLDrawBuffers::drawBuffersWEBGL.
Returns different error messages, uses non EXT enums.
(WebCore::WebGL2RenderingContext::clearBufferiv): This actually does nothing for now but the validation has been implemented.
(WebCore::WebGL2RenderingContext::clearBufferuiv): Ditto.
(WebCore::WebGL2RenderingContext::clearBufferfv): Ditto.
(WebCore::WebGL2RenderingContext::clearBufferfi): Ditto.
(WebCore::WebGL2RenderingContext::validateFramebufferFuncParameters): Removes the extension object check.
(WebCore::WebGL2RenderingContext::getMaxDrawBuffers):
(WebCore::WebGL2RenderingContext::getMaxColorAttachments): Must return the same thing as getMaxDrawBuffers.
(WebCore::WebGL2RenderingContext::getParameter): Remove extension object checks.
* html/canvas/WebGL2RenderingContext.h:
* html/canvas/WebGLFramebuffer.cpp:
(WebCore::WebGLFramebuffer::drawBuffersIfNecessary):
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::validateFramebufferFuncParameters): Copied from WebGLRenderingContextBase.
(WebCore::WebGLRenderingContext::getMaxDrawBuffers): Ditto.
(WebCore::WebGLRenderingContext::getMaxColorAttachments): Ditto.
* html/canvas/WebGLRenderingContext.h:
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::validateFramebufferFuncParameters): Deleted.
* html/canvas/WebGLRenderingContextBase.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGL2RenderingContextcpp">trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGL2RenderingContexth">trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLFramebuffercpp">trunk/Source/WebCore/html/canvas/WebGLFramebuffer.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLRenderingContextcpp">trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLRenderingContexth">trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLRenderingContextBasecpp">trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLRenderingContextBaseh">trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (181572 => 181573)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-03-16 19:08:40 UTC (rev 181572)
+++ trunk/Source/WebCore/ChangeLog        2015-03-16 19:30:20 UTC (rev 181573)
</span><span class="lines">@@ -1,3 +1,39 @@
</span><ins>+2015-03-16  Roger Fong  &lt;roger_fong@apple.com&gt;
+
+        [WebGL2] Multiple Render Targets.
+        https://bugs.webkit.org/show_bug.cgi?id=126994.
+        &lt;rdar://problem/15815766&gt;
+
+        Reviewed by Dean Jackson.
+
+        Tested by a modified version of the 1.0.3 conformance test:
+        conformance/extensions/webgl-draw-buffers.html
+        This test will be landed along with other modified extension conformance tests
+        once approval from Khronos is received.
+
+        * html/canvas/WebGL2RenderingContext.cpp:
+        (WebCore::WebGL2RenderingContext::drawBuffers): Mostly the same as WebGLDrawBuffers::drawBuffersWEBGL.
+        Returns different error messages, uses non EXT enums.
+        (WebCore::WebGL2RenderingContext::clearBufferiv): This actually does nothing for now but the validation has been implemented.
+        (WebCore::WebGL2RenderingContext::clearBufferuiv): Ditto.
+        (WebCore::WebGL2RenderingContext::clearBufferfv): Ditto.
+        (WebCore::WebGL2RenderingContext::clearBufferfi): Ditto.
+        (WebCore::WebGL2RenderingContext::validateFramebufferFuncParameters): Removes the extension object check.
+        (WebCore::WebGL2RenderingContext::getMaxDrawBuffers):
+        (WebCore::WebGL2RenderingContext::getMaxColorAttachments): Must return the same thing as getMaxDrawBuffers.
+        (WebCore::WebGL2RenderingContext::getParameter): Remove extension object checks.
+        * html/canvas/WebGL2RenderingContext.h:
+        * html/canvas/WebGLFramebuffer.cpp:
+        (WebCore::WebGLFramebuffer::drawBuffersIfNecessary):
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::validateFramebufferFuncParameters): Copied from WebGLRenderingContextBase.
+        (WebCore::WebGLRenderingContext::getMaxDrawBuffers): Ditto.
+        (WebCore::WebGLRenderingContext::getMaxColorAttachments): Ditto.
+        * html/canvas/WebGLRenderingContext.h:
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::validateFramebufferFuncParameters): Deleted.
+        * html/canvas/WebGLRenderingContextBase.h:
+
</ins><span class="cx"> 2015-03-16  Dean Jackson  &lt;dino@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Parsing and Style Resolution of Container-based Animation Triggers
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGL2RenderingContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp (181572 => 181573)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp        2015-03-16 19:08:40 UTC (rev 181572)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp        2015-03-16 19:30:20 UTC (rev 181573)
</span><span class="lines">@@ -485,36 +485,129 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGL2RenderingContext::drawBuffers(Vector&lt;GC3Denum&gt; buffers)
</span><span class="cx"> {
</span><del>-    UNUSED_PARAM(buffers);
</del><ins>+    if (isContextLost())
+        return;
+    GC3Dsizei n = buffers.size();
+    const GC3Denum* bufs = buffers.data();
+    if (!m_framebufferBinding) {
+        if (n != 1) {
+            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, &quot;drawBuffers&quot;, &quot;more than one buffer&quot;);
+            return;
+        }
+        if (bufs[0] != GraphicsContext3D::BACK &amp;&amp; bufs[0] != GraphicsContext3D::NONE) {
+            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, &quot;drawBuffers&quot;, &quot;BACK or NONE&quot;);
+            return;
+        }
+        // Because the backbuffer is simulated on all current WebKit ports, we need to change BACK to COLOR_ATTACHMENT0.
+        GC3Denum value = (bufs[0] == GraphicsContext3D::BACK) ? GraphicsContext3D::COLOR_ATTACHMENT0 : GraphicsContext3D::NONE;
+        graphicsContext3D()-&gt;getExtensions()-&gt;drawBuffersEXT(1, &amp;value);
+        setBackDrawBuffer(bufs[0]);
+    } else {
+        if (n &gt; getMaxDrawBuffers()) {
+            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, &quot;drawBuffers&quot;, &quot;more than max draw buffers&quot;);
+            return;
+        }
+        for (GC3Dsizei i = 0; i &lt; n; ++i) {
+            if (bufs[i] != GraphicsContext3D::NONE &amp;&amp; bufs[i] != static_cast&lt;GC3Denum&gt;(GraphicsContext3D::COLOR_ATTACHMENT0 + i)) {
+                synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, &quot;drawBuffers&quot;, &quot;COLOR_ATTACHMENTi or NONE&quot;);
+                return;
+            }
+        }
+        m_framebufferBinding-&gt;drawBuffers(buffers);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGL2RenderingContext::clearBufferiv(GC3Denum buffer, GC3Dint drawbuffer, Int32Array* value)
</span><span class="cx"> {
</span><del>-    UNUSED_PARAM(buffer);
-    UNUSED_PARAM(drawbuffer);
</del><span class="cx">     UNUSED_PARAM(value);
</span><ins>+    switch (buffer) {
+    case GraphicsContext3D::COLOR:
+        if (drawbuffer &lt; 0 || drawbuffer &gt;= getMaxDrawBuffers()) {
+            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, &quot;clearBufferiv&quot;, &quot;buffer index out of range&quot;);
+            return;
+        }
+        // TODO: Call clearBufferiv, requires gl3.h and ES3/gl.h
+        break;
+    case GraphicsContext3D::STENCIL:
+        if (drawbuffer) {
+            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, &quot;clearBufferiv&quot;, &quot;buffer index must be 0&quot;);
+            return;
+        }
+        // TODO: Call clearBufferiv, requires gl3.h and ES3/gl.h
+        break;
+    case GraphicsContext3D::DEPTH:
+    case GraphicsContext3D::DEPTH_STENCIL:
+    default:
+        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, &quot;clearBufferiv&quot;, &quot;buffer argument must be COLOR or STENCIL&quot;);
+        break;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGL2RenderingContext::clearBufferuiv(GC3Denum buffer, GC3Dint drawbuffer, Uint32Array* value)
</span><span class="cx"> {
</span><del>-    UNUSED_PARAM(buffer);
-    UNUSED_PARAM(drawbuffer);
</del><span class="cx">     UNUSED_PARAM(value);
</span><ins>+    switch (buffer) {
+    case GraphicsContext3D::COLOR:
+        if (drawbuffer &lt; 0 || drawbuffer &gt;= getMaxDrawBuffers()) {
+            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, &quot;clearBufferuiv&quot;, &quot;buffer index out of range&quot;);
+            return;
+        }
+        // TODO: Call clearBufferuiv, requires gl3.h and ES3/gl.h
+        break;
+    case GraphicsContext3D::DEPTH:
+    case GraphicsContext3D::STENCIL:
+    case GraphicsContext3D::DEPTH_STENCIL:
+    default:
+        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, &quot;clearBufferuiv&quot;, &quot;buffer argument must be COLOR&quot;);
+        break;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGL2RenderingContext::clearBufferfv(GC3Denum buffer, GC3Dint drawbuffer, Float32Array* value)
</span><span class="cx"> {
</span><del>-    UNUSED_PARAM(buffer);
-    UNUSED_PARAM(drawbuffer);
</del><span class="cx">     UNUSED_PARAM(value);
</span><ins>+    switch (buffer) {
+    case GraphicsContext3D::COLOR:
+        if (drawbuffer &lt; 0 || drawbuffer &gt;= getMaxDrawBuffers()) {
+            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, &quot;clearBufferfv&quot;, &quot;buffer index out of range&quot;);
+            return;
+        }
+        // TODO: Call clearBufferfv, requires gl3.h and ES3/gl.h
+        break;
+    case GraphicsContext3D::DEPTH:
+        if (drawbuffer) {
+            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, &quot;clearBufferfv&quot;, &quot;buffer index must be 0&quot;);
+            return;
+        }
+        // TODO: Call clearBufferfv, requires gl3.h and ES3/gl.h
+        break;
+    case GraphicsContext3D::STENCIL:
+    case GraphicsContext3D::DEPTH_STENCIL:
+    default:
+        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, &quot;clearBufferfv&quot;, &quot;buffer argument must be COLOR OR DEPTH&quot;);
+        break;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGL2RenderingContext::clearBufferfi(GC3Denum buffer, GC3Dint drawbuffer, GC3Dfloat depth, GC3Dint stencil)
</span><span class="cx"> {
</span><del>-    UNUSED_PARAM(buffer);
-    UNUSED_PARAM(drawbuffer);
</del><span class="cx">     UNUSED_PARAM(depth);
</span><span class="cx">     UNUSED_PARAM(stencil);
</span><ins>+    switch (buffer) {
+    case GraphicsContext3D::DEPTH_STENCIL:
+        if (drawbuffer) {
+            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, &quot;clearBufferfv&quot;, &quot;buffer index must be 0&quot;);
+            return;
+        }
+        // TODO: Call clearBufferfi, requires gl3.h and ES3/gl.h
+        break;
+    case GraphicsContext3D::COLOR:
+    case GraphicsContext3D::DEPTH:
+    case GraphicsContext3D::STENCIL:
+    default:
+        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, &quot;clearBufferfv&quot;, &quot;buffer argument must be DEPTH_STENCIL&quot;);
+        break;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;WebGLQuery&gt; WebGL2RenderingContext::createQuery()
</span><span class="lines">@@ -1021,6 +1114,43 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool WebGL2RenderingContext::validateFramebufferFuncParameters(const char* functionName, GC3Denum target, GC3Denum attachment)
+{
+    if (target != GraphicsContext3D::FRAMEBUFFER) {
+        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, &quot;invalid target&quot;);
+        return false;
+    }
+    switch (attachment) {
+    case GraphicsContext3D::COLOR_ATTACHMENT0:
+    case GraphicsContext3D::DEPTH_ATTACHMENT:
+    case GraphicsContext3D::STENCIL_ATTACHMENT:
+    case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
+        break;
+    default:
+        if (attachment &gt; GraphicsContext3D::COLOR_ATTACHMENT0
+            &amp;&amp; attachment &lt; static_cast&lt;GC3Denum&gt;(GraphicsContext3D::COLOR_ATTACHMENT0 + getMaxColorAttachments()))
+            break;
+        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, &quot;invalid attachment&quot;);
+        return false;
+    }
+    return true;
+}
+
+GC3Dint WebGL2RenderingContext::getMaxDrawBuffers()
+{
+    if (!m_maxDrawBuffers)
+        m_context-&gt;getIntegerv(GraphicsContext3D::MAX_DRAW_BUFFERS, &amp;m_maxDrawBuffers);
+    return m_maxDrawBuffers;
+}
+
+GC3Dint WebGL2RenderingContext::getMaxColorAttachments()
+{
+    // DrawBuffers requires MAX_COLOR_ATTACHMENTS == MAX_DRAW_BUFFERS
+    if (!m_maxColorAttachments)
+        m_context-&gt;getIntegerv(GraphicsContext3D::MAX_DRAW_BUFFERS, &amp;m_maxColorAttachments);
+    return m_maxColorAttachments;
+}
+
</ins><span class="cx"> void WebGL2RenderingContext::renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height)
</span><span class="cx"> {
</span><span class="cx">     if (isContextLostOrPending())
</span><span class="lines">@@ -2203,8 +2333,6 @@
</span><span class="cx">         return WebGLGetInfo();
</span><span class="cx">         }
</span><span class="cx">         break;
</span><del>-    case GraphicsContext3D::COPY_READ_BUFFER:
-    case GraphicsContext3D::COPY_WRITE_BUFFER:
</del><span class="cx">     case GraphicsContext3D::DRAW_BUFFER0:
</span><span class="cx">     case GraphicsContext3D::DRAW_BUFFER1:
</span><span class="cx">     case GraphicsContext3D::DRAW_BUFFER2:
</span><span class="lines">@@ -2220,7 +2348,16 @@
</span><span class="cx">     case GraphicsContext3D::DRAW_BUFFER12:
</span><span class="cx">     case GraphicsContext3D::DRAW_BUFFER13:
</span><span class="cx">     case GraphicsContext3D::DRAW_BUFFER14:
</span><del>-    case GraphicsContext3D::DRAW_BUFFER15:
</del><ins>+    case GraphicsContext3D::DRAW_BUFFER15: {
+        GC3Dint value = GraphicsContext3D::NONE;
+        if (m_framebufferBinding)
+            value = m_framebufferBinding-&gt;getDrawBuffer(pname);
+        else // emulated backbuffer
+            value = m_backDrawBuffer;
+        return WebGLGetInfo(value);
+        }
+    case GraphicsContext3D::COPY_READ_BUFFER:
+    case GraphicsContext3D::COPY_WRITE_BUFFER:
</ins><span class="cx">     case GraphicsContext3D::PIXEL_PACK_BUFFER_BINDING:   
</span><span class="cx">     case GraphicsContext3D::PIXEL_UNPACK_BUFFER_BINDING:
</span><span class="cx">     case GraphicsContext3D::READ_BUFFER:
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGL2RenderingContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h (181572 => 181573)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h        2015-03-16 19:08:40 UTC (rev 181572)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h        2015-03-16 19:30:20 UTC (rev 181573)
</span><span class="lines">@@ -190,6 +190,8 @@
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     virtual void initializeVertexArrayObjects() override;
</span><ins>+    virtual GC3Dint getMaxDrawBuffers() override;
+    virtual GC3Dint getMaxColorAttachments() override;
</ins><span class="cx">     virtual bool validateIndexArrayConservative(GC3Denum type, unsigned&amp; numElementsRequired) override;
</span><span class="cx">     virtual bool validateDrawElements(const char* functionName, GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, unsigned&amp; numElements, GC3Dsizei primitiveCount) override;
</span><span class="cx">     virtual bool validateBlendEquation(const char* functionName, GC3Denum mode) override;
</span><span class="lines">@@ -206,6 +208,7 @@
</span><span class="cx">         ArrayBufferView* pixels,
</span><span class="cx">         NullDisposition) override;
</span><span class="cx">     virtual bool validateCapability(const char* functionName, GC3Denum cap) override;
</span><ins>+    virtual bool validateFramebufferFuncParameters(const char* functionName, GC3Denum target, GC3Denum attachment) override;
</ins><span class="cx">     
</span><span class="cx"> private:
</span><span class="cx">     GC3Denum baseInternalFormatFromInternalFormat(GC3Denum internalformat);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLFramebuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLFramebuffer.cpp (181572 => 181573)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLFramebuffer.cpp        2015-03-16 19:08:40 UTC (rev 181572)
+++ trunk/Source/WebCore/html/canvas/WebGLFramebuffer.cpp        2015-03-16 19:30:20 UTC (rev 181573)
</span><span class="lines">@@ -607,7 +607,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLFramebuffer::drawBuffersIfNecessary(bool force)
</span><span class="cx"> {
</span><del>-    if (!context()-&gt;m_webglDrawBuffers)
</del><ins>+    if (!context()-&gt;m_webglDrawBuffers &amp;&amp; !context()-&gt;isWebGL2())
</ins><span class="cx">         return;
</span><span class="cx">     bool reset = force;
</span><span class="cx">     // This filtering works around graphics driver bugs on Mac OS X.
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLRenderingContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (181572 => 181573)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp        2015-03-16 19:08:40 UTC (rev 181572)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp        2015-03-16 19:30:20 UTC (rev 181573)
</span><span class="lines">@@ -361,6 +361,29 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool WebGLRenderingContext::validateFramebufferFuncParameters(const char* functionName, GC3Denum target, GC3Denum attachment)
+{
+    if (target != GraphicsContext3D::FRAMEBUFFER) {
+        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, &quot;invalid target&quot;);
+        return false;
+    }
+    switch (attachment) {
+    case GraphicsContext3D::COLOR_ATTACHMENT0:
+    case GraphicsContext3D::DEPTH_ATTACHMENT:
+    case GraphicsContext3D::STENCIL_ATTACHMENT:
+    case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
+        break;
+    default:
+        if (m_webglDrawBuffers
+            &amp;&amp; attachment &gt; GraphicsContext3D::COLOR_ATTACHMENT0
+            &amp;&amp; attachment &lt; static_cast&lt;GC3Denum&gt;(GraphicsContext3D::COLOR_ATTACHMENT0 + getMaxColorAttachments()))
+            break;
+        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, &quot;invalid attachment&quot;);
+        return false;
+    }
+    return true;
+}
+    
</ins><span class="cx"> void WebGLRenderingContext::renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height)
</span><span class="cx"> {
</span><span class="cx">     if (isContextLostOrPending())
</span><span class="lines">@@ -1113,6 +1136,27 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+GC3Dint WebGLRenderingContext::getMaxDrawBuffers()
+{
+    if (!supportsDrawBuffers())
+        return 0;
+    if (!m_maxDrawBuffers)
+        m_context-&gt;getIntegerv(Extensions3D::MAX_DRAW_BUFFERS_EXT, &amp;m_maxDrawBuffers);
+    if (!m_maxColorAttachments)
+        m_context-&gt;getIntegerv(Extensions3D::MAX_COLOR_ATTACHMENTS_EXT, &amp;m_maxColorAttachments);
+    // WEBGL_draw_buffers requires MAX_COLOR_ATTACHMENTS &gt;= MAX_DRAW_BUFFERS.
+    return std::min(m_maxDrawBuffers, m_maxColorAttachments);
+}
+
+GC3Dint WebGLRenderingContext::getMaxColorAttachments()
+{
+    if (!supportsDrawBuffers())
+        return 0;
+    if (!m_maxColorAttachments)
+        m_context-&gt;getIntegerv(Extensions3D::MAX_COLOR_ATTACHMENTS_EXT, &amp;m_maxColorAttachments);
+    return m_maxColorAttachments;
+}
+    
</ins><span class="cx"> bool WebGLRenderingContext::validateIndexArrayConservative(GC3Denum type, unsigned&amp; numElementsRequired)
</span><span class="cx"> {
</span><span class="cx">     // Performs conservative validation by caching a maximum index of
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLRenderingContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h (181572 => 181573)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h        2015-03-16 19:08:40 UTC (rev 181572)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h        2015-03-16 19:30:20 UTC (rev 181573)
</span><span class="lines">@@ -42,6 +42,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual WebGLGetInfo getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname, ExceptionCode&amp;) override;
</span><span class="cx">     virtual void renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) override;
</span><ins>+    virtual bool validateFramebufferFuncParameters(const char* functionName, GC3Denum target, GC3Denum attachment) override;
</ins><span class="cx">     virtual void hint(GC3Denum target, GC3Denum mode) override;
</span><span class="cx">     virtual void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border) override;
</span><span class="cx">     virtual void texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum internalformat, GC3Denum format, GC3Denum type, const void* pixels, ExceptionCode&amp;) override;
</span><span class="lines">@@ -61,6 +62,8 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><ins>+    virtual GC3Dint getMaxDrawBuffers() override;
+    virtual GC3Dint getMaxColorAttachments() override;
</ins><span class="cx">     virtual void initializeVertexArrayObjects() override;
</span><span class="cx">     virtual bool validateIndexArrayConservative(GC3Denum type, unsigned&amp; numElementsRequired) override;
</span><span class="cx">     virtual bool validateDrawElements(const char* functionName, GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, unsigned&amp; numElements, GC3Dsizei primitiveCount) override;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLRenderingContextBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (181572 => 181573)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp        2015-03-16 19:08:40 UTC (rev 181572)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp        2015-03-16 19:30:20 UTC (rev 181573)
</span><span class="lines">@@ -4346,29 +4346,6 @@
</span><span class="cx">     canvas()-&gt;document().addConsoleMessage(MessageSource::Rendering, MessageLevel::Warning, message);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool WebGLRenderingContextBase::validateFramebufferFuncParameters(const char* functionName, GC3Denum target, GC3Denum attachment)
-{
-    if (target != GraphicsContext3D::FRAMEBUFFER) {
-        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, &quot;invalid target&quot;);
-        return false;
-    }
-    switch (attachment) {
-    case GraphicsContext3D::COLOR_ATTACHMENT0:
-    case GraphicsContext3D::DEPTH_ATTACHMENT:
-    case GraphicsContext3D::STENCIL_ATTACHMENT:
-    case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
-        break;
-    default:
-        if (m_webglDrawBuffers
-            &amp;&amp; attachment &gt; GraphicsContext3D::COLOR_ATTACHMENT0
-            &amp;&amp; attachment &lt; static_cast&lt;GC3Denum&gt;(GraphicsContext3D::COLOR_ATTACHMENT0 + getMaxColorAttachments()))
-            break;
-        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, &quot;invalid attachment&quot;);
-        return false;
-    }
-    return true;
-}
-
</del><span class="cx"> bool WebGLRenderingContextBase::validateBlendFuncFactors(const char* functionName, GC3Denum src, GC3Denum dst)
</span><span class="cx"> {
</span><span class="cx">     if (((src == GraphicsContext3D::CONSTANT_COLOR || src == GraphicsContext3D::ONE_MINUS_CONSTANT_COLOR)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLRenderingContextBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h (181572 => 181573)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h        2015-03-16 19:08:40 UTC (rev 181572)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h        2015-03-16 19:30:20 UTC (rev 181573)
</span><span class="lines">@@ -566,7 +566,7 @@
</span><span class="cx">     bool m_hasRequestedPolicyResolution;
</span><span class="cx">     bool isContextLostOrPending();
</span><span class="cx"> 
</span><del>-    // Enabled extension objects.
</del><ins>+    // Enabled extension objects. FIXME: Move these to WebGL1RenderingContext, not needed for WebGL2
</ins><span class="cx">     std::unique_ptr&lt;EXTFragDepth&gt; m_extFragDepth;
</span><span class="cx">     std::unique_ptr&lt;EXTBlendMinMax&gt; m_extBlendMinMax;
</span><span class="cx">     std::unique_ptr&lt;EXTsRGB&gt; m_extsRGB;
</span><span class="lines">@@ -743,7 +743,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Helper function to validate input parameters for framebuffer functions.
</span><span class="cx">     // Generate GL error if parameters are illegal.
</span><del>-    bool validateFramebufferFuncParameters(const char* functionName, GC3Denum target, GC3Denum attachment);
</del><ins>+    virtual bool validateFramebufferFuncParameters(const char* functionName, GC3Denum target, GC3Denum attachment) = 0;
</ins><span class="cx"> 
</span><span class="cx">     // Helper function to validate blend equation mode.
</span><span class="cx">     virtual bool validateBlendEquation(const char* functionName, GC3Denum) = 0;
</span><span class="lines">@@ -824,10 +824,8 @@
</span><span class="cx">     // Clamp the width and height to GL_MAX_VIEWPORT_DIMS.
</span><span class="cx">     IntSize clampedCanvasSize();
</span><span class="cx"> 
</span><del>-    // First time called, if EXT_draw_buffers is supported, query the value; otherwise return 0.
-    // Later, return the cached value.
-    GC3Dint getMaxDrawBuffers();
-    GC3Dint getMaxColorAttachments();
</del><ins>+    virtual GC3Dint getMaxDrawBuffers() = 0;
+    virtual GC3Dint getMaxColorAttachments() = 0;
</ins><span class="cx"> 
</span><span class="cx">     void setBackDrawBuffer(GC3Denum);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>