<!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>[208032] trunk</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/208032">208032</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2016-10-27 22:28:55 -0700 (Thu, 27 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Teach WebGL code about new buffer targets in WebGL2
https://bugs.webkit.org/show_bug.cgi?id=163924

Reviewed by Dean Jackson.

Source/WebCore:

WebGL 2 adds new buffer targets. Instead of completely reimplementing
the functions again for WebGL 2, we can simply check if we are using
a new kind of context to conditionally enable support.

Test: fast/canvas/webgl/webgl2-buffer-targets.html

* html/canvas/WebGL2RenderingContext.h:
* html/canvas/WebGL2RenderingContext.idl:
* html/canvas/WebGLBuffer.cpp:
(WebCore::WebGLBuffer::associateBufferDataImpl):
(WebCore::WebGLBuffer::associateBufferSubDataImpl):
(WebCore::WebGLBuffer::setTarget):
* html/canvas/WebGLBuffer.h:
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::bindBuffer):
(WebCore::WebGLRenderingContextBase::getBufferParameter):
(WebCore::WebGLRenderingContextBase::validateBufferDataParameters):
* html/canvas/WebGLRenderingContextBase.h:

LayoutTests:

* fast/canvas/webgl/bufferData-offset-length.html:
* fast/canvas/webgl/webgl2-buffer-targets-expected.txt: Added.
* fast/canvas/webgl/webgl2-buffer-targets.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastcanvaswebglbufferDataoffsetlengthhtml">trunk/LayoutTests/fast/canvas/webgl/bufferData-offset-length.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGL2RenderingContexth">trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGL2RenderingContextidl">trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.idl</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLBuffercpp">trunk/Source/WebCore/html/canvas/WebGLBuffer.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLBufferh">trunk/Source/WebCore/html/canvas/WebGLBuffer.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>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcanvaswebglwebgl2buffertargetsexpectedtxt">trunk/LayoutTests/fast/canvas/webgl/webgl2-buffer-targets-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcanvaswebglwebgl2buffertargetshtml">trunk/LayoutTests/fast/canvas/webgl/webgl2-buffer-targets.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (208031 => 208032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-10-28 04:30:22 UTC (rev 208031)
+++ trunk/LayoutTests/ChangeLog        2016-10-28 05:28:55 UTC (rev 208032)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-10-27  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        Teach WebGL code about new buffer targets in WebGL2
+        https://bugs.webkit.org/show_bug.cgi?id=163924
+
+        Reviewed by Dean Jackson.
+
+        * fast/canvas/webgl/bufferData-offset-length.html:
+        * fast/canvas/webgl/webgl2-buffer-targets-expected.txt: Added.
+        * fast/canvas/webgl/webgl2-buffer-targets.html: Added.
+
</ins><span class="cx"> 2016-10-27  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         If an animation's keyframes affect stacking context properties, create stacking context while the animation is running
</span></span></pre></div>
<a id="trunkLayoutTestsfastcanvaswebglbufferDataoffsetlengthhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/canvas/webgl/bufferData-offset-length.html (208031 => 208032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/canvas/webgl/bufferData-offset-length.html        2016-10-28 04:30:22 UTC (rev 208031)
+++ trunk/LayoutTests/fast/canvas/webgl/bufferData-offset-length.html        2016-10-28 05:28:55 UTC (rev 208032)
</span><span class="lines">@@ -39,7 +39,7 @@
</span><span class="cx">     debug(&quot;&quot;);
</span><span class="cx"> 
</span><span class="cx">     if (window.internals)
</span><del>-                    internals.setWebGL2Enabled(true);
</del><ins>+            internals.setWebGL2Enabled(true);
</ins><span class="cx">     gl = initWebGL(&quot;example&quot;, &quot;vshader&quot;, &quot;fshader&quot;, [ &quot;vPosition&quot;, &quot;index&quot; ],
</span><span class="cx">                    [ 1, 1, 1, 1 ], 1, null, true);
</span><span class="cx"> 
</span><span class="lines">@@ -80,6 +80,8 @@
</span><span class="cx">     checkRedValue(10, 10, 0, &quot;Left half of canvas should be filled&quot;);
</span><span class="cx">     checkRedValue(30, 10, 255, &quot;Right half of canvas should be empty&quot;);
</span><span class="cx"> 
</span><ins>+    gl.deleteBuffer(vertexObject);
+
</ins><span class="cx">     function checkRedValue(x, y, value, msg) {
</span><span class="cx">         gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
</span><span class="cx">         gl.drawArrays(gl.TRIANGLES, 0, 6);
</span></span></pre></div>
<a id="trunkLayoutTestsfastcanvaswebglwebgl2buffertargetsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/webgl/webgl2-buffer-targets-expected.txt (0 => 208032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/canvas/webgl/webgl2-buffer-targets-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/webgl2-buffer-targets-expected.txt        2016-10-28 05:28:55 UTC (rev 208032)
</span><span class="lines">@@ -0,0 +1,88 @@
</span><ins>+CONSOLE MESSAGE: line 55: WebGL: INVALID_ENUM: bindBuffer: invalid target
+CONSOLE MESSAGE: line 57: WebGL: INVALID_ENUM: bufferData: invalid target
+CONSOLE MESSAGE: line 55: WebGL: INVALID_ENUM: bindBuffer: invalid target
+CONSOLE MESSAGE: line 57: WebGL: INVALID_ENUM: bufferData: invalid target
+CONSOLE MESSAGE: line 55: WebGL: INVALID_ENUM: bindBuffer: invalid target
+CONSOLE MESSAGE: line 57: WebGL: INVALID_ENUM: bufferData: invalid target
+CONSOLE MESSAGE: line 55: WebGL: INVALID_ENUM: bindBuffer: invalid target
+CONSOLE MESSAGE: line 57: WebGL: INVALID_ENUM: bufferData: invalid target
+CONSOLE MESSAGE: line 55: WebGL: INVALID_ENUM: bindBuffer: invalid target
+CONSOLE MESSAGE: line 57: WebGL: INVALID_ENUM: bufferData: invalid target
+CONSOLE MESSAGE: line 55: WebGL: INVALID_ENUM: bindBuffer: invalid target
+CONSOLE MESSAGE: line 57: WebGL: INVALID_ENUM: bufferData: invalid target
+Checks that using WebGL 2 buffer targets don't cause errors
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.INVALID_ENUM
+PASS context.getError() is context.INVALID_ENUM
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.INVALID_ENUM
+PASS context.getError() is context.INVALID_ENUM
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.INVALID_ENUM
+PASS context.getError() is context.INVALID_ENUM
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.INVALID_ENUM
+PASS context.getError() is context.INVALID_ENUM
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.INVALID_ENUM
+PASS context.getError() is context.INVALID_ENUM
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.NO_ERROR
+PASS context.getError() is context.INVALID_ENUM
+PASS context.getError() is context.INVALID_ENUM
+PASS context.getError() is context.NO_ERROR
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcanvaswebglwebgl2buffertargetshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/webgl/webgl2-buffer-targets.html (0 => 208032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/canvas/webgl/webgl2-buffer-targets.html                                (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/webgl2-buffer-targets.html        2016-10-28 05:28:55 UTC (rev 208032)
</span><span class="lines">@@ -0,0 +1,65 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;canvas id=&quot;c&quot; width=&quot;40&quot; height=&quot;40&quot;&gt;&lt;/canvas&gt;
+&lt;script&gt;
+description(&quot;Checks that using WebGL 2 buffer targets don't cause errors&quot;);
+
+if (window.internals)
+        internals.setWebGL2Enabled(true);
+
+var canvas = document.getElementById(&quot;c&quot;);
+var context = canvas.getContext(&quot;webgl2&quot;);
+shouldBe(&quot;context.getError()&quot;, &quot;context.NO_ERROR&quot;);
+checkBufferSuccess(context, context.ARRAY_BUFFER);
+checkBufferSuccess(context, context.COPY_READ_BUFFER);
+checkBufferSuccess(context, context.COPY_WRITE_BUFFER);
+checkBufferSuccess(context, context.ELEMENT_ARRAY_BUFFER);
+checkBufferSuccess(context, context.PIXEL_PACK_BUFFER);
+checkBufferSuccess(context, context.PIXEL_UNPACK_BUFFER);
+checkBufferSuccess(context, context.TRANSFORM_FEEDBACK_BUFFER);
+checkBufferSuccess(context, context.UNIFORM_BUFFER);
+
+canvas = document.createElement(&quot;canvas&quot;);
+canvas.width = 40;
+canvas.height = 40;
+context = canvas.getContext(&quot;webgl&quot;);
+shouldBe(&quot;context.getError()&quot;, &quot;context.NO_ERROR&quot;);
+shouldBe(&quot;context.getError()&quot;, &quot;context.NO_ERROR&quot;);
+checkBufferSuccess(context, context.ARRAY_BUFFER);
+checkBufferFailure(context, context.COPY_READ_BUFFER);
+checkBufferFailure(context, context.COPY_WRITE_BUFFER);
+checkBufferSuccess(context, context.ELEMENT_ARRAY_BUFFER);
+checkBufferFailure(context, context.PIXEL_PACK_BUFFER);
+checkBufferFailure(context, context.PIXEL_UNPACK_BUFFER);
+checkBufferFailure(context, context.TRANSFORM_FEEDBACK_BUFFER);
+checkBufferFailure(context, context.UNIFORM_BUFFER);
+
+function checkBufferSuccess(context, target) {
+        var buffer = context.createBuffer();
+        shouldBe(&quot;context.getError()&quot;, &quot;context.NO_ERROR&quot;);
+        context.bindBuffer(target, buffer);
+        shouldBe(&quot;context.getError()&quot;, &quot;context.NO_ERROR&quot;);
+        context.bufferData(target, new Int32Array(16), context.STATIC_DRAW);
+        shouldBe(&quot;context.getError()&quot;, &quot;context.NO_ERROR&quot;);
+        context.deleteBuffer(buffer);
+        shouldBe(&quot;context.getError()&quot;, &quot;context.NO_ERROR&quot;);
+}
+
+function checkBufferFailure(context, target) {
+        var buffer = context.createBuffer();
+        shouldBe(&quot;context.getError()&quot;, &quot;context.NO_ERROR&quot;);
+        context.bindBuffer(target, buffer);
+        shouldBe(&quot;context.getError()&quot;, &quot;context.INVALID_ENUM&quot;);
+        context.bufferData(target, new Int32Array(16), context.STATIC_DRAW);
+        shouldBe(&quot;context.getError()&quot;, &quot;context.INVALID_ENUM&quot;);
+        context.deleteBuffer(buffer);
+        shouldBe(&quot;context.getError()&quot;, &quot;context.NO_ERROR&quot;);
+}
+&lt;/script&gt;
+&lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208031 => 208032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-28 04:30:22 UTC (rev 208031)
+++ trunk/Source/WebCore/ChangeLog        2016-10-28 05:28:55 UTC (rev 208032)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2016-10-27  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        Teach WebGL code about new buffer targets in WebGL2
+        https://bugs.webkit.org/show_bug.cgi?id=163924
+
+        Reviewed by Dean Jackson.
+
+        WebGL 2 adds new buffer targets. Instead of completely reimplementing
+        the functions again for WebGL 2, we can simply check if we are using
+        a new kind of context to conditionally enable support.
+
+        Test: fast/canvas/webgl/webgl2-buffer-targets.html
+
+        * html/canvas/WebGL2RenderingContext.h:
+        * html/canvas/WebGL2RenderingContext.idl:
+        * html/canvas/WebGLBuffer.cpp:
+        (WebCore::WebGLBuffer::associateBufferDataImpl):
+        (WebCore::WebGLBuffer::associateBufferSubDataImpl):
+        (WebCore::WebGLBuffer::setTarget):
+        * html/canvas/WebGLBuffer.h:
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::bindBuffer):
+        (WebCore::WebGLRenderingContextBase::getBufferParameter):
+        (WebCore::WebGLRenderingContextBase::validateBufferDataParameters):
+        * html/canvas/WebGLRenderingContextBase.h:
+
</ins><span class="cx"> 2016-10-27  Dave Hyatt  &lt;hyatt@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CSS Parser] Enhance grid-auto-flow parsing to allow dense first.
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGL2RenderingContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h (208031 => 208032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h        2016-10-28 04:30:22 UTC (rev 208031)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h        2016-10-28 05:28:55 UTC (rev 208032)
</span><span class="lines">@@ -44,6 +44,8 @@
</span><span class="cx">     WebGL2RenderingContext(HTMLCanvasElement*, RefPtr&lt;GraphicsContext3D&gt;&amp;&amp;, GraphicsContext3D::Attributes);
</span><span class="cx"> 
</span><span class="cx">     /* Buffer objects */
</span><ins>+    using WebGLRenderingContextBase::bufferData;
+    using WebGLRenderingContextBase::bufferSubData;
</ins><span class="cx">     void bufferData(GC3Denum target, ArrayBufferView&amp; data, GC3Denum usage, GC3Duint srcOffset, GC3Duint length);
</span><span class="cx">     void bufferSubData(GC3Denum target, long long offset, ArrayBufferView&amp; data, GC3Duint srcOffset, GC3Duint length);
</span><span class="cx">     void copyBufferSubData(GC3Denum readTarget, GC3Denum writeTarget, GC3Dint64 readOffset, GC3Dint64 writeOffset, GC3Dint64 size);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGL2RenderingContextidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.idl (208031 => 208032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.idl        2016-10-28 04:30:22 UTC (rev 208031)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.idl        2016-10-28 05:28:55 UTC (rev 208032)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> typedef unsigned long long GLuint64;
</span><span class="cx"> typedef unrestricted float GLfloat;
</span><span class="cx"> typedef unrestricted float GLclampf;
</span><ins>+typedef (ArrayBuffer or ArrayBufferView) BufferDataSource;
</ins><span class="cx"> 
</span><span class="cx"> // FIXME: Should allow ImageBitmap too.
</span><span class="cx"> typedef (ImageData or HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) TexImageSource;
</span><span class="lines">@@ -336,8 +337,14 @@
</span><span class="cx">     const GLuint64 TIMEOUT_IGNORED                             = 0xFFFFFFFFFFFFFFFF;
</span><span class="cx"> 
</span><span class="cx">     /* Buffer objects */
</span><ins>+    // WebGL1:
+    void bufferData(GLenum target, GLsizeiptr size, GLenum usage);
+    void bufferData(GLenum target, BufferDataSource? srcData, GLenum usage);
+    void bufferSubData(GLenum target, GLintptr dstByteOffset, BufferDataSource? srcData);
+    // WebGL2:
</ins><span class="cx">     void bufferData(GLenum target, ArrayBufferView data, GLenum usage, GLuint srcOffset, optional GLuint length = 0);
</span><span class="cx">     void bufferSubData(GLenum target, GLintptr dstByteOffset, ArrayBufferView srcData, GLuint srcOffset, optional GLuint length = 0);
</span><ins>+
</ins><span class="cx">     void copyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
</span><span class="cx">     // MapBufferRange, in particular its read-only and write-only modes,
</span><span class="cx">     // can not be exposed safely to JavaScript. GetBufferSubData
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLBuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLBuffer.cpp (208031 => 208032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLBuffer.cpp        2016-10-28 04:30:22 UTC (rev 208031)
+++ trunk/Source/WebCore/html/canvas/WebGLBuffer.cpp        2016-10-28 05:28:55 UTC (rev 208032)
</span><span class="lines">@@ -87,6 +87,18 @@
</span><span class="cx">         m_byteLength = byteLength;
</span><span class="cx">         return true;
</span><span class="cx">     default:
</span><ins>+#if ENABLE(WEBGL2)
+        switch (m_target) {
+        case GraphicsContext3D::COPY_READ_BUFFER:
+        case GraphicsContext3D::COPY_WRITE_BUFFER:
+        case GraphicsContext3D::PIXEL_PACK_BUFFER:
+        case GraphicsContext3D::PIXEL_UNPACK_BUFFER:
+        case GraphicsContext3D::TRANSFORM_FEEDBACK_BUFFER:
+        case GraphicsContext3D::UNIFORM_BUFFER:
+            m_byteLength = byteLength;
+            return true;
+        }
+#endif
</ins><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -135,6 +147,17 @@
</span><span class="cx">     case GraphicsContext3D::ARRAY_BUFFER:
</span><span class="cx">         return true;
</span><span class="cx">     default:
</span><ins>+#if ENABLE(WEBGL2)
+        switch (m_target) {
+        case GraphicsContext3D::COPY_READ_BUFFER:
+        case GraphicsContext3D::COPY_WRITE_BUFFER:
+        case GraphicsContext3D::PIXEL_PACK_BUFFER:
+        case GraphicsContext3D::PIXEL_UNPACK_BUFFER:
+        case GraphicsContext3D::TRANSFORM_FEEDBACK_BUFFER:
+        case GraphicsContext3D::UNIFORM_BUFFER:
+            return true;
+        }
+#endif
</ins><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -186,7 +209,7 @@
</span><span class="cx">     m_nextAvailableCacheEntry = (m_nextAvailableCacheEntry + 1) % WTF_ARRAY_LENGTH(m_maxIndexCache);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebGLBuffer::setTarget(GC3Denum target)
</del><ins>+void WebGLBuffer::setTarget(GC3Denum target, bool forWebGL2)
</ins><span class="cx"> {
</span><span class="cx">     // In WebGL, a buffer is bound to one target in its lifetime
</span><span class="cx">     if (m_target)
</span><span class="lines">@@ -193,6 +216,19 @@
</span><span class="cx">         return;
</span><span class="cx">     if (target == GraphicsContext3D::ARRAY_BUFFER || target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER)
</span><span class="cx">         m_target = target;
</span><ins>+    else if (forWebGL2) {
+#if ENABLE(WEBGL2)
+        switch (target) {
+        case GraphicsContext3D::COPY_READ_BUFFER:
+        case GraphicsContext3D::COPY_WRITE_BUFFER:
+        case GraphicsContext3D::PIXEL_PACK_BUFFER:
+        case GraphicsContext3D::PIXEL_UNPACK_BUFFER:
+        case GraphicsContext3D::TRANSFORM_FEEDBACK_BUFFER:
+        case GraphicsContext3D::UNIFORM_BUFFER:
+            m_target = target;
+        }
+#endif
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLBuffer::clearCachedMaxIndices()
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLBuffer.h (208031 => 208032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLBuffer.h        2016-10-28 04:30:22 UTC (rev 208031)
+++ trunk/Source/WebCore/html/canvas/WebGLBuffer.h        2016-10-28 05:28:55 UTC (rev 208032)
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx">     void setCachedMaxIndex(GC3Denum type, int value);
</span><span class="cx"> 
</span><span class="cx">     GC3Denum getTarget() const { return m_target; }
</span><del>-    void setTarget(GC3Denum);
</del><ins>+    void setTarget(GC3Denum, bool forWebGL2);
</ins><span class="cx"> 
</span><span class="cx">     bool hasEverBeenBound() const { return object() &amp;&amp; m_target; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLRenderingContextBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (208031 => 208032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp        2016-10-28 04:30:22 UTC (rev 208031)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp        2016-10-28 05:28:55 UTC (rev 208032)
</span><span class="lines">@@ -919,13 +919,44 @@
</span><span class="cx">     else if (target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER)
</span><span class="cx">         m_boundVertexArrayObject-&gt;setElementArrayBuffer(buffer);
</span><span class="cx">     else {
</span><del>-        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, &quot;bindBuffer&quot;, &quot;invalid target&quot;);
-        return;
</del><ins>+        bool success = false;
+#if ENABLE(WEBGL2)
+        if (isWebGL2()) {
+            success = true;
+            switch (target) {
+            case GraphicsContext3D::COPY_READ_BUFFER:
+                m_boundCopyReadBuffer = buffer;
+                break;
+            case GraphicsContext3D::COPY_WRITE_BUFFER:
+                m_boundCopyWriteBuffer = buffer;
+                break;
+            case GraphicsContext3D::PIXEL_PACK_BUFFER:
+                m_boundPixelPackBuffer = buffer;
+                break;
+            case GraphicsContext3D::PIXEL_UNPACK_BUFFER:
+                m_boundPixelUnpackBuffer = buffer;
+                break;
+            case GraphicsContext3D::TRANSFORM_FEEDBACK_BUFFER:
+                m_boundTransformFeedbackBuffer = buffer;
+                break;
+            case GraphicsContext3D::UNIFORM_BUFFER:
+                m_boundUniformBuffer = buffer;
+                break;
+            default:
+                success = false;
+                break;
+            }
+        }
+#endif
+        if (!success) {
+            synthesizeGLError(GraphicsContext3D::INVALID_ENUM, &quot;bindBuffer&quot;, &quot;invalid target&quot;);
+            return;
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_context-&gt;bindBuffer(target, objectOrZero(buffer));
</span><span class="cx">     if (buffer)
</span><del>-        buffer-&gt;setTarget(target);
</del><ins>+        buffer-&gt;setTarget(target, isWebGL2());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContextBase::bindFramebuffer(GC3Denum target, WebGLFramebuffer* buffer)
</span><span class="lines">@@ -2165,7 +2196,24 @@
</span><span class="cx"> {
</span><span class="cx">     if (isContextLostOrPending())
</span><span class="cx">         return WebGLGetInfo();
</span><del>-    if (target != GraphicsContext3D::ARRAY_BUFFER &amp;&amp; target != GraphicsContext3D::ELEMENT_ARRAY_BUFFER) {
</del><ins>+
+    bool valid = false;
+    if (target == GraphicsContext3D::ARRAY_BUFFER || target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER)
+        valid = true;
+#if ENABLE(WEBGL2)
+    if (isWebGL2()) {
+        switch (target) {
+        case GraphicsContext3D::COPY_READ_BUFFER:
+        case GraphicsContext3D::COPY_WRITE_BUFFER:
+        case GraphicsContext3D::PIXEL_PACK_BUFFER:
+        case GraphicsContext3D::PIXEL_UNPACK_BUFFER:
+        case GraphicsContext3D::TRANSFORM_FEEDBACK_BUFFER:
+        case GraphicsContext3D::UNIFORM_BUFFER:
+            valid = true;
+        }
+    }
+#endif
+    if (!valid) {
</ins><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, &quot;getBufferParameter&quot;, &quot;invalid target&quot;);
</span><span class="cx">         return WebGLGetInfo();
</span><span class="cx">     }
</span><span class="lines">@@ -4457,6 +4505,37 @@
</span><span class="cx">         buffer = m_boundArrayBuffer.get();
</span><span class="cx">         break;
</span><span class="cx">     default:
</span><ins>+#if ENABLE(WEBGL2)
+        bool success = true;
+        if (isWebGL2()) {
+            switch (target) {
+            case GraphicsContext3D::COPY_READ_BUFFER:
+                buffer = m_boundCopyReadBuffer.get();
+                break;
+            case GraphicsContext3D::COPY_WRITE_BUFFER:
+                buffer = m_boundCopyWriteBuffer.get();
+                break;
+            case GraphicsContext3D::PIXEL_PACK_BUFFER:
+                buffer = m_boundPixelPackBuffer.get();
+                break;
+            case GraphicsContext3D::PIXEL_UNPACK_BUFFER:
+                buffer = m_boundPixelUnpackBuffer.get();
+                break;
+            case GraphicsContext3D::TRANSFORM_FEEDBACK_BUFFER:
+                buffer = m_boundTransformFeedbackBuffer.get();
+                break;
+            case GraphicsContext3D::UNIFORM_BUFFER:
+                buffer = m_boundUniformBuffer.get();
+                break;
+            default:
+                success = false;
+                break;
+            }
+        } else
+            success = false;
+        if (success)
+            break;
+#endif
</ins><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, &quot;invalid target&quot;);
</span><span class="cx">         return nullptr;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLRenderingContextBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h (208031 => 208032)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h        2016-10-28 04:30:22 UTC (rev 208031)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h        2016-10-28 05:28:55 UTC (rev 208032)
</span><span class="lines">@@ -427,6 +427,12 @@
</span><span class="cx"> 
</span><span class="cx">     // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER and stored values for ELEMENT_ARRAY_BUFFER
</span><span class="cx">     RefPtr&lt;WebGLBuffer&gt; m_boundArrayBuffer;
</span><ins>+    RefPtr&lt;WebGLBuffer&gt; m_boundCopyReadBuffer;
+    RefPtr&lt;WebGLBuffer&gt; m_boundCopyWriteBuffer;
+    RefPtr&lt;WebGLBuffer&gt; m_boundPixelPackBuffer;
+    RefPtr&lt;WebGLBuffer&gt; m_boundPixelUnpackBuffer;
+    RefPtr&lt;WebGLBuffer&gt; m_boundTransformFeedbackBuffer;
+    RefPtr&lt;WebGLBuffer&gt; m_boundUniformBuffer;
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;WebGLVertexArrayObjectBase&gt; m_defaultVertexArrayObject;
</span><span class="cx">     RefPtr&lt;WebGLVertexArrayObjectBase&gt; m_boundVertexArrayObject;
</span></span></pre>
</div>
</div>

</body>
</html>