<!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>[161605] 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/161605">161605</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2014-01-09 17:12:57 -0800 (Thu, 09 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WebGL] Return filtered results for getProgramParameter for ACTIVE_ATTRIBUTES and ACTIVE_UNIFORMS
https://bugs.webkit.org/show_bug.cgi?id=126718
&lt;rdar://problem/15202048&gt;

Reviewed by Dean Jackson.

Covered by webgl/conformance/ogles/GL/biuDepthRange/biuDepthRange_001_to_002.html and
webgl/conformance/ogles/GL/gl_FragCoord/gl_FragCoord_001_to_003.html.

* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::getActiveAttrib): Added loging.
(WebCore::WebGLRenderingContext::getActiveUniform): Added logging.
(WebCore::WebGLRenderingContext::getAttribLocation): Drive-by-fix. Return
-1 on link failure (an invalid location) rather than 0 (a valid
location) when link fails.
(WebCore::WebGLRenderingContext::getProgramParameter): Use new
method to return filtered count.
(WebCore::WebGLRenderingContext::getUniformLocation): Use nullptr
rather than returning 0.
* platform/graphics/GraphicsContext3D.h:
(WebCore::GraphicsContext3D::ActiveShaderSymbolCounts::ActiveShaderSymbolCounts):
(WebCore::GraphicsContext3D::ActiveShaderSymbolCounts::countForType):
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::precisionsMatch): Drive-by-fix. Don't
copy giant objects to read a single value.
(WebCore::GraphicsContext3D::compileShader): Release filtered count
when we change shader source code.
(WebCore::GraphicsContext3D::getActiveAttribImpl): Renamed from getActiveAttrib.
(WebCore::GraphicsContext3D::getActiveAttrib): Maps filtered indices to
real OpenGL indices.
(WebCore::GraphicsContext3D::getActiveUniformImpl): Renamed from getActiveUniform.
(WebCore::GraphicsContext3D::getActiveUniform): Maps filtered indices to
real OpenGL indices.
(WebCore::GraphicsContext3D::originalSymbolName): Use C++11 loop.
(WebCore::GraphicsContext3D::getAttribLocation): Added logging.
(WebCore::GraphicsContext3D::getNonBuiltinActiveSymbolCount): Added.
(WebCore::GraphicsContext3D::getShaderiv): Const correctness.
(WebCore::GraphicsContext3D::getShaderInfoLog): Ditto.
(WebCore::GraphicsContext3D::getShaderSource): Ditto.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLRenderingContextcpp">trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContext3Dh">trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h</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 (161604 => 161605)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-10 00:55:37 UTC (rev 161604)
+++ trunk/Source/WebCore/ChangeLog        2014-01-10 01:12:57 UTC (rev 161605)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2014-01-09  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        [WebGL] Return filtered results for getProgramParameter for ACTIVE_ATTRIBUTES and ACTIVE_UNIFORMS
+        https://bugs.webkit.org/show_bug.cgi?id=126718
+        &lt;rdar://problem/15202048&gt;
+
+        Reviewed by Dean Jackson.
+
+        Covered by webgl/conformance/ogles/GL/biuDepthRange/biuDepthRange_001_to_002.html and
+        webgl/conformance/ogles/GL/gl_FragCoord/gl_FragCoord_001_to_003.html.
+
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::getActiveAttrib): Added loging.
+        (WebCore::WebGLRenderingContext::getActiveUniform): Added logging.
+        (WebCore::WebGLRenderingContext::getAttribLocation): Drive-by-fix. Return
+        -1 on link failure (an invalid location) rather than 0 (a valid
+        location) when link fails.
+        (WebCore::WebGLRenderingContext::getProgramParameter): Use new
+        method to return filtered count.
+        (WebCore::WebGLRenderingContext::getUniformLocation): Use nullptr
+        rather than returning 0.
+        * platform/graphics/GraphicsContext3D.h:
+        (WebCore::GraphicsContext3D::ActiveShaderSymbolCounts::ActiveShaderSymbolCounts):
+        (WebCore::GraphicsContext3D::ActiveShaderSymbolCounts::countForType):
+        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
+        (WebCore::GraphicsContext3D::precisionsMatch): Drive-by-fix. Don't
+        copy giant objects to read a single value.
+        (WebCore::GraphicsContext3D::compileShader): Release filtered count
+        when we change shader source code.
+        (WebCore::GraphicsContext3D::getActiveAttribImpl): Renamed from getActiveAttrib.
+        (WebCore::GraphicsContext3D::getActiveAttrib): Maps filtered indices to
+        real OpenGL indices.
+        (WebCore::GraphicsContext3D::getActiveUniformImpl): Renamed from getActiveUniform.
+        (WebCore::GraphicsContext3D::getActiveUniform): Maps filtered indices to
+        real OpenGL indices.
+        (WebCore::GraphicsContext3D::originalSymbolName): Use C++11 loop.
+        (WebCore::GraphicsContext3D::getAttribLocation): Added logging.
+        (WebCore::GraphicsContext3D::getNonBuiltinActiveSymbolCount): Added.
+        (WebCore::GraphicsContext3D::getShaderiv): Const correctness.
+        (WebCore::GraphicsContext3D::getShaderInfoLog): Ditto.
+        (WebCore::GraphicsContext3D::getShaderSource): Ditto.
+
</ins><span class="cx"> 2014-01-09  Zoltan Horvath  &lt;zoltan@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [CSS Shapes] First line gets incorrectly adjusted in shape-inside due to rounding
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLRenderingContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (161604 => 161605)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp        2014-01-10 00:55:37 UTC (rev 161604)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp        2014-01-10 01:12:57 UTC (rev 161605)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2009, 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2009, 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> #include &quot;ImageBuffer.h&quot;
</span><span class="cx"> #include &quot;ImageData.h&quot;
</span><span class="cx"> #include &quot;IntSize.h&quot;
</span><ins>+#include &quot;Logging.h&quot;
</ins><span class="cx"> #include &quot;NotImplemented.h&quot;
</span><span class="cx"> #include &quot;OESElementIndexUint.h&quot;
</span><span class="cx"> #include &quot;OESStandardDerivatives.h&quot;
</span><span class="lines">@@ -2259,6 +2260,9 @@
</span><span class="cx">     ActiveInfo info;
</span><span class="cx">     if (!m_context-&gt;getActiveAttrib(objectOrZero(program), index, info))
</span><span class="cx">         return 0;
</span><ins>+
+    LOG(WebGL, &quot;Returning active attribute %d: %s&quot;, index, info.name.utf8().data());
+
</ins><span class="cx">     return WebGLActiveInfo::create(info.name, info.type, info.size);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2273,6 +2277,9 @@
</span><span class="cx">     if (!isGLES2Compliant())
</span><span class="cx">         if (info.size &gt; 1 &amp;&amp; !info.name.endsWith(&quot;[0]&quot;))
</span><span class="cx">             info.name.append(&quot;[0]&quot;);
</span><ins>+
+    LOG(WebGL, &quot;Returning active uniform %d: %s&quot;, index, info.name.utf8().data());
+
</ins><span class="cx">     return WebGLActiveInfo::create(info.name, info.type, info.size);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2307,7 +2314,7 @@
</span><span class="cx">         return -1;
</span><span class="cx">     if (!program-&gt;getLinkStatus()) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, &quot;getAttribLocation&quot;, &quot;program not linked&quot;);
</span><del>-        return 0;
</del><ins>+        return -1;
</ins><span class="cx">     }
</span><span class="cx">     return m_context-&gt;getAttribLocation(objectOrZero(program), name);
</span><span class="cx"> }
</span><span class="lines">@@ -2787,9 +2794,11 @@
</span><span class="cx">     case GraphicsContext3D::LINK_STATUS:
</span><span class="cx">         return WebGLGetInfo(program-&gt;getLinkStatus());
</span><span class="cx">     case GraphicsContext3D::ATTACHED_SHADERS:
</span><ins>+        m_context-&gt;getProgramiv(objectOrZero(program), pname, &amp;value);
+        return WebGLGetInfo(value);
</ins><span class="cx">     case GraphicsContext3D::ACTIVE_ATTRIBUTES:
</span><span class="cx">     case GraphicsContext3D::ACTIVE_UNIFORMS:
</span><del>-        m_context-&gt;getProgramiv(objectOrZero(program), pname, &amp;value);
</del><ins>+        m_context-&gt;getNonBuiltInActiveSymbolCount(objectOrZero(program), pname, &amp;value);
</ins><span class="cx">         return WebGLGetInfo(value);
</span><span class="cx">     default:
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, &quot;getProgramParameter&quot;, &quot;invalid parameter name&quot;);
</span><span class="lines">@@ -3147,21 +3156,21 @@
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><span class="cx">     if (isContextLost() || !validateWebGLObject(&quot;getUniformLocation&quot;, program))
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     if (!validateLocationLength(&quot;getUniformLocation&quot;, name))
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     if (!validateString(&quot;getUniformLocation&quot;, name))
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     if (isPrefixReserved(name))
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     if (!program-&gt;getLinkStatus()) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, &quot;getUniformLocation&quot;, &quot;program not linked&quot;);
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     }
</span><span class="cx">     WebGLStateRestorer(this, false);
</span><span class="cx">     GC3Dint uniformLocation = m_context-&gt;getUniformLocation(objectOrZero(program), name);
</span><span class="cx">     if (uniformLocation == -1)
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx"> 
</span><span class="cx">     GC3Dint activeUniforms = 0;
</span><span class="cx">     m_context-&gt;getProgramiv(objectOrZero(program), GraphicsContext3D::ACTIVE_UNIFORMS, &amp;activeUniforms);
</span><span class="lines">@@ -3180,7 +3189,7 @@
</span><span class="cx">                 return WebGLUniformLocation::create(program, uniformLocation, info.type);
</span><span class="cx">         }
</span><span class="cx">     }
</span><del>-    return 0;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebGLGetInfo WebGLRenderingContext::getVertexAttrib(GC3Duint index, GC3Denum pname, ExceptionCode&amp; ec)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContext3Dh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (161604 => 161605)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h        2014-01-10 00:55:37 UTC (rev 161604)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h        2014-01-10 01:12:57 UTC (rev 161605)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2009 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2009, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -688,7 +688,9 @@
</span><span class="cx">     void generateMipmap(GC3Denum target);
</span><span class="cx"> 
</span><span class="cx">     bool getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo&amp;);
</span><ins>+    bool getActiveAttribImpl(Platform3DObject program, GC3Duint index, ActiveInfo&amp;);
</ins><span class="cx">     bool getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo&amp;);
</span><ins>+    bool getActiveUniformImpl(Platform3DObject program, GC3Duint index, ActiveInfo&amp;);
</ins><span class="cx">     void getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders);
</span><span class="cx">     GC3Dint getAttribLocation(Platform3DObject, const String&amp; name);
</span><span class="cx">     void getBooleanv(GC3Denum pname, GC3Dboolean* value);
</span><span class="lines">@@ -699,6 +701,7 @@
</span><span class="cx">     void getFramebufferAttachmentParameteriv(GC3Denum target, GC3Denum attachment, GC3Denum pname, GC3Dint* value);
</span><span class="cx">     void getIntegerv(GC3Denum pname, GC3Dint* value);
</span><span class="cx">     void getProgramiv(Platform3DObject program, GC3Denum pname, GC3Dint* value);
</span><ins>+    void getNonBuiltInActiveSymbolCount(Platform3DObject program, GC3Denum pname, GC3Dint* value);
</ins><span class="cx">     String getProgramInfoLog(Platform3DObject);
</span><span class="cx">     void getRenderbufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value);
</span><span class="cx">     void getShaderiv(Platform3DObject, GC3Denum pname, GC3Dint* value);
</span><span class="lines">@@ -1044,6 +1047,25 @@
</span><span class="cx">     typedef HashMap&lt;Platform3DObject, ShaderSourceEntry&gt; ShaderSourceMap;
</span><span class="cx">     ShaderSourceMap m_shaderSourceMap;
</span><span class="cx"> 
</span><ins>+    struct ActiveShaderSymbolCounts {
+        Vector&lt;GC3Dint&gt; filteredToActualAttributeIndexMap;
+        Vector&lt;GC3Dint&gt; filteredToActualUniformIndexMap;
+
+        ActiveShaderSymbolCounts()
+        {
+        }
+
+        GC3Dint countForType(GC3Denum activeType)
+        {
+            ASSERT(activeType == ACTIVE_ATTRIBUTES || activeType == ACTIVE_UNIFORMS);
+            if (activeType == ACTIVE_ATTRIBUTES)
+                return filteredToActualAttributeIndexMap.size();
+
+            return filteredToActualUniformIndexMap.size();
+        }
+    };
+    std::unique_ptr&lt;ActiveShaderSymbolCounts&gt; m_shaderSymbolCount;
+
</ins><span class="cx">     String mappedSymbolName(Platform3DObject program, ANGLEShaderSymbolType, const String&amp; name);
</span><span class="cx">     String originalSymbolName(Platform3DObject program, ANGLEShaderSymbolType, const String&amp; name);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsopenglGraphicsContext3DOpenGLCommoncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp (161604 => 161605)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp        2014-01-10 00:55:37 UTC (rev 161604)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp        2014-01-10 01:12:57 UTC (rev 161605)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2010 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2011 Google Inc. All rights reserved.
</span><span class="cx">  * Copyright (C) 2012 ChangSeok Oh &lt;shivamidow@gmail.com&gt;
</span><span class="cx">  * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
</span><span class="lines">@@ -337,17 +337,19 @@
</span><span class="cx"> 
</span><span class="cx"> bool GraphicsContext3D::precisionsMatch(Platform3DObject vertexShader, Platform3DObject fragmentShader) const
</span><span class="cx"> {
</span><del>-    ShaderSourceEntry vertexEntry = m_shaderSourceMap.find(vertexShader)-&gt;value;
-    ShaderSourceEntry fragmentEntry = m_shaderSourceMap.find(fragmentShader)-&gt;value;
</del><ins>+    ASSERT(m_shaderSourceMap.contains(vertexShader));
+    ASSERT(m_shaderSourceMap.contains(fragmentShader));
+    const auto&amp; vertexEntry = m_shaderSourceMap.find(vertexShader)-&gt;value;
+    const auto&amp; fragmentEntry = m_shaderSourceMap.find(fragmentShader)-&gt;value;
</ins><span class="cx"> 
</span><span class="cx">     HashMap&lt;String, ShPrecisionType&gt; vertexSymbolPrecisionMap;
</span><span class="cx"> 
</span><del>-    for (auto it = vertexEntry.uniformMap.begin(); it != vertexEntry.uniformMap.end(); ++it)
-        vertexSymbolPrecisionMap.add(it-&gt;value.mappedName, it-&gt;value.precision);
</del><ins>+    for (const auto&amp; entry : vertexEntry.uniformMap)
+        vertexSymbolPrecisionMap.add(entry.value.mappedName, entry.value.precision);
</ins><span class="cx"> 
</span><del>-    for (auto it = fragmentEntry.uniformMap.begin(); it != fragmentEntry.uniformMap.end(); ++it) {
-        HashMap&lt;String, ShPrecisionType&gt;::iterator vertexSymbol = vertexSymbolPrecisionMap.find(it-&gt;value.mappedName);
-        if (vertexSymbol != vertexSymbolPrecisionMap.end() &amp;&amp; vertexSymbol-&gt;value != it-&gt;value.precision)
</del><ins>+    for (const auto&amp; entry : fragmentEntry.uniformMap) {
+        const auto&amp; vertexSymbol = vertexSymbolPrecisionMap.find(entry.value.mappedName);
+        if (vertexSymbol != vertexSymbolPrecisionMap.end() &amp;&amp; vertexSymbol-&gt;value != entry.value.precision)
</ins><span class="cx">             return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -564,6 +566,8 @@
</span><span class="cx">         BBLOG(BlackBerry::Platform::LogLevelWarn, &quot;The shader validated, but didn't compile.\n&quot;);
</span><span class="cx"> #endif
</span><span class="cx">     }
</span><ins>+
+    m_shaderSymbolCount = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsContext3D::copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border)
</span><span class="lines">@@ -696,7 +700,7 @@
</span><span class="cx">     ::glGenerateMipmap(target);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo&amp; info)
</del><ins>+bool GraphicsContext3D::getActiveAttribImpl(Platform3DObject program, GC3Duint index, ActiveInfo&amp; info)
</ins><span class="cx"> {
</span><span class="cx">     if (!program) {
</span><span class="cx">         synthesizeGLError(INVALID_VALUE);
</span><span class="lines">@@ -715,14 +719,27 @@
</span><span class="cx">     
</span><span class="cx">     String originalName = originalSymbolName(program, SHADER_SYMBOL_TYPE_ATTRIBUTE, String(name.get(), nameLength));
</span><span class="cx">     
</span><ins>+#ifndef NDEBUG
+    String uniformName(name.get(), nameLength);
+    LOG(WebGL, &quot;Program %d is mapping active attribute %d from '%s' to '%s'&quot;, program, index, uniformName.utf8().data(), originalName.utf8().data());
+#endif
+
</ins><span class="cx">     info.name = originalName;
</span><span class="cx">     info.type = type;
</span><span class="cx">     info.size = size;
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GraphicsContext3D::getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo&amp; info)
</del><ins>+bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo&amp; info)
</ins><span class="cx"> {
</span><ins>+    ASSERT(!m_shaderSymbolCount || index &lt; m_shaderSymbolCount-&gt;filteredToActualAttributeIndexMap.size());
+    GC3Duint rawIndex = (m_shaderSymbolCount) ? m_shaderSymbolCount-&gt;filteredToActualAttributeIndexMap[index] : index;
+
+    return getActiveAttribImpl(program, rawIndex, info);
+}
+
+bool GraphicsContext3D::getActiveUniformImpl(Platform3DObject program, GC3Duint index, ActiveInfo&amp; info)
+{
</ins><span class="cx">     if (!program) {
</span><span class="cx">         synthesizeGLError(INVALID_VALUE);
</span><span class="cx">         return false;
</span><span class="lines">@@ -742,12 +759,25 @@
</span><span class="cx">     
</span><span class="cx">     String originalName = originalSymbolName(program, SHADER_SYMBOL_TYPE_UNIFORM, String(name.get(), nameLength));
</span><span class="cx">     
</span><ins>+#ifndef NDEBUG
+    String uniformName(name.get(), nameLength);
+    LOG(WebGL, &quot;Program %d is mapping active uniform %d from '%s' to '%s'&quot;, program, index, uniformName.utf8().data(), originalName.utf8().data());
+#endif
+    
</ins><span class="cx">     info.name = originalName;
</span><span class="cx">     info.type = type;
</span><span class="cx">     info.size = size;
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><ins>+
+bool GraphicsContext3D::getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo&amp; info)
+{
+    ASSERT(!m_shaderSymbolCount || index &lt; m_shaderSymbolCount-&gt;filteredToActualUniformIndexMap.size());
+    GC3Duint rawIndex = (m_shaderSymbolCount) ? m_shaderSymbolCount-&gt;filteredToActualUniformIndexMap[index] : index;
</ins><span class="cx">     
</span><ins>+    return getActiveUniformImpl(program, rawIndex, info);
+}
+
</ins><span class="cx"> void GraphicsContext3D::getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders)
</span><span class="cx"> {
</span><span class="cx">     if (!program) {
</span><span class="lines">@@ -789,10 +819,9 @@
</span><span class="cx">             continue;
</span><span class="cx">         
</span><span class="cx">         const ShaderSymbolMap&amp; symbolMap = result-&gt;value.symbolMap(symbolType);
</span><del>-        ShaderSymbolMap::const_iterator symbolEntry;
-        for (symbolEntry = symbolMap.begin(); symbolEntry != symbolMap.end(); ++symbolEntry) {
-            if (symbolEntry-&gt;value.mappedName == name)
-                return symbolEntry-&gt;key;
</del><ins>+        for (const auto&amp; symbolEntry : symbolMap) {
+            if (symbolEntry.value.mappedName == name)
+                return symbolEntry.key;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     return name;
</span><span class="lines">@@ -806,7 +835,7 @@
</span><span class="cx">     makeContextCurrent();
</span><span class="cx"> 
</span><span class="cx">     String mappedName = mappedSymbolName(program, SHADER_SYMBOL_TYPE_ATTRIBUTE, name);
</span><del>-    LOG(WebGL, &quot;::getAttribLocation is mapping %s to %s&quot;, name.utf8().data(), mappedName.utf8().data());
</del><ins>+    LOG(WebGL, &quot;::glGetAttribLocation is mapping %s to %s&quot;, name.utf8().data(), mappedName.utf8().data());
</ins><span class="cx">     return ::glGetAttribLocation(program, mappedName.utf8().data());
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1227,6 +1256,49 @@
</span><span class="cx">     ::glGetProgramiv(program, pname, value);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void GraphicsContext3D::getNonBuiltInActiveSymbolCount(Platform3DObject program, GC3Denum pname, GC3Dint* value)
+{
+    ASSERT(ACTIVE_ATTRIBUTES == pname || ACTIVE_UNIFORMS == pname);
+    if (!value)
+        return;
+
+    makeContextCurrent();
+
+    if (m_shaderSymbolCount) {
+        *value = m_shaderSymbolCount-&gt;countForType(pname);
+        return;
+    }
+
+    m_shaderSymbolCount = std::make_unique&lt;ActiveShaderSymbolCounts&gt;();
+
+    // Retrieve the active attributes, build a filtered count, and a mapping of
+    // our internal attributes indexes to the real unfiltered indexes inside OpenGL.
+    GC3Dint attributeCount = 0;
+    ::glGetProgramiv(program, ACTIVE_ATTRIBUTES, &amp;attributeCount);
+    for (GC3Dint i = 0; i &lt; attributeCount; ++i) {
+        ActiveInfo info;
+        getActiveAttribImpl(program, i, info);
+        if (info.name.startsWith(&quot;gl_&quot;))
+            continue;
+
+        m_shaderSymbolCount-&gt;filteredToActualAttributeIndexMap.append(i);
+    }
+    
+    // Do the same for uniforms.
+    GC3Dint uniformCount = 0;
+    ::glGetProgramiv(program, ACTIVE_UNIFORMS, &amp;uniformCount);
+    for (GC3Dint i = 0; i &lt; uniformCount; ++i) {
+        ActiveInfo info;
+        getActiveUniformImpl(program, i, info);
+        if (info.name.startsWith(&quot;gl_&quot;))
+            continue;
+        
+        m_shaderSymbolCount-&gt;filteredToActualUniformIndexMap.append(i);
+    }
+    
+    *value = m_shaderSymbolCount-&gt;countForType(pname);
+}
+
</ins><span class="cx"> String GraphicsContext3D::getProgramInfoLog(Platform3DObject program)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(program);
</span><span class="lines">@@ -1256,7 +1328,7 @@
</span><span class="cx"> 
</span><span class="cx">     makeContextCurrent();
</span><span class="cx"> 
</span><del>-    ShaderSourceMap::iterator result = m_shaderSourceMap.find(shader);
</del><ins>+    const auto&amp; result = m_shaderSourceMap.find(shader);
</ins><span class="cx">     
</span><span class="cx">     switch (pname) {
</span><span class="cx">     case DELETE_STATUS:
</span><span class="lines">@@ -1291,11 +1363,11 @@
</span><span class="cx"> 
</span><span class="cx">     makeContextCurrent();
</span><span class="cx"> 
</span><del>-    ShaderSourceMap::iterator result = m_shaderSourceMap.find(shader);
</del><ins>+    const auto&amp; result = m_shaderSourceMap.find(shader);
</ins><span class="cx">     if (result == m_shaderSourceMap.end())
</span><span class="cx">         return String(); 
</span><span class="cx"> 
</span><del>-    ShaderSourceEntry entry = result-&gt;value;
</del><ins>+    const ShaderSourceEntry&amp; entry = result-&gt;value;
</ins><span class="cx">     if (!entry.isValid)
</span><span class="cx">         return entry.log;
</span><span class="cx"> 
</span><span class="lines">@@ -1317,7 +1389,7 @@
</span><span class="cx"> 
</span><span class="cx">     makeContextCurrent();
</span><span class="cx"> 
</span><del>-    ShaderSourceMap::iterator result = m_shaderSourceMap.find(shader);
</del><ins>+    const auto&amp; result = m_shaderSourceMap.find(shader);
</ins><span class="cx">     if (result == m_shaderSourceMap.end())
</span><span class="cx">         return String(); 
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>