<!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>[161783] 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/161783">161783</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-01-11 14:56:40 -0800 (Sat, 11 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Extract the FormatConverter class out of GraphicsContext3D.cpp and into its own file
https://bugs.webkit.org/show_bug.cgi?id=126820

Patch by Sam Weinig &lt;sam@webkit.org&gt; on 2014-01-11
Reviewed by Anders Carlsson.

* CMakeLists.txt:
* GNUmakefile.list.am:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/FormatConverter.cpp: Copied from Source/WebCore/platform/graphics/GraphicsContext3D.cpp.
(WebCore::convertFloatToHalfFloat):
(WebCore::FormatConverter::convert):
* platform/graphics/FormatConverter.h: Copied from Source/WebCore/platform/graphics/GraphicsContext3D.cpp.
(WebCore::FormatConverter::FormatConverter):
(WebCore::FormatConverter::success):
* platform/graphics/GraphicsContext3D.cpp:
(WebCore::GraphicsContext3D::computeFormatAndTypeParameters):
(WebCore::GraphicsContext3D::computeImageSizeInBytes):
(WebCore::GraphicsContext3D::packImageData):
(WebCore::GraphicsContext3D::extractImageData):
(WebCore::GraphicsContext3D::extractTextureData):
(WebCore::GraphicsContext3D::packPixels):
* platform/graphics/GraphicsContext3D.h:
(WebCore::GraphicsContext3D::hasAlpha):
(WebCore::GraphicsContext3D::hasColor):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreGNUmakefilelistam">trunk/Source/WebCore/GNUmakefile.list.am</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContext3Dcpp">trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContext3Dh">trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicsFormatConvertercpp">trunk/Source/WebCore/platform/graphics/FormatConverter.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFormatConverterh">trunk/Source/WebCore/platform/graphics/FormatConverter.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (161782 => 161783)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2014-01-11 21:58:23 UTC (rev 161782)
+++ trunk/Source/WebCore/CMakeLists.txt        2014-01-11 22:56:40 UTC (rev 161783)
</span><span class="lines">@@ -2979,6 +2979,7 @@
</span><span class="cx">     list(APPEND WebCore_SOURCES
</span><span class="cx">         platform/graphics/ANGLEWebKitBridge.cpp
</span><span class="cx">         platform/graphics/GraphicsContext3D.cpp
</span><ins>+        platform/graphics/FormatConverter.cpp
</ins><span class="cx"> 
</span><span class="cx">         platform/graphics/gpu/DrawingBuffer.cpp
</span><span class="cx">     )
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (161782 => 161783)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-11 21:58:23 UTC (rev 161782)
+++ trunk/Source/WebCore/ChangeLog        2014-01-11 22:56:40 UTC (rev 161783)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2014-01-11  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        Extract the FormatConverter class out of GraphicsContext3D.cpp and into its own file
+        https://bugs.webkit.org/show_bug.cgi?id=126820
+
+        Reviewed by Anders Carlsson.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/FormatConverter.cpp: Copied from Source/WebCore/platform/graphics/GraphicsContext3D.cpp.
+        (WebCore::convertFloatToHalfFloat):
+        (WebCore::FormatConverter::convert):
+        * platform/graphics/FormatConverter.h: Copied from Source/WebCore/platform/graphics/GraphicsContext3D.cpp.
+        (WebCore::FormatConverter::FormatConverter):
+        (WebCore::FormatConverter::success):
+        * platform/graphics/GraphicsContext3D.cpp:
+        (WebCore::GraphicsContext3D::computeFormatAndTypeParameters):
+        (WebCore::GraphicsContext3D::computeImageSizeInBytes):
+        (WebCore::GraphicsContext3D::packImageData):
+        (WebCore::GraphicsContext3D::extractImageData):
+        (WebCore::GraphicsContext3D::extractTextureData):
+        (WebCore::GraphicsContext3D::packPixels):
+        * platform/graphics/GraphicsContext3D.h:
+        (WebCore::GraphicsContext3D::hasAlpha):
+        (WebCore::GraphicsContext3D::hasColor):
+
</ins><span class="cx"> 2014-01-11  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix updateScrollingLayerWithClient() for iOS.
</span></span></pre></div>
<a id="trunkSourceWebCoreGNUmakefilelistam"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/GNUmakefile.list.am (161782 => 161783)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/GNUmakefile.list.am        2014-01-11 21:58:23 UTC (rev 161782)
+++ trunk/Source/WebCore/GNUmakefile.list.am        2014-01-11 22:56:40 UTC (rev 161783)
</span><span class="lines">@@ -5366,6 +5366,8 @@
</span><span class="cx">         Source/WebCore/platform/graphics/filters/FilterOperations.h \
</span><span class="cx">         Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp \
</span><span class="cx">         Source/WebCore/platform/graphics/gpu/DrawingBuffer.h \
</span><ins>+        Source/WebCore/platform/graphics/FormatConverter.cpp \
+        Source/WebCore/platform/graphics/FormatConverter.h \
</ins><span class="cx">         Source/WebCore/platform/graphics/GraphicsContext3D.cpp \
</span><span class="cx">         Source/WebCore/platform/graphics/GraphicsContext3D.h \
</span><span class="cx">         Source/WebCore/platform/graphics/GraphicsLayer.h \
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (161782 => 161783)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-01-11 21:58:23 UTC (rev 161782)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-01-11 22:56:40 UTC (rev 161783)
</span><span class="lines">@@ -7295,6 +7295,7 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\graphics\gpu\SharedGraphicsContext3D.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\graphics\gpu\Texture.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\graphics\gpu\TilingData.cpp&quot; /&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\platform\graphics\FormatConverter.cpp&quot; /&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\platform\graphics\GraphicsContext3D.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\graphics\GraphicsLayerAnimation.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\graphics\GraphicsLayerTransform.cpp&quot; /&gt;
</span><span class="lines">@@ -19073,6 +19074,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\gpu\SharedGraphicsContext3D.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\gpu\Texture.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\gpu\TilingData.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\platform\graphics\FormatConverter.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\GraphicsContext3D.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\GraphicsLayerAnimation.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\GraphicsLayerFactory.h&quot; /&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (161782 => 161783)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2014-01-11 21:58:23 UTC (rev 161782)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2014-01-11 22:56:40 UTC (rev 161783)
</span><span class="lines">@@ -6739,6 +6739,9 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\graphics\ANGLEWebKitBridge.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;platform\graphics&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\platform\graphics\FormatConverter.cpp&quot;&gt;
+      &lt;Filter&gt;platform\graphics&lt;/Filter&gt;
+    &lt;/ClCompile&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\platform\graphics\GraphicsContext3D.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;platform\graphics&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><span class="lines">@@ -14602,6 +14605,9 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\ANGLEWebKitBridge.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;platform\graphics&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\platform\graphics\FormatConverter.h&quot;&gt;
+      &lt;Filter&gt;platform\graphics&lt;/Filter&gt;
+    &lt;/ClInclude&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\GraphicsContext3D.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;platform\graphics&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (161782 => 161783)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-01-11 21:58:23 UTC (rev 161782)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-01-11 22:56:40 UTC (rev 161783)
</span><span class="lines">@@ -2293,6 +2293,8 @@
</span><span class="cx">                 7C5343FC17B74B63004232F0 /* JSMediaQueryListListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C5343FA17B74B63004232F0 /* JSMediaQueryListListener.cpp */; };
</span><span class="cx">                 7C5343FD17B74B63004232F0 /* JSMediaQueryListListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C5343FB17B74B63004232F0 /* JSMediaQueryListListener.h */; };
</span><span class="cx">                 7CC7E3D717208C0F003C5277 /* IDNScriptWhiteList.txt in Resources */ = {isa = PBXBuildFile; fileRef = 7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */; };
</span><ins>+                7CE6CBFB187F370700D46BF5 /* FormatConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE6CBFA187F370700D46BF5 /* FormatConverter.h */; };
+                7CE6CBFD187F394900D46BF5 /* FormatConverter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CE6CBFC187F394900D46BF5 /* FormatConverter.cpp */; };
</ins><span class="cx">                 7D741BDA177226AA00859170 /* CSSValueKeywords.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 6565814809D13043000E61D7 /* CSSValueKeywords.h */; };
</span><span class="cx">                 7E12E90F15FA5D3A005E4126 /* CustomFilterMeshGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E12E90D15FA5D3A005E4126 /* CustomFilterMeshGenerator.h */; };
</span><span class="cx">                 7E12E91015FA5D3A005E4126 /* CustomFilterMeshGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E12E90E15FA5D3A005E4126 /* CustomFilterMeshGenerator.cpp */; };
</span><span class="lines">@@ -9266,6 +9268,8 @@
</span><span class="cx">                 7C6136F81710C35200FF4A57 /* InFilesParser.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; name = InFilesParser.pm; path = scripts/InFilesParser.pm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7C6136F91710C35200FF4A57 /* StaticString.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; name = StaticString.pm; path = scripts/StaticString.pm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = IDNScriptWhiteList.txt; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                7CE6CBFA187F370700D46BF5 /* FormatConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormatConverter.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                7CE6CBFC187F394900D46BF5 /* FormatConverter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormatConverter.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 7E12E90D15FA5D3A005E4126 /* CustomFilterMeshGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CustomFilterMeshGenerator.h; path = filters/CustomFilterMeshGenerator.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7E12E90E15FA5D3A005E4126 /* CustomFilterMeshGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CustomFilterMeshGenerator.cpp; path = filters/CustomFilterMeshGenerator.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7E33CD00127F340D00BE8F17 /* PurgePriority.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PurgePriority.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -19832,10 +19836,6 @@
</span><span class="cx">                 B2A015910AF6CD53006BCE0E /* graphics */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><del>-                                6E0E5699183BFFE600E0E8D5 /* FloatRoundedRect.cpp */,
-                                6E0E569A183BFFE600E0E8D5 /* FloatRoundedRect.h */,
-                                CD641EB11818F5ED00EE4C41 /* MediaSourcePrivate.h */,
-                                CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */,
</del><span class="cx">                                 076F0D0812B8192700C26AA4 /* avfoundation */,
</span><span class="cx">                                 499B3EC0128CCC1800E726C2 /* ca */,
</span><span class="cx">                                 B27535290B053814002CE64F /* cg */,
</span><span class="lines">@@ -19872,6 +19872,8 @@
</span><span class="cx">                                 0FD723800EC8BD9300CA5DD7 /* FloatQuad.h */,
</span><span class="cx">                                 B275353C0B053814002CE64F /* FloatRect.cpp */,
</span><span class="cx">                                 B275353D0B053814002CE64F /* FloatRect.h */,
</span><ins>+                                6E0E5699183BFFE600E0E8D5 /* FloatRoundedRect.cpp */,
+                                6E0E569A183BFFE600E0E8D5 /* FloatRoundedRect.h */,
</ins><span class="cx">                                 B275353E0B053814002CE64F /* FloatSize.cpp */,
</span><span class="cx">                                 B275353F0B053814002CE64F /* FloatSize.h */,
</span><span class="cx">                                 B2C3DA4F0D006CD600EF6F26 /* Font.cpp */,
</span><span class="lines">@@ -19899,10 +19901,10 @@
</span><span class="cx">                                 37202198106213C600F25C4B /* FontSmoothingMode.h */,
</span><span class="cx">                                 3784C34A0E11AA34007D8D48 /* FontTraitsMask.h */,
</span><span class="cx">                                 BCE4413512F7490B009B84B8 /* FontWidthVariant.h */,
</span><ins>+                                7CE6CBFC187F394900D46BF5 /* FormatConverter.cpp */,
+                                7CE6CBFA187F370700D46BF5 /* FormatConverter.h */,
</ins><span class="cx">                                 4FB390AC15EF61F3007AD51F /* GeneratedImage.cpp */,
</span><span class="cx">                                 BC23F0DA0DAFF4A4009FDC91 /* GeneratedImage.h */,
</span><del>-                                2D2FC0561460CD6F00263633 /* GradientImage.cpp */,
-                                2D2FC0571460CD6F00263633 /* GradientImage.h */,
</del><span class="cx">                                 086BBD0E136039C2008B15D8 /* Glyph.h */,
</span><span class="cx">                                 B2C3DA5B0D006CD600EF6F26 /* GlyphBuffer.h */,
</span><span class="cx">                                 C5D4AA78116BAFB60069CA93 /* GlyphMetricsMap.h */,
</span><span class="lines">@@ -19911,6 +19913,8 @@
</span><span class="cx">                                 B2C3DA5D0D006CD600EF6F26 /* GlyphPageTreeNode.h */,
</span><span class="cx">                                 BC53C6070DA56C570021EB5D /* Gradient.cpp */,
</span><span class="cx">                                 BC53C5F40DA56B920021EB5D /* Gradient.h */,
</span><ins>+                                2D2FC0561460CD6F00263633 /* GradientImage.cpp */,
+                                2D2FC0571460CD6F00263633 /* GradientImage.h */,
</ins><span class="cx">                                 B2A015920AF6CD53006BCE0E /* GraphicsContext.cpp */,
</span><span class="cx">                                 B2A015930AF6CD53006BCE0E /* GraphicsContext.h */,
</span><span class="cx">                                 6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */,
</span><span class="lines">@@ -19957,6 +19961,7 @@
</span><span class="cx">                                 E4B41E0C0CBF90BD00AF2ECE /* MediaPlayer.cpp */,
</span><span class="cx">                                 E4B41E0D0CBF90BD00AF2ECE /* MediaPlayer.h */,
</span><span class="cx">                                 079F5E4B0F3BEBEA005E0782 /* MediaPlayerPrivate.h */,
</span><ins>+                                CD641EB11818F5ED00EE4C41 /* MediaSourcePrivate.h */,
</ins><span class="cx">                                 6B3480920EEF50D400AC1B41 /* NativeImagePtr.h */,
</span><span class="cx">                                 B27535520B053814002CE64F /* Path.cpp */,
</span><span class="cx">                                 B27535530B053814002CE64F /* Path.h */,
</span><span class="lines">@@ -19977,8 +19982,7 @@
</span><span class="cx">                                 0F3DD44E12F5EA1B000D9190 /* ShadowBlur.h */,
</span><span class="cx">                                 B2C3DA530D006CD600EF6F26 /* SimpleFontData.cpp */,
</span><span class="cx">                                 B2C3DA540D006CD600EF6F26 /* SimpleFontData.h */,
</span><del>-                                CDC61DA0180867D8004B913F /* SourceBufferPrivate.h */,
-                                CD54A75E180F535000B076C9 /* MediaSourcePrivate.h */,
</del><ins>+                                CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */,
</ins><span class="cx">                                 CDC8B5AC1804AE5D0016E685 /* SourceBufferPrivateClient.h */,
</span><span class="cx">                                 B23540F00D00782E002382FA /* StringTruncator.cpp */,
</span><span class="cx">                                 B23540F10D00782E002382FA /* StringTruncator.h */,
</span><span class="lines">@@ -20002,6 +20006,8 @@
</span><span class="cx">                                 501BAAA813950E2C00F7ACEB /* WindRule.h */,
</span><span class="cx">                                 379919941200DDF400EA041C /* WOFFFileFormat.cpp */,
</span><span class="cx">                                 379919951200DDF400EA041C /* WOFFFileFormat.h */,
</span><ins>+                                CDC61DA0180867D8004B913F /* SourceBufferPrivate.h */,
+                                CD54A75E180F535000B076C9 /* MediaSourcePrivate.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = graphics;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -24944,6 +24950,7 @@
</span><span class="cx">                                 BC5C762B1497FE1400BC4775 /* PlatformEvent.h in Headers */,
</span><span class="cx">                                 BCAA487014A052530088FAC4 /* PlatformEventFactoryMac.h in Headers */,
</span><span class="cx">                                 A723F77B1484CA4C008C6DBE /* PlatformExportMacros.h in Headers */,
</span><ins>+                                7CE6CBFB187F370700D46BF5 /* FormatConverter.h in Headers */,
</ins><span class="cx">                                 935C476809AC4D4300A6AAB4 /* PlatformKeyboardEvent.h in Headers */,
</span><span class="cx">                                 0562F9611573F88F0031CA16 /* PlatformLayer.h in Headers */,
</span><span class="cx">                                 F544F78915CFB2A800AF33A8 /* PlatformLocale.h in Headers */,
</span><span class="lines">@@ -27110,6 +27117,7 @@
</span><span class="cx">                                 511EF2C817F0FD3500E4FA16 /* JSIDBOpenDBRequest.cpp in Sources */,
</span><span class="cx">                                 31313F651443B35F006E2A90 /* FilterEffectRenderer.cpp in Sources */,
</span><span class="cx">                                 49ECEB6D1499790D00CDD3A4 /* FilterOperation.cpp in Sources */,
</span><ins>+                                7CE6CBFD187F394900D46BF5 /* FormatConverter.cpp in Sources */,
</ins><span class="cx">                                 49ECEB6F1499790D00CDD3A4 /* FilterOperations.cpp in Sources */,
</span><span class="cx">                                 A8CFF04D0A154F09000A4234 /* FixedTableLayout.cpp in Sources */,
</span><span class="cx">                                 51D719B6181106E00016DC51 /* DOMWindowIndexedDatabase.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFormatConvertercppfromrev161780trunkSourceWebCoreplatformgraphicsGraphicsContext3Dcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/FormatConverter.cpp (from rev 161780, trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp) (0 => 161783)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FormatConverter.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/FormatConverter.cpp        2014-01-11 22:56:40 UTC (rev 161783)
</span><span class="lines">@@ -0,0 +1,1276 @@
</span><ins>+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Mozilla Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;config.h&quot;
+
+#if USE(3D_GRAPHICS)
+
+#include &quot;FormatConverter.h&quot;
+
+#if HAVE(ARM_NEON_INTRINSICS)
+#include &quot;GraphicsContext3DNEON.h&quot;
+#endif
+
+// Visual Studio crashes with a C1063 Fatal Error if everything is inlined.
+#if COMPILER(MSVC)
+#define ALWAYS_INLINE_EXCEPT_MSVC
+#else
+#define ALWAYS_INLINE_EXCEPT_MSVC ALWAYS_INLINE
+#endif
+
+namespace WebCore {
+
+
+// Following Float to Half-Float converion code is from the implementation of ftp://www.fox-toolkit.org/pub/fasthalffloatconversion.pdf,
+// &quot;Fast Half Float Conversions&quot; by Jeroen van der Zijp, November 2008 (Revised September 2010).
+// Specially, the basetable[512] and shifttable[512] are generated as follows:
+/*
+unsigned short basetable[512];
+unsigned char shifttable[512];
+
+void generatetables(){
+    unsigned int i;
+    int e;
+    for (i = 0; i &lt; 256; ++i){
+        e = i - 127;
+        if (e &lt; -24){ // Very small numbers map to zero
+            basetable[i | 0x000] = 0x0000;
+            basetable[i | 0x100] = 0x8000;
+            shifttable[i | 0x000] = 24;
+            shifttable[i | 0x100] = 24;
+        }
+        else if (e &lt; -14) { // Small numbers map to denorms
+            basetable[i | 0x000] = (0x0400&gt;&gt;(-e-14));
+            basetable[i | 0x100] = (0x0400&gt;&gt;(-e-14)) | 0x8000;
+            shifttable[i | 0x000] = -e-1;
+            shifttable[i | 0x100] = -e-1;
+        }
+        else if (e &lt;= 15){ // Normal numbers just lose precision
+            basetable[i | 0x000] = ((e+15)&lt;&lt;10);
+            basetable[i| 0x100] = ((e+15)&lt;&lt;10) | 0x8000;
+            shifttable[i|0x000] = 13;
+            shifttable[i|0x100] = 13;
+        }
+        else if (e&lt;128){ // Large numbers map to Infinity
+            basetable[i|0x000] = 0x7C00;
+            basetable[i|0x100] = 0xFC00;
+            shifttable[i|0x000] = 24;
+            shifttable[i|0x100] = 24;
+        }
+        else { // Infinity and NaN's stay Infinity and NaN's
+            basetable[i|0x000] = 0x7C00;
+            basetable[i|0x100] = 0xFC00;
+            shifttable[i|0x000] = 13;
+            shifttable[i|0x100] = 13;
+       }
+    }
+}
+*/
+
+unsigned short baseTable[512] = {
+0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,
+0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,
+0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,
+0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,
+0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,
+0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,
+0,      0,      0,      0,      0,      0,      0,      1,      2,      4,      8,      16,     32,     64,     128,    256,
+512,    1024,   2048,   3072,   4096,   5120,   6144,   7168,   8192,   9216,   10240,  11264,  12288,  13312,  14336,  15360,
+16384,  17408,  18432,  19456,  20480,  21504,  22528,  23552,  24576,  25600,  26624,  27648,  28672,  29696,  30720,  31744,
+31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,
+31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,
+31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,
+31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,
+31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,
+31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,
+31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,
+32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,
+32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,
+32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,
+32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,
+32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,
+32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,
+32768,  32768,  32768,  32768,  32768,  32768,  32768,  32769,  32770,  32772,  32776,  32784,  32800,  32832,  32896,  33024,
+33280,  33792,  34816,  35840,  36864,  37888,  38912,  39936,  40960,  41984,  43008,  44032,  45056,  46080,  47104,  48128,
+49152,  50176,  51200,  52224,  53248,  54272,  55296,  56320,  57344,  58368,  59392,  60416,  61440,  62464,  63488,  64512,
+64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,
+64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,
+64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,
+64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,
+64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,
+64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,
+64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512
+};
+
+unsigned char shiftTable[512] = {
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     23,     22,     21,     20,     19,     18,     17,     16,     15,
+14,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,
+13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     13,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     23,     22,     21,     20,     19,     18,     17,     16,     15,
+14,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,
+13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
+24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     13
+};
+
+inline unsigned short convertFloatToHalfFloat(float f)
+{
+    unsigned temp = *(reinterpret_cast&lt;unsigned *&gt;(&amp;f));
+    unsigned signexp = (temp &gt;&gt; 23) &amp; 0x1ff;
+    return baseTable[signexp] + ((temp &amp; 0x007fffff) &gt;&gt; shiftTable[signexp]);
+}
+
+/* BEGIN CODE SHARED WITH MOZILLA FIREFOX */
+
+// The following packing and unpacking routines are expressed in terms of function templates and inline functions to achieve generality and speedup.
+// Explicit template specializations correspond to the cases that would occur.
+// Some code are merged back from Mozilla code in http://mxr.mozilla.org/mozilla-central/source/content/canvas/src/WebGLTexelConversions.h
+
+//----------------------------------------------------------------------
+// Pixel unpacking routines.
+template&lt;int format, typename SourceType, typename DstType&gt;
+ALWAYS_INLINE void unpack(const SourceType*, DstType*, unsigned)
+{
+    ASSERT_NOT_REACHED();
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRGB8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[0];
+        destination[1] = source[1];
+        destination[2] = source[2];
+        destination[3] = 0xFF;
+        source += 3;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatBGR8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[2];
+        destination[1] = source[1];
+        destination[2] = source[0];
+        destination[3] = 0xFF;
+        source += 3;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatARGB8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[1];
+        destination[1] = source[2];
+        destination[2] = source[3];
+        destination[3] = source[0];
+        source += 4;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatABGR8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[3];
+        destination[1] = source[2];
+        destination[2] = source[1];
+        destination[3] = source[0];
+        source += 4;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatBGRA8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    const uint32_t* source32 = reinterpret_cast_ptr&lt;const uint32_t*&gt;(source);
+    uint32_t* destination32 = reinterpret_cast_ptr&lt;uint32_t*&gt;(destination);
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        uint32_t bgra = source32[i];
+#if CPU(BIG_ENDIAN)
+        uint32_t brMask = 0xff00ff00;
+        uint32_t gaMask = 0x00ff00ff;
+#else
+        uint32_t brMask = 0x00ff00ff;
+        uint32_t gaMask = 0xff00ff00;
+#endif
+        uint32_t rgba = (((bgra &gt;&gt; 16) | (bgra &lt;&lt; 16)) &amp; brMask) | (bgra &amp; gaMask);
+        destination32[i] = rgba;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRGBA5551, uint16_t, uint8_t&gt;(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+#if HAVE(ARM_NEON_INTRINSICS)
+    SIMD::unpackOneRowOfRGBA5551ToRGBA8(source, destination, pixelsPerRow);
+#endif
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        uint16_t packedValue = source[0];
+        uint8_t r = packedValue &gt;&gt; 11;
+        uint8_t g = (packedValue &gt;&gt; 6) &amp; 0x1F;
+        uint8_t b = (packedValue &gt;&gt; 1) &amp; 0x1F;
+        destination[0] = (r &lt;&lt; 3) | (r &amp; 0x7);
+        destination[1] = (g &lt;&lt; 3) | (g &amp; 0x7);
+        destination[2] = (b &lt;&lt; 3) | (b &amp; 0x7);
+        destination[3] = (packedValue &amp; 0x1) ? 0xFF : 0x0;
+        source += 1;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRGBA4444, uint16_t, uint8_t&gt;(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+#if HAVE(ARM_NEON_INTRINSICS)
+    SIMD::unpackOneRowOfRGBA4444ToRGBA8(source, destination, pixelsPerRow);
+#endif
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        uint16_t packedValue = source[0];
+        uint8_t r = packedValue &gt;&gt; 12;
+        uint8_t g = (packedValue &gt;&gt; 8) &amp; 0x0F;
+        uint8_t b = (packedValue &gt;&gt; 4) &amp; 0x0F;
+        uint8_t a = packedValue &amp; 0x0F;
+        destination[0] = r &lt;&lt; 4 | r;
+        destination[1] = g &lt;&lt; 4 | g;
+        destination[2] = b &lt;&lt; 4 | b;
+        destination[3] = a &lt;&lt; 4 | a;
+        source += 1;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRGB565, uint16_t, uint8_t&gt;(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+#if HAVE(ARM_NEON_INTRINSICS)
+    SIMD::unpackOneRowOfRGB565ToRGBA8(source, destination, pixelsPerRow);
+#endif
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        uint16_t packedValue = source[0];
+        uint8_t r = packedValue &gt;&gt; 11;
+        uint8_t g = (packedValue &gt;&gt; 5) &amp; 0x3F;
+        uint8_t b = packedValue &amp; 0x1F;
+        destination[0] = (r &lt;&lt; 3) | (r &amp; 0x7);
+        destination[1] = (g &lt;&lt; 2) | (g &amp; 0x3);
+        destination[2] = (b &lt;&lt; 3) | (b &amp; 0x7);
+        destination[3] = 0xFF;
+        source += 1;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatR8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[0];
+        destination[1] = source[0];
+        destination[2] = source[0];
+        destination[3] = 0xFF;
+        source += 1;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRA8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[0];
+        destination[1] = source[0];
+        destination[2] = source[0];
+        destination[3] = source[1];
+        source += 2;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatAR8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[1];
+        destination[1] = source[1];
+        destination[2] = source[1];
+        destination[3] = source[0];
+        source += 2;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatA8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = 0x0;
+        destination[1] = 0x0;
+        destination[2] = 0x0;
+        destination[3] = source[0];
+        source += 1;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRGBA8, uint8_t, float&gt;(const uint8_t* source, float* destination, unsigned pixelsPerRow)
+{
+    const float scaleFactor = 1.0f / 255.0f;
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[0] * scaleFactor;
+        destination[1] = source[1] * scaleFactor;
+        destination[2] = source[2] * scaleFactor;
+        destination[3] = source[3] * scaleFactor;
+        source += 4;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatBGRA8, uint8_t, float&gt;(const uint8_t* source, float* destination, unsigned pixelsPerRow)
+{
+    const float scaleFactor = 1.0f / 255.0f;
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[2] * scaleFactor;
+        destination[1] = source[1] * scaleFactor;
+        destination[2] = source[0] * scaleFactor;
+        destination[3] = source[3] * scaleFactor;
+        source += 4;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatABGR8, uint8_t, float&gt;(const uint8_t* source, float* destination, unsigned pixelsPerRow)
+{
+    const float scaleFactor = 1.0f / 255.0f;
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[3] * scaleFactor;
+        destination[1] = source[2] * scaleFactor;
+        destination[2] = source[1] * scaleFactor;
+        destination[3] = source[0] * scaleFactor;
+        source += 4;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatARGB8, uint8_t, float&gt;(const uint8_t* source, float* destination, unsigned pixelsPerRow)
+{
+    const float scaleFactor = 1.0f / 255.0f;
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[1] * scaleFactor;
+        destination[1] = source[2] * scaleFactor;
+        destination[2] = source[3] * scaleFactor;
+        destination[3] = source[0] * scaleFactor;
+        source += 4;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRGB8, uint8_t, float&gt;(const uint8_t* source, float* destination, unsigned pixelsPerRow)
+{
+    const float scaleFactor = 1.0f / 255.0f;
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[0] * scaleFactor;
+        destination[1] = source[1] * scaleFactor;
+        destination[2] = source[2] * scaleFactor;
+        destination[3] = 1;
+        source += 3;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatBGR8, uint8_t, float&gt;(const uint8_t* source, float* destination, unsigned pixelsPerRow)
+{
+    const float scaleFactor = 1.0f / 255.0f;
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[2] * scaleFactor;
+        destination[1] = source[1] * scaleFactor;
+        destination[2] = source[0] * scaleFactor;
+        destination[3] = 1;
+        source += 3;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRGB32F, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[0];
+        destination[1] = source[1];
+        destination[2] = source[2];
+        destination[3] = 1;
+        source += 3;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatR32F, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[0];
+        destination[1] = source[0];
+        destination[2] = source[0];
+        destination[3] = 1;
+        source += 1;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRA32F, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[0];
+        destination[1] = source[0];
+        destination[2] = source[0];
+        destination[3] = source[1];
+        source += 2;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatA32F, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = 0;
+        destination[1] = 0;
+        destination[2] = 0;
+        destination[3] = source[0];
+        source += 1;
+        destination += 4;
+    }
+}
+
+//----------------------------------------------------------------------
+// Pixel packing routines.
+//
+
+template&lt;int format, int alphaOp, typename SourceType, typename DstType&gt;
+ALWAYS_INLINE void pack(const SourceType*, DstType*, unsigned)
+{
+    ASSERT_NOT_REACHED();
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatA8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[3];
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[0];
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR8, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] / 255.0f;
+        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
+        destination[0] = sourceR;
+        source += 4;
+        destination += 1;
+    }
+}
+
+// FIXME: this routine is lossy and must be removed.
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR8, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
+        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
+        destination[0] = sourceR;
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[0];
+        destination[1] = source[3];
+        source += 4;
+        destination += 2;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA8, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] / 255.0f;
+        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
+        destination[0] = sourceR;
+        destination[1] = source[3];
+        source += 4;
+        destination += 2;
+    }
+}
+
+// FIXME: this routine is lossy and must be removed.
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA8, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
+        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
+        destination[0] = sourceR;
+        destination[1] = source[3];
+        source += 4;
+        destination += 2;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[0];
+        destination[1] = source[1];
+        destination[2] = source[2];
+        source += 4;
+        destination += 3;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB8, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] / 255.0f;
+        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
+        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
+        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
+        destination[0] = sourceR;
+        destination[1] = sourceG;
+        destination[2] = sourceB;
+        source += 4;
+        destination += 3;
+    }
+}
+
+// FIXME: this routine is lossy and must be removed.
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB8, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
+        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
+        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
+        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
+        destination[0] = sourceR;
+        destination[1] = sourceG;
+        destination[2] = sourceB;
+        source += 4;
+        destination += 3;
+    }
+}
+
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    memcpy(destination, source, pixelsPerRow * 4);
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA8, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] / 255.0f;
+        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
+        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
+        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
+        destination[0] = sourceR;
+        destination[1] = sourceG;
+        destination[2] = sourceB;
+        destination[3] = source[3];
+        source += 4;
+        destination += 4;
+    }
+}
+
+// FIXME: this routine is lossy and must be removed.
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA8, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
+        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
+        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
+        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
+        destination[0] = sourceR;
+        destination[1] = sourceG;
+        destination[2] = sourceB;
+        destination[3] = source[3];
+        source += 4;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA4444, GraphicsContext3D::AlphaDoNothing, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+#if HAVE(ARM_NEON_INTRINSICS)
+    SIMD::packOneRowOfRGBA8ToUnsignedShort4444(source, destination, pixelsPerRow);
+#endif
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        *destination = (((source[0] &amp; 0xF0) &lt;&lt; 8)
+                        | ((source[1] &amp; 0xF0) &lt;&lt; 4)
+                        | (source[2] &amp; 0xF0)
+                        | (source[3] &gt;&gt; 4));
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA4444, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] / 255.0f;
+        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
+        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
+        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
+        *destination = (((sourceR &amp; 0xF0) &lt;&lt; 8)
+                        | ((sourceG &amp; 0xF0) &lt;&lt; 4)
+                        | (sourceB &amp; 0xF0)
+                        | (source[3] &gt;&gt; 4));
+        source += 4;
+        destination += 1;
+    }
+}
+
+// FIXME: this routine is lossy and must be removed.
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA4444, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
+        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
+        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
+        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
+        *destination = (((sourceR &amp; 0xF0) &lt;&lt; 8)
+                        | ((sourceG &amp; 0xF0) &lt;&lt; 4)
+                        | (sourceB &amp; 0xF0)
+                        | (source[3] &gt;&gt; 4));
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA5551, GraphicsContext3D::AlphaDoNothing, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+#if HAVE(ARM_NEON_INTRINSICS)
+    SIMD::packOneRowOfRGBA8ToUnsignedShort5551(source, destination, pixelsPerRow);
+#endif
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        *destination = (((source[0] &amp; 0xF8) &lt;&lt; 8)
+                        | ((source[1] &amp; 0xF8) &lt;&lt; 3)
+                        | ((source[2] &amp; 0xF8) &gt;&gt; 2)
+                        | (source[3] &gt;&gt; 7));
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA5551, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] / 255.0f;
+        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
+        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
+        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
+        *destination = (((sourceR &amp; 0xF8) &lt;&lt; 8)
+                        | ((sourceG &amp; 0xF8) &lt;&lt; 3)
+                        | ((sourceB &amp; 0xF8) &gt;&gt; 2)
+                        | (source[3] &gt;&gt; 7));
+        source += 4;
+        destination += 1;
+    }
+}
+
+// FIXME: this routine is lossy and must be removed.
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA5551, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
+        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
+        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
+        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
+        *destination = (((sourceR &amp; 0xF8) &lt;&lt; 8)
+                        | ((sourceG &amp; 0xF8) &lt;&lt; 3)
+                        | ((sourceB &amp; 0xF8) &gt;&gt; 2)
+                        | (source[3] &gt;&gt; 7));
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB565, GraphicsContext3D::AlphaDoNothing, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+#if HAVE(ARM_NEON_INTRINSICS)
+    SIMD::packOneRowOfRGBA8ToUnsignedShort565(source, destination, pixelsPerRow);
+#endif
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        *destination = (((source[0] &amp; 0xF8) &lt;&lt; 8)
+                        | ((source[1] &amp; 0xFC) &lt;&lt; 3)
+                        | ((source[2] &amp; 0xF8) &gt;&gt; 3));
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB565, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] / 255.0f;
+        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
+        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
+        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
+        *destination = (((sourceR &amp; 0xF8) &lt;&lt; 8)
+                        | ((sourceG &amp; 0xFC) &lt;&lt; 3)
+                        | ((sourceB &amp; 0xF8) &gt;&gt; 3));
+        source += 4;
+        destination += 1;
+    }
+}
+
+// FIXME: this routine is lossy and must be removed.
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB565, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
+        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
+        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
+        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
+        *destination = (((sourceR &amp; 0xF8) &lt;&lt; 8)
+                        | ((sourceG &amp; 0xFC) &lt;&lt; 3)
+                        | ((sourceB &amp; 0xF8) &gt;&gt; 3));
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB32F, GraphicsContext3D::AlphaDoNothing, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[0];
+        destination[1] = source[1];
+        destination[2] = source[2];
+        source += 4;
+        destination += 3;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB32F, GraphicsContext3D::AlphaDoPremultiply, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3];
+        destination[0] = source[0] * scaleFactor;
+        destination[1] = source[1] * scaleFactor;
+        destination[2] = source[2] * scaleFactor;
+        source += 4;
+        destination += 3;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB32F, GraphicsContext3D::AlphaDoUnmultiply, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
+        destination[0] = source[0] * scaleFactor;
+        destination[1] = source[1] * scaleFactor;
+        destination[2] = source[2] * scaleFactor;
+        source += 4;
+        destination += 3;
+    }
+}
+
+// Used only during RGBA8 or BGRA8 -&gt; floating-point uploads.
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA32F, GraphicsContext3D::AlphaDoNothing, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    memcpy(destination, source, pixelsPerRow * 4 * sizeof(float));
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA32F, GraphicsContext3D::AlphaDoPremultiply, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3];
+        destination[0] = source[0] * scaleFactor;
+        destination[1] = source[1] * scaleFactor;
+        destination[2] = source[2] * scaleFactor;
+        destination[3] = source[3];
+        source += 4;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA32F, GraphicsContext3D::AlphaDoUnmultiply, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
+        destination[0] = source[0] * scaleFactor;
+        destination[1] = source[1] * scaleFactor;
+        destination[2] = source[2] * scaleFactor;
+        destination[3] = source[3];
+        source += 4;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatA32F, GraphicsContext3D::AlphaDoNothing, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[3];
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR32F, GraphicsContext3D::AlphaDoNothing, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[0];
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR32F, GraphicsContext3D::AlphaDoPremultiply, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3];
+        destination[0] = source[0] * scaleFactor;
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR32F, GraphicsContext3D::AlphaDoUnmultiply, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
+        destination[0] = source[0] * scaleFactor;
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA32F, GraphicsContext3D::AlphaDoNothing, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = source[0];
+        destination[1] = source[3];
+        source += 4;
+        destination += 2;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA32F, GraphicsContext3D::AlphaDoPremultiply, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3];
+        destination[0] = source[0] * scaleFactor;
+        destination[1] = source[3];
+        source += 4;
+        destination += 2;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA32F, GraphicsContext3D::AlphaDoUnmultiply, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
+{
+    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
+        destination[0] = source[0] * scaleFactor;
+        destination[1] = source[3];
+        source += 4;
+        destination += 2;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA16F, GraphicsContext3D::AlphaDoNothing, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = convertFloatToHalfFloat(source[0]);
+        destination[1] = convertFloatToHalfFloat(source[1]);
+        destination[2] = convertFloatToHalfFloat(source[2]);
+        destination[3] = convertFloatToHalfFloat(source[3]);
+        source += 4;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA16F, GraphicsContext3D::AlphaDoPremultiply, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3];
+        destination[0] = convertFloatToHalfFloat(source[0] * scaleFactor);
+        destination[1] = convertFloatToHalfFloat(source[1] * scaleFactor);
+        destination[2] = convertFloatToHalfFloat(source[2] * scaleFactor);
+        destination[3] = convertFloatToHalfFloat(source[3]);
+        source += 4;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA16F, GraphicsContext3D::AlphaDoUnmultiply, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
+        destination[0] = convertFloatToHalfFloat(source[0] * scaleFactor);
+        destination[1] = convertFloatToHalfFloat(source[1] * scaleFactor);
+        destination[2] = convertFloatToHalfFloat(source[2] * scaleFactor);
+        destination[3] = convertFloatToHalfFloat(source[3]);
+        source += 4;
+        destination += 4;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB16F, GraphicsContext3D::AlphaDoNothing, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = convertFloatToHalfFloat(source[0]);
+        destination[1] = convertFloatToHalfFloat(source[1]);
+        destination[2] = convertFloatToHalfFloat(source[2]);
+        source += 4;
+        destination += 3;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB16F, GraphicsContext3D::AlphaDoPremultiply, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3];
+        destination[0] = convertFloatToHalfFloat(source[0] * scaleFactor);
+        destination[1] = convertFloatToHalfFloat(source[1] * scaleFactor);
+        destination[2] = convertFloatToHalfFloat(source[2] * scaleFactor);
+        source += 4;
+        destination += 3;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB16F, GraphicsContext3D::AlphaDoUnmultiply, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
+        destination[0] = convertFloatToHalfFloat(source[0] * scaleFactor);
+        destination[1] = convertFloatToHalfFloat(source[1] * scaleFactor);
+        destination[2] = convertFloatToHalfFloat(source[2] * scaleFactor);
+        source += 4;
+        destination += 3;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA16F, GraphicsContext3D::AlphaDoNothing, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = convertFloatToHalfFloat(source[0]);
+        destination[1] = convertFloatToHalfFloat(source[3]);
+        source += 4;
+        destination += 2;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA16F, GraphicsContext3D::AlphaDoPremultiply, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3];
+        destination[0] = convertFloatToHalfFloat(source[0] * scaleFactor);
+        destination[1] = convertFloatToHalfFloat(source[3]);
+        source += 4;
+        destination += 2;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA16F, GraphicsContext3D::AlphaDoUnmultiply, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
+        destination[0] = convertFloatToHalfFloat(source[0] * scaleFactor);
+        destination[1] = convertFloatToHalfFloat(source[3]);
+        source += 4;
+        destination += 2;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR16F, GraphicsContext3D::AlphaDoNothing, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = convertFloatToHalfFloat(source[0]);
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR16F, GraphicsContext3D::AlphaDoPremultiply, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3];
+        destination[0] = convertFloatToHalfFloat(source[0] * scaleFactor);
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR16F, GraphicsContext3D::AlphaDoUnmultiply, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
+        destination[0] = convertFloatToHalfFloat(source[0] * scaleFactor);
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatA16F, GraphicsContext3D::AlphaDoNothing, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+{
+    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
+        destination[0] = convertFloatToHalfFloat(source[3]);
+        source += 4;
+        destination += 1;
+    }
+}
+
+template&lt;int Format&gt;
+struct IsFloatFormat {
+    static const bool Value =
+        Format == GraphicsContext3D::DataFormatRGBA32F
+        || Format == GraphicsContext3D::DataFormatRGB32F
+        || Format == GraphicsContext3D::DataFormatRA32F
+        || Format == GraphicsContext3D::DataFormatR32F
+        || Format == GraphicsContext3D::DataFormatA32F;
+};
+
+template&lt;int Format&gt;
+struct IsHalfFloatFormat {
+    static const bool Value =
+        Format == GraphicsContext3D::DataFormatRGBA16F
+        || Format == GraphicsContext3D::DataFormatRGB16F
+        || Format == GraphicsContext3D::DataFormatRA16F
+        || Format == GraphicsContext3D::DataFormatR16F
+        || Format == GraphicsContext3D::DataFormatA16F;
+};
+
+template&lt;int Format&gt;
+struct Is16bppFormat {
+    static const bool Value =
+        Format == GraphicsContext3D::DataFormatRGBA5551
+        || Format == GraphicsContext3D::DataFormatRGBA4444
+        || Format == GraphicsContext3D::DataFormatRGB565;
+};
+
+template&lt;int Format, bool IsFloat = IsFloatFormat&lt;Format&gt;::Value, bool IsHalfFloat = IsHalfFloatFormat&lt;Format&gt;::Value, bool Is16bpp = Is16bppFormat&lt;Format&gt;::Value&gt;
+struct DataTypeForFormat {
+    typedef uint8_t Type;
+};
+
+template&lt;int Format&gt;
+struct DataTypeForFormat&lt;Format, true, false, false&gt; {
+    typedef float Type;
+};
+
+template&lt;int Format&gt;
+struct DataTypeForFormat&lt;Format, false, true, false&gt; {
+    typedef uint16_t Type;
+};
+
+template&lt;int Format&gt;
+struct DataTypeForFormat&lt;Format, false, false, true&gt; {
+    typedef uint16_t Type;
+};
+
+template&lt;int Format&gt;
+struct IntermediateFormat {
+    static const int Value = (IsFloatFormat&lt;Format&gt;::Value || IsHalfFloatFormat&lt;Format&gt;::Value) ? GraphicsContext3D::DataFormatRGBA32F : GraphicsContext3D::DataFormatRGBA8;
+};
+
+
+/* END CODE SHARED WITH MOZILLA FIREFOX */
+
+void FormatConverter::convert(GraphicsContext3D::DataFormat srcFormat, GraphicsContext3D::DataFormat dstFormat, GraphicsContext3D::AlphaOp alphaOp)
+{
+#define FORMATCONVERTER_CASE_SRCFORMAT(SrcFormat) \
+    case SrcFormat: \
+        return convert&lt;SrcFormat&gt;(dstFormat, alphaOp);
+
+        switch (srcFormat) {
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatR8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatA8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatR32F)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatA32F)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRA8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRA32F)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGB8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatBGR8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGB565)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGB32F)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGBA8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatARGB8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatABGR8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatAR8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatBGRA8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGBA5551)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGBA4444)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGBA32F)
+        default:
+            ASSERT_NOT_REACHED();
+        }
+#undef FORMATCONVERTER_CASE_SRCFORMAT
+}
+
+template&lt;GraphicsContext3D::DataFormat SrcFormat&gt;
+ALWAYS_INLINE void FormatConverter::convert(GraphicsContext3D::DataFormat dstFormat, GraphicsContext3D::AlphaOp alphaOp)
+{
+#define FORMATCONVERTER_CASE_DSTFORMAT(DstFormat) \
+    case DstFormat: \
+        return convert&lt;SrcFormat, DstFormat&gt;(alphaOp);
+
+        switch (dstFormat) {
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatR8)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatR16F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatR32F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatA8)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatA16F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatA32F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRA8)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRA16F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRA32F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGB8)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGB565)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGB16F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGB32F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA8)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA5551)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA4444)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA16F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA32F)
+        default:
+            ASSERT_NOT_REACHED();
+        }
+
+#undef FORMATCONVERTER_CASE_DSTFORMAT
+}
+
+template&lt;GraphicsContext3D::DataFormat SrcFormat, GraphicsContext3D::DataFormat DstFormat&gt;
+ALWAYS_INLINE void FormatConverter::convert(GraphicsContext3D::AlphaOp alphaOp)
+{
+#define FORMATCONVERTER_CASE_ALPHAOP(alphaOp) \
+    case alphaOp: \
+        return convert&lt;SrcFormat, DstFormat, alphaOp&gt;();
+
+        switch (alphaOp) {
+            FORMATCONVERTER_CASE_ALPHAOP(GraphicsContext3D::AlphaDoNothing)
+            FORMATCONVERTER_CASE_ALPHAOP(GraphicsContext3D::AlphaDoPremultiply)
+            FORMATCONVERTER_CASE_ALPHAOP(GraphicsContext3D::AlphaDoUnmultiply)
+        default:
+            ASSERT_NOT_REACHED();
+        }
+#undef FORMATCONVERTER_CASE_ALPHAOP
+}
+
+template&lt;GraphicsContext3D::DataFormat SrcFormat, GraphicsContext3D::DataFormat DstFormat, GraphicsContext3D::AlphaOp alphaOp&gt;
+ALWAYS_INLINE_EXCEPT_MSVC void FormatConverter::convert()
+{
+    // Many instantiations of this template function will never be entered, so we try
+    // to return immediately in these cases to avoid the compiler to generate useless code.
+    if (SrcFormat == DstFormat &amp;&amp; alphaOp == GraphicsContext3D::AlphaDoNothing) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
+    if (!IsFloatFormat&lt;DstFormat&gt;::Value &amp;&amp; IsFloatFormat&lt;SrcFormat&gt;::Value) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
+
+    // Only textures uploaded from DOM elements or ImageData can allow DstFormat != SrcFormat.
+    const bool srcFormatComesFromDOMElementOrImageData = GraphicsContext3D::srcFormatComesFromDOMElementOrImageData(SrcFormat);
+    if (!srcFormatComesFromDOMElementOrImageData &amp;&amp; SrcFormat != DstFormat) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
+    // Likewise, only textures uploaded from DOM elements or ImageData can possibly have to be unpremultiplied.
+    if (!srcFormatComesFromDOMElementOrImageData &amp;&amp; alphaOp == GraphicsContext3D::AlphaDoUnmultiply) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
+    if ((!GraphicsContext3D::hasAlpha(SrcFormat) || !GraphicsContext3D::hasColor(SrcFormat) || !GraphicsContext3D::hasColor(DstFormat)) &amp;&amp; alphaOp != GraphicsContext3D::AlphaDoNothing) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
+
+    typedef typename DataTypeForFormat&lt;SrcFormat&gt;::Type SrcType;
+    typedef typename DataTypeForFormat&lt;DstFormat&gt;::Type DstType;
+    const int IntermediateSrcFormat = IntermediateFormat&lt;DstFormat&gt;::Value;
+    typedef typename DataTypeForFormat&lt;IntermediateSrcFormat&gt;::Type IntermediateSrcType;
+    const ptrdiff_t srcStrideInElements = m_srcStride / sizeof(SrcType);
+    const ptrdiff_t dstStrideInElements = m_dstStride / sizeof(DstType);
+    const bool trivialUnpack = (SrcFormat == GraphicsContext3D::DataFormatRGBA8 &amp;&amp; !IsFloatFormat&lt;DstFormat&gt;::Value &amp;&amp; !IsHalfFloatFormat&lt;DstFormat&gt;::Value) || SrcFormat == GraphicsContext3D::DataFormatRGBA32F;
+    const bool trivialPack = (DstFormat == GraphicsContext3D::DataFormatRGBA8 || DstFormat == GraphicsContext3D::DataFormatRGBA32F) &amp;&amp; alphaOp == GraphicsContext3D::AlphaDoNothing &amp;&amp; m_dstStride &gt; 0;
+    ASSERT(!trivialUnpack || !trivialPack);
+
+    const SrcType *srcRowStart = static_cast&lt;const SrcType*&gt;(m_srcStart);
+    DstType* dstRowStart = static_cast&lt;DstType*&gt;(m_dstStart);
+    if (!trivialUnpack &amp;&amp; trivialPack) {
+        for (size_t i = 0; i &lt; m_height; ++i) {
+            unpack&lt;SrcFormat&gt;(srcRowStart, dstRowStart, m_width);
+            srcRowStart += srcStrideInElements;
+            dstRowStart += dstStrideInElements;
+        }
+    } else if (!trivialUnpack &amp;&amp; !trivialPack) {
+        for (size_t i = 0; i &lt; m_height; ++i) {
+            unpack&lt;SrcFormat&gt;(srcRowStart, reinterpret_cast_ptr&lt;IntermediateSrcType*&gt;(m_unpackedIntermediateSrcData.get()), m_width);
+            pack&lt;DstFormat, alphaOp&gt;(reinterpret_cast_ptr&lt;IntermediateSrcType*&gt;(m_unpackedIntermediateSrcData.get()), dstRowStart, m_width);
+            srcRowStart += srcStrideInElements;
+            dstRowStart += dstStrideInElements;
+        }
+    } else {
+        for (size_t i = 0; i &lt; m_height; ++i) {
+            pack&lt;DstFormat, alphaOp&gt;(srcRowStart, dstRowStart, m_width);
+            srcRowStart += srcStrideInElements;
+            dstRowStart += dstStrideInElements;
+        }
+    }
+    m_success = true;
+    return;
+}
+
+} // namespace WebCore
+
+#endif // USE(3D_GRAPHICS)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFormatConverterh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/FormatConverter.h (0 => 161783)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FormatConverter.h                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/FormatConverter.h        2014-01-11 22:56:40 UTC (rev 161783)
</span><span class="lines">@@ -0,0 +1,78 @@
</span><ins>+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Mozilla Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include &quot;config.h&quot;
+
+#if USE(3D_GRAPHICS)
+
+#include &quot;GraphicsContext3D.h&quot;
+#include &lt;wtf/StdLibExtras.h&gt;
+
+namespace WebCore {
+
+class FormatConverter {
+public:
+    FormatConverter(unsigned width, unsigned height, const void* srcStart, void* dstStart, int srcStride, int dstStride)
+        : m_width(width)
+        , m_height(height)
+        , m_srcStart(srcStart)
+        , m_dstStart(dstStart)
+        , m_srcStride(srcStride)
+        , m_dstStride(dstStride)
+        , m_success(false)
+    {
+        const unsigned MaxNumberOfComponents = 4;
+        const unsigned MaxBytesPerComponent  = 4;
+        m_unpackedIntermediateSrcData = std::make_unique&lt;uint8_t[]&gt;(m_width * MaxNumberOfComponents * MaxBytesPerComponent);
+
+        ASSERT(m_unpackedIntermediateSrcData.get());
+    }
+
+    void convert(GraphicsContext3D::DataFormat srcFormat, GraphicsContext3D::DataFormat dstFormat, GraphicsContext3D::AlphaOp);
+    bool success() const { return m_success; }
+
+private:
+    template&lt;GraphicsContext3D::DataFormat SrcFormat&gt;
+    ALWAYS_INLINE void convert(GraphicsContext3D::DataFormat dstFormat, GraphicsContext3D::AlphaOp);
+
+    template&lt;GraphicsContext3D::DataFormat SrcFormat, GraphicsContext3D::DataFormat DstFormat&gt;
+    ALWAYS_INLINE void convert(GraphicsContext3D::AlphaOp);
+
+    template&lt;GraphicsContext3D::DataFormat SrcFormat, GraphicsContext3D::DataFormat DstFormat, GraphicsContext3D::AlphaOp alphaOp&gt;
+    ALWAYS_INLINE void convert();
+
+    const unsigned m_width, m_height;
+    const void* const m_srcStart;
+    void* const m_dstStart;
+    const int m_srcStride, m_dstStride;
+    bool m_success;
+    std::unique_ptr&lt;uint8_t[]&gt; m_unpackedIntermediateSrcData;
+};
+
+} // namespace WebCore
+
+#endif // USE(3D_GRAPHICS)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContext3Dcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp (161782 => 161783)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp        2014-01-11 21:58:23 UTC (rev 161782)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp        2014-01-11 22:56:40 UTC (rev 161783)
</span><span class="lines">@@ -32,24 +32,11 @@
</span><span class="cx"> #include &quot;GraphicsContext3D.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Extensions3D.h&quot;
</span><ins>+#include &quot;FormatConverter.h&quot;
</ins><span class="cx"> #include &quot;Image.h&quot;
</span><span class="cx"> #include &quot;ImageData.h&quot;
</span><span class="cx"> #include &quot;ImageObserver.h&quot;
</span><span class="cx"> 
</span><del>-#if HAVE(ARM_NEON_INTRINSICS)
-#include &quot;GraphicsContext3DNEON.h&quot;
-#endif
-
-#include &lt;runtime/ArrayBufferView.h&gt;
-#include &lt;wtf/StdLibExtras.h&gt;
-
-// Visual Studio crashes with a C1063 Fatal Error if everything is inlined.
-#if COMPILER(MSVC)
-#define ALWAYS_INLINE_EXCEPT_MSVC
-#else
-#define ALWAYS_INLINE_EXCEPT_MSVC ALWAYS_INLINE
-#endif
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> namespace {
</span><span class="lines">@@ -159,10 +146,7 @@
</span><span class="cx">     return texImage2D(target, level, internalformat, width, height, border, format, type, zero.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GraphicsContext3D::computeFormatAndTypeParameters(GC3Denum format,
-                                                       GC3Denum type,
-                                                       unsigned int* componentsPerPixel,
-                                                       unsigned int* bytesPerComponent)
</del><ins>+bool GraphicsContext3D::computeFormatAndTypeParameters(GC3Denum format, GC3Denum type, unsigned int* componentsPerPixel, unsigned int* bytesPerComponent)
</ins><span class="cx"> {
</span><span class="cx">     switch (format) {
</span><span class="cx">     case GraphicsContext3D::ALPHA:
</span><span class="lines">@@ -213,8 +197,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-GC3Denum GraphicsContext3D::computeImageSizeInBytes(GC3Denum format, GC3Denum type, GC3Dsizei width, GC3Dsizei height, GC3Dint alignment,
-                                                    unsigned int* imageSizeInBytes, unsigned int* paddingInBytes)
</del><ins>+GC3Denum GraphicsContext3D::computeImageSizeInBytes(GC3Denum format, GC3Denum type, GC3Dsizei width, GC3Dsizei height, GC3Dint alignment, unsigned int* imageSizeInBytes, unsigned int* paddingInBytes)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(imageSizeInBytes);
</span><span class="cx">     ASSERT(alignment == 1 || alignment == 2 || alignment == 4 || alignment == 8);
</span><span class="lines">@@ -258,18 +241,7 @@
</span><span class="cx">     m_extractSucceeded = extractImage(premultiplyAlpha, ignoreGammaAndColorProfile);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GraphicsContext3D::packImageData(
-    Image* image,
-    const void* pixels,
-    GC3Denum format,
-    GC3Denum type,
-    bool flipY,
-    AlphaOp alphaOp,
-    DataFormat sourceFormat,
-    unsigned width,
-    unsigned height,
-    unsigned sourceUnpackAlignment,
-    Vector&lt;uint8_t&gt;&amp; data)
</del><ins>+bool GraphicsContext3D::packImageData( Image* image, const void* pixels, GC3Denum format, GC3Denum type, bool flipY, AlphaOp alphaOp, DataFormat sourceFormat, unsigned width, unsigned height, unsigned sourceUnpackAlignment, Vector&lt;uint8_t&gt;&amp; data)
</ins><span class="cx"> {
</span><span class="cx">     if (!pixels)
</span><span class="cx">         return false;
</span><span class="lines">@@ -282,17 +254,12 @@
</span><span class="cx"> 
</span><span class="cx">     if (!packPixels(reinterpret_cast&lt;const uint8_t*&gt;(pixels), sourceFormat, width, height, sourceUnpackAlignment, format, type, alphaOp, data.data(), flipY))
</span><span class="cx">         return false;
</span><del>-    if (ImageObserver *observer = image-&gt;imageObserver())
</del><ins>+    if (ImageObserver* observer = image-&gt;imageObserver())
</ins><span class="cx">         observer-&gt;didDraw(image);
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GraphicsContext3D::extractImageData(ImageData* imageData,
-                                         GC3Denum format,
-                                         GC3Denum type,
-                                         bool flipY,
-                                         bool premultiplyAlpha,
-                                         Vector&lt;uint8_t&gt;&amp; data)
</del><ins>+bool GraphicsContext3D::extractImageData(ImageData* imageData, GC3Denum format, GC3Denum type, bool flipY, bool premultiplyAlpha, Vector&lt;uint8_t&gt;&amp; data)
</ins><span class="cx"> {
</span><span class="cx">     if (!imageData)
</span><span class="cx">         return false;
</span><span class="lines">@@ -311,21 +278,14 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GraphicsContext3D::extractTextureData(unsigned int width, unsigned int height,
-                                           GC3Denum format, GC3Denum type,
-                                           unsigned int unpackAlignment,
-                                           bool flipY, bool premultiplyAlpha,
-                                           const void* pixels,
-                                           Vector&lt;uint8_t&gt;&amp; data)
</del><ins>+bool GraphicsContext3D::extractTextureData(unsigned int width, unsigned int height, GC3Denum format, GC3Denum type, unsigned int unpackAlignment, bool flipY, bool premultiplyAlpha, const void* pixels, Vector&lt;uint8_t&gt;&amp; data)
</ins><span class="cx"> {
</span><span class="cx">     // Assumes format, type, etc. have already been validated.
</span><span class="cx">     DataFormat sourceDataFormat = getDataFormat(format, type);
</span><span class="cx"> 
</span><span class="cx">     // Resize the output buffer.
</span><span class="cx">     unsigned int componentsPerPixel, bytesPerComponent;
</span><del>-    if (!computeFormatAndTypeParameters(format, type,
-                                        &amp;componentsPerPixel,
-                                        &amp;bytesPerComponent))
</del><ins>+    if (!computeFormatAndTypeParameters(format, type, &amp;componentsPerPixel, &amp;bytesPerComponent))
</ins><span class="cx">         return false;
</span><span class="cx">     unsigned int bytesPerPixel = componentsPerPixel * bytesPerComponent;
</span><span class="cx">     data.resize(width * height * bytesPerPixel);
</span><span class="lines">@@ -336,1127 +296,6 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-namespace {
-
-// Following Float to Half-Float converion code is from the implementation of ftp://www.fox-toolkit.org/pub/fasthalffloatconversion.pdf,
-// &quot;Fast Half Float Conversions&quot; by Jeroen van der Zijp, November 2008 (Revised September 2010).
-// Specially, the basetable[512] and shifttable[512] are generated as follows:
-/*
-unsigned short basetable[512];
-unsigned char shifttable[512];
-
-void generatetables(){
-    unsigned int i;
-    int e;
-    for (i = 0; i &lt; 256; ++i){
-        e = i - 127;
-        if (e &lt; -24){ // Very small numbers map to zero
-            basetable[i | 0x000] = 0x0000;
-            basetable[i | 0x100] = 0x8000;
-            shifttable[i | 0x000] = 24;
-            shifttable[i | 0x100] = 24;
-        }
-        else if (e &lt; -14) { // Small numbers map to denorms
-            basetable[i | 0x000] = (0x0400&gt;&gt;(-e-14));
-            basetable[i | 0x100] = (0x0400&gt;&gt;(-e-14)) | 0x8000;
-            shifttable[i | 0x000] = -e-1;
-            shifttable[i | 0x100] = -e-1;
-        }
-        else if (e &lt;= 15){ // Normal numbers just lose precision
-            basetable[i | 0x000] = ((e+15)&lt;&lt;10);
-            basetable[i| 0x100] = ((e+15)&lt;&lt;10) | 0x8000;
-            shifttable[i|0x000] = 13;
-            shifttable[i|0x100] = 13;
-        }
-        else if (e&lt;128){ // Large numbers map to Infinity
-            basetable[i|0x000] = 0x7C00;
-            basetable[i|0x100] = 0xFC00;
-            shifttable[i|0x000] = 24;
-            shifttable[i|0x100] = 24;
-        }
-        else { // Infinity and NaN's stay Infinity and NaN's
-            basetable[i|0x000] = 0x7C00;
-            basetable[i|0x100] = 0xFC00;
-            shifttable[i|0x000] = 13;
-            shifttable[i|0x100] = 13;
-       }
-    }
-}
-*/
-
-unsigned short baseTable[512] = {
-0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,
-0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,
-0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,
-0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,
-0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,
-0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,
-0,      0,      0,      0,      0,      0,      0,      1,      2,      4,      8,      16,     32,     64,     128,    256,
-512,    1024,   2048,   3072,   4096,   5120,   6144,   7168,   8192,   9216,   10240,  11264,  12288,  13312,  14336,  15360,
-16384,  17408,  18432,  19456,  20480,  21504,  22528,  23552,  24576,  25600,  26624,  27648,  28672,  29696,  30720,  31744,
-31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,
-31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,
-31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,
-31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,
-31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,
-31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,
-31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,  31744,
-32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,
-32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,
-32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,
-32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,
-32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,
-32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,  32768,
-32768,  32768,  32768,  32768,  32768,  32768,  32768,  32769,  32770,  32772,  32776,  32784,  32800,  32832,  32896,  33024,
-33280,  33792,  34816,  35840,  36864,  37888,  38912,  39936,  40960,  41984,  43008,  44032,  45056,  46080,  47104,  48128,
-49152,  50176,  51200,  52224,  53248,  54272,  55296,  56320,  57344,  58368,  59392,  60416,  61440,  62464,  63488,  64512,
-64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,
-64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,
-64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,
-64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,
-64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,
-64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,
-64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512,  64512
-};
-
-unsigned char shiftTable[512] = {
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     23,     22,     21,     20,     19,     18,     17,     16,     15,
-14,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,
-13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     13,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     23,     22,     21,     20,     19,     18,     17,     16,     15,
-14,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,
-13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     13,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,
-24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     24,     13
-};
-
-unsigned short convertFloatToHalfFloat(float f)
-{
-    unsigned temp = *(reinterpret_cast&lt;unsigned *&gt;(&amp;f));
-    unsigned signexp = (temp &gt;&gt; 23) &amp; 0x1ff;
-    return baseTable[signexp] + ((temp &amp; 0x007fffff) &gt;&gt; shiftTable[signexp]);
-}
-
-/* BEGIN CODE SHARED WITH MOZILLA FIREFOX */
-
-// The following packing and unpacking routines are expressed in terms of function templates and inline functions to achieve generality and speedup.
-// Explicit template specializations correspond to the cases that would occur.
-// Some code are merged back from Mozilla code in http://mxr.mozilla.org/mozilla-central/source/content/canvas/src/WebGLTexelConversions.h
-
-//----------------------------------------------------------------------
-// Pixel unpacking routines.
-template&lt;int format, typename SourceType, typename DstType&gt;
-ALWAYS_INLINE void unpack(const SourceType*, DstType*, unsigned)
-{
-    ASSERT_NOT_REACHED();
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRGB8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[0];
-        destination[1] = source[1];
-        destination[2] = source[2];
-        destination[3] = 0xFF;
-        source += 3;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatBGR8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[2];
-        destination[1] = source[1];
-        destination[2] = source[0];
-        destination[3] = 0xFF;
-        source += 3;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatARGB8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[1];
-        destination[1] = source[2];
-        destination[2] = source[3];
-        destination[3] = source[0];
-        source += 4;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatABGR8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[3];
-        destination[1] = source[2];
-        destination[2] = source[1];
-        destination[3] = source[0];
-        source += 4;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatBGRA8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    const uint32_t* source32 = reinterpret_cast_ptr&lt;const uint32_t*&gt;(source);
-    uint32_t* destination32 = reinterpret_cast_ptr&lt;uint32_t*&gt;(destination);
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        uint32_t bgra = source32[i];
-#if CPU(BIG_ENDIAN)
-        uint32_t brMask = 0xff00ff00;
-        uint32_t gaMask = 0x00ff00ff;
-#else
-        uint32_t brMask = 0x00ff00ff;
-        uint32_t gaMask = 0xff00ff00;
-#endif
-        uint32_t rgba = (((bgra &gt;&gt; 16) | (bgra &lt;&lt; 16)) &amp; brMask) | (bgra &amp; gaMask);
-        destination32[i] = rgba;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRGBA5551, uint16_t, uint8_t&gt;(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-#if HAVE(ARM_NEON_INTRINSICS)
-    SIMD::unpackOneRowOfRGBA5551ToRGBA8(source, destination, pixelsPerRow);
-#endif
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        uint16_t packedValue = source[0];
-        uint8_t r = packedValue &gt;&gt; 11;
-        uint8_t g = (packedValue &gt;&gt; 6) &amp; 0x1F;
-        uint8_t b = (packedValue &gt;&gt; 1) &amp; 0x1F;
-        destination[0] = (r &lt;&lt; 3) | (r &amp; 0x7);
-        destination[1] = (g &lt;&lt; 3) | (g &amp; 0x7);
-        destination[2] = (b &lt;&lt; 3) | (b &amp; 0x7);
-        destination[3] = (packedValue &amp; 0x1) ? 0xFF : 0x0;
-        source += 1;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRGBA4444, uint16_t, uint8_t&gt;(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-#if HAVE(ARM_NEON_INTRINSICS)
-    SIMD::unpackOneRowOfRGBA4444ToRGBA8(source, destination, pixelsPerRow);
-#endif
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        uint16_t packedValue = source[0];
-        uint8_t r = packedValue &gt;&gt; 12;
-        uint8_t g = (packedValue &gt;&gt; 8) &amp; 0x0F;
-        uint8_t b = (packedValue &gt;&gt; 4) &amp; 0x0F;
-        uint8_t a = packedValue &amp; 0x0F;
-        destination[0] = r &lt;&lt; 4 | r;
-        destination[1] = g &lt;&lt; 4 | g;
-        destination[2] = b &lt;&lt; 4 | b;
-        destination[3] = a &lt;&lt; 4 | a;
-        source += 1;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRGB565, uint16_t, uint8_t&gt;(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-#if HAVE(ARM_NEON_INTRINSICS)
-    SIMD::unpackOneRowOfRGB565ToRGBA8(source, destination, pixelsPerRow);
-#endif
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        uint16_t packedValue = source[0];
-        uint8_t r = packedValue &gt;&gt; 11;
-        uint8_t g = (packedValue &gt;&gt; 5) &amp; 0x3F;
-        uint8_t b = packedValue &amp; 0x1F;
-        destination[0] = (r &lt;&lt; 3) | (r &amp; 0x7);
-        destination[1] = (g &lt;&lt; 2) | (g &amp; 0x3);
-        destination[2] = (b &lt;&lt; 3) | (b &amp; 0x7);
-        destination[3] = 0xFF;
-        source += 1;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatR8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[0];
-        destination[1] = source[0];
-        destination[2] = source[0];
-        destination[3] = 0xFF;
-        source += 1;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRA8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[0];
-        destination[1] = source[0];
-        destination[2] = source[0];
-        destination[3] = source[1];
-        source += 2;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatAR8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[1];
-        destination[1] = source[1];
-        destination[2] = source[1];
-        destination[3] = source[0];
-        source += 2;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatA8, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = 0x0;
-        destination[1] = 0x0;
-        destination[2] = 0x0;
-        destination[3] = source[0];
-        source += 1;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRGBA8, uint8_t, float&gt;(const uint8_t* source, float* destination, unsigned pixelsPerRow)
-{
-    const float scaleFactor = 1.0f / 255.0f;
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[0] * scaleFactor;
-        destination[1] = source[1] * scaleFactor;
-        destination[2] = source[2] * scaleFactor;
-        destination[3] = source[3] * scaleFactor;
-        source += 4;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatBGRA8, uint8_t, float&gt;(const uint8_t* source, float* destination, unsigned pixelsPerRow)
-{
-    const float scaleFactor = 1.0f / 255.0f;
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[2] * scaleFactor;
-        destination[1] = source[1] * scaleFactor;
-        destination[2] = source[0] * scaleFactor;
-        destination[3] = source[3] * scaleFactor;
-        source += 4;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatABGR8, uint8_t, float&gt;(const uint8_t* source, float* destination, unsigned pixelsPerRow)
-{
-    const float scaleFactor = 1.0f / 255.0f;
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[3] * scaleFactor;
-        destination[1] = source[2] * scaleFactor;
-        destination[2] = source[1] * scaleFactor;
-        destination[3] = source[0] * scaleFactor;
-        source += 4;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatARGB8, uint8_t, float&gt;(const uint8_t* source, float* destination, unsigned pixelsPerRow)
-{
-    const float scaleFactor = 1.0f / 255.0f;
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[1] * scaleFactor;
-        destination[1] = source[2] * scaleFactor;
-        destination[2] = source[3] * scaleFactor;
-        destination[3] = source[0] * scaleFactor;
-        source += 4;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRGB8, uint8_t, float&gt;(const uint8_t* source, float* destination, unsigned pixelsPerRow)
-{
-    const float scaleFactor = 1.0f / 255.0f;
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[0] * scaleFactor;
-        destination[1] = source[1] * scaleFactor;
-        destination[2] = source[2] * scaleFactor;
-        destination[3] = 1;
-        source += 3;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatBGR8, uint8_t, float&gt;(const uint8_t* source, float* destination, unsigned pixelsPerRow)
-{
-    const float scaleFactor = 1.0f / 255.0f;
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[2] * scaleFactor;
-        destination[1] = source[1] * scaleFactor;
-        destination[2] = source[0] * scaleFactor;
-        destination[3] = 1;
-        source += 3;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRGB32F, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[0];
-        destination[1] = source[1];
-        destination[2] = source[2];
-        destination[3] = 1;
-        source += 3;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatR32F, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[0];
-        destination[1] = source[0];
-        destination[2] = source[0];
-        destination[3] = 1;
-        source += 1;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatRA32F, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[0];
-        destination[1] = source[0];
-        destination[2] = source[0];
-        destination[3] = source[1];
-        source += 2;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void unpack&lt;GraphicsContext3D::DataFormatA32F, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = 0;
-        destination[1] = 0;
-        destination[2] = 0;
-        destination[3] = source[0];
-        source += 1;
-        destination += 4;
-    }
-}
-
-//----------------------------------------------------------------------
-// Pixel packing routines.
-//
-
-template&lt;int format, int alphaOp, typename SourceType, typename DstType&gt;
-ALWAYS_INLINE void pack(const SourceType*, DstType*, unsigned)
-{
-    ASSERT_NOT_REACHED();
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatA8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[3];
-        source += 4;
-        destination += 1;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[0];
-        source += 4;
-        destination += 1;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR8, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] / 255.0f;
-        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
-        destination[0] = sourceR;
-        source += 4;
-        destination += 1;
-    }
-}
-
-// FIXME: this routine is lossy and must be removed.
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR8, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
-        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
-        destination[0] = sourceR;
-        source += 4;
-        destination += 1;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[0];
-        destination[1] = source[3];
-        source += 4;
-        destination += 2;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA8, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] / 255.0f;
-        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
-        destination[0] = sourceR;
-        destination[1] = source[3];
-        source += 4;
-        destination += 2;
-    }
-}
-
-// FIXME: this routine is lossy and must be removed.
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA8, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
-        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
-        destination[0] = sourceR;
-        destination[1] = source[3];
-        source += 4;
-        destination += 2;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[0];
-        destination[1] = source[1];
-        destination[2] = source[2];
-        source += 4;
-        destination += 3;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB8, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] / 255.0f;
-        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
-        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
-        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
-        destination[0] = sourceR;
-        destination[1] = sourceG;
-        destination[2] = sourceB;
-        source += 4;
-        destination += 3;
-    }
-}
-
-// FIXME: this routine is lossy and must be removed.
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB8, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
-        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
-        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
-        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
-        destination[0] = sourceR;
-        destination[1] = sourceG;
-        destination[2] = sourceB;
-        source += 4;
-        destination += 3;
-    }
-}
-
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    memcpy(destination, source, pixelsPerRow * 4);
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA8, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] / 255.0f;
-        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
-        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
-        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
-        destination[0] = sourceR;
-        destination[1] = sourceG;
-        destination[2] = sourceB;
-        destination[3] = source[3];
-        source += 4;
-        destination += 4;
-    }
-}
-
-// FIXME: this routine is lossy and must be removed.
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA8, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint8_t&gt;(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
-        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
-        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
-        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
-        destination[0] = sourceR;
-        destination[1] = sourceG;
-        destination[2] = sourceB;
-        destination[3] = source[3];
-        source += 4;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA4444, GraphicsContext3D::AlphaDoNothing, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-#if HAVE(ARM_NEON_INTRINSICS)
-    SIMD::packOneRowOfRGBA8ToUnsignedShort4444(source, destination, pixelsPerRow);
-#endif
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        *destination = (((source[0] &amp; 0xF0) &lt;&lt; 8)
-                        | ((source[1] &amp; 0xF0) &lt;&lt; 4)
-                        | (source[2] &amp; 0xF0)
-                        | (source[3] &gt;&gt; 4));
-        source += 4;
-        destination += 1;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA4444, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] / 255.0f;
-        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
-        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
-        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
-        *destination = (((sourceR &amp; 0xF0) &lt;&lt; 8)
-                        | ((sourceG &amp; 0xF0) &lt;&lt; 4)
-                        | (sourceB &amp; 0xF0)
-                        | (source[3] &gt;&gt; 4));
-        source += 4;
-        destination += 1;
-    }
-}
-
-// FIXME: this routine is lossy and must be removed.
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA4444, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
-        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
-        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
-        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
-        *destination = (((sourceR &amp; 0xF0) &lt;&lt; 8)
-                        | ((sourceG &amp; 0xF0) &lt;&lt; 4)
-                        | (sourceB &amp; 0xF0)
-                        | (source[3] &gt;&gt; 4));
-        source += 4;
-        destination += 1;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA5551, GraphicsContext3D::AlphaDoNothing, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-#if HAVE(ARM_NEON_INTRINSICS)
-    SIMD::packOneRowOfRGBA8ToUnsignedShort5551(source, destination, pixelsPerRow);
-#endif
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        *destination = (((source[0] &amp; 0xF8) &lt;&lt; 8)
-                        | ((source[1] &amp; 0xF8) &lt;&lt; 3)
-                        | ((source[2] &amp; 0xF8) &gt;&gt; 2)
-                        | (source[3] &gt;&gt; 7));
-        source += 4;
-        destination += 1;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA5551, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] / 255.0f;
-        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
-        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
-        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
-        *destination = (((sourceR &amp; 0xF8) &lt;&lt; 8)
-                        | ((sourceG &amp; 0xF8) &lt;&lt; 3)
-                        | ((sourceB &amp; 0xF8) &gt;&gt; 2)
-                        | (source[3] &gt;&gt; 7));
-        source += 4;
-        destination += 1;
-    }
-}
-
-// FIXME: this routine is lossy and must be removed.
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA5551, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
-        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
-        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
-        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
-        *destination = (((sourceR &amp; 0xF8) &lt;&lt; 8)
-                        | ((sourceG &amp; 0xF8) &lt;&lt; 3)
-                        | ((sourceB &amp; 0xF8) &gt;&gt; 2)
-                        | (source[3] &gt;&gt; 7));
-        source += 4;
-        destination += 1;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB565, GraphicsContext3D::AlphaDoNothing, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-#if HAVE(ARM_NEON_INTRINSICS)
-    SIMD::packOneRowOfRGBA8ToUnsignedShort565(source, destination, pixelsPerRow);
-#endif
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        *destination = (((source[0] &amp; 0xF8) &lt;&lt; 8)
-                        | ((source[1] &amp; 0xFC) &lt;&lt; 3)
-                        | ((source[2] &amp; 0xF8) &gt;&gt; 3));
-        source += 4;
-        destination += 1;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB565, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] / 255.0f;
-        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
-        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
-        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
-        *destination = (((sourceR &amp; 0xF8) &lt;&lt; 8)
-                        | ((sourceG &amp; 0xFC) &lt;&lt; 3)
-                        | ((sourceB &amp; 0xF8) &gt;&gt; 3));
-        source += 4;
-        destination += 1;
-    }
-}
-
-// FIXME: this routine is lossy and must be removed.
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB565, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint16_t&gt;(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
-        uint8_t sourceR = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[0]) * scaleFactor);
-        uint8_t sourceG = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[1]) * scaleFactor);
-        uint8_t sourceB = static_cast&lt;uint8_t&gt;(static_cast&lt;float&gt;(source[2]) * scaleFactor);
-        *destination = (((sourceR &amp; 0xF8) &lt;&lt; 8)
-                        | ((sourceG &amp; 0xFC) &lt;&lt; 3)
-                        | ((sourceB &amp; 0xF8) &gt;&gt; 3));
-        source += 4;
-        destination += 1;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB32F, GraphicsContext3D::AlphaDoNothing, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[0];
-        destination[1] = source[1];
-        destination[2] = source[2];
-        source += 4;
-        destination += 3;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB32F, GraphicsContext3D::AlphaDoPremultiply, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3];
-        destination[0] = source[0] * scaleFactor;
-        destination[1] = source[1] * scaleFactor;
-        destination[2] = source[2] * scaleFactor;
-        source += 4;
-        destination += 3;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB32F, GraphicsContext3D::AlphaDoUnmultiply, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
-        destination[0] = source[0] * scaleFactor;
-        destination[1] = source[1] * scaleFactor;
-        destination[2] = source[2] * scaleFactor;
-        source += 4;
-        destination += 3;
-    }
-}
-
-// Used only during RGBA8 or BGRA8 -&gt; floating-point uploads.
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA32F, GraphicsContext3D::AlphaDoNothing, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    memcpy(destination, source, pixelsPerRow * 4 * sizeof(float));
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA32F, GraphicsContext3D::AlphaDoPremultiply, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3];
-        destination[0] = source[0] * scaleFactor;
-        destination[1] = source[1] * scaleFactor;
-        destination[2] = source[2] * scaleFactor;
-        destination[3] = source[3];
-        source += 4;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA32F, GraphicsContext3D::AlphaDoUnmultiply, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
-        destination[0] = source[0] * scaleFactor;
-        destination[1] = source[1] * scaleFactor;
-        destination[2] = source[2] * scaleFactor;
-        destination[3] = source[3];
-        source += 4;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatA32F, GraphicsContext3D::AlphaDoNothing, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[3];
-        source += 4;
-        destination += 1;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR32F, GraphicsContext3D::AlphaDoNothing, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[0];
-        source += 4;
-        destination += 1;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR32F, GraphicsContext3D::AlphaDoPremultiply, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3];
-        destination[0] = source[0] * scaleFactor;
-        source += 4;
-        destination += 1;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR32F, GraphicsContext3D::AlphaDoUnmultiply, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
-        destination[0] = source[0] * scaleFactor;
-        source += 4;
-        destination += 1;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA32F, GraphicsContext3D::AlphaDoNothing, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = source[0];
-        destination[1] = source[3];
-        source += 4;
-        destination += 2;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA32F, GraphicsContext3D::AlphaDoPremultiply, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3];
-        destination[0] = source[0] * scaleFactor;
-        destination[1] = source[3];
-        source += 4;
-        destination += 2;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA32F, GraphicsContext3D::AlphaDoUnmultiply, float, float&gt;(const float* source, float* destination, unsigned pixelsPerRow)
-{
-    for (unsigned int i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
-        destination[0] = source[0] * scaleFactor;
-        destination[1] = source[3];
-        source += 4;
-        destination += 2;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA16F, GraphicsContext3D::AlphaDoNothing, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = convertFloatToHalfFloat(source[0]);
-        destination[1] = convertFloatToHalfFloat(source[1]);
-        destination[2] = convertFloatToHalfFloat(source[2]);
-        destination[3] = convertFloatToHalfFloat(source[3]);
-        source += 4;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA16F, GraphicsContext3D::AlphaDoPremultiply, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3];
-        destination[0] = convertFloatToHalfFloat(source[0] * scaleFactor);
-        destination[1] = convertFloatToHalfFloat(source[1] * scaleFactor);
-        destination[2] = convertFloatToHalfFloat(source[2] * scaleFactor);
-        destination[3] = convertFloatToHalfFloat(source[3]);
-        source += 4;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGBA16F, GraphicsContext3D::AlphaDoUnmultiply, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
-        destination[0] = convertFloatToHalfFloat(source[0] * scaleFactor);
-        destination[1] = convertFloatToHalfFloat(source[1] * scaleFactor);
-        destination[2] = convertFloatToHalfFloat(source[2] * scaleFactor);
-        destination[3] = convertFloatToHalfFloat(source[3]);
-        source += 4;
-        destination += 4;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB16F, GraphicsContext3D::AlphaDoNothing, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = convertFloatToHalfFloat(source[0]);
-        destination[1] = convertFloatToHalfFloat(source[1]);
-        destination[2] = convertFloatToHalfFloat(source[2]);
-        source += 4;
-        destination += 3;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB16F, GraphicsContext3D::AlphaDoPremultiply, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3];
-        destination[0] = convertFloatToHalfFloat(source[0] * scaleFactor);
-        destination[1] = convertFloatToHalfFloat(source[1] * scaleFactor);
-        destination[2] = convertFloatToHalfFloat(source[2] * scaleFactor);
-        source += 4;
-        destination += 3;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRGB16F, GraphicsContext3D::AlphaDoUnmultiply, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
-        destination[0] = convertFloatToHalfFloat(source[0] * scaleFactor);
-        destination[1] = convertFloatToHalfFloat(source[1] * scaleFactor);
-        destination[2] = convertFloatToHalfFloat(source[2] * scaleFactor);
-        source += 4;
-        destination += 3;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA16F, GraphicsContext3D::AlphaDoNothing, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = convertFloatToHalfFloat(source[0]);
-        destination[1] = convertFloatToHalfFloat(source[3]);
-        source += 4;
-        destination += 2;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA16F, GraphicsContext3D::AlphaDoPremultiply, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3];
-        destination[0] = convertFloatToHalfFloat(source[0] * scaleFactor);
-        destination[1] = convertFloatToHalfFloat(source[3]);
-        source += 4;
-        destination += 2;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatRA16F, GraphicsContext3D::AlphaDoUnmultiply, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
-        destination[0] = convertFloatToHalfFloat(source[0] * scaleFactor);
-        destination[1] = convertFloatToHalfFloat(source[3]);
-        source += 4;
-        destination += 2;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR16F, GraphicsContext3D::AlphaDoNothing, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = convertFloatToHalfFloat(source[0]);
-        source += 4;
-        destination += 1;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR16F, GraphicsContext3D::AlphaDoPremultiply, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3];
-        destination[0] = convertFloatToHalfFloat(source[0] * scaleFactor);
-        source += 4;
-        destination += 1;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatR16F, GraphicsContext3D::AlphaDoUnmultiply, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
-        destination[0] = convertFloatToHalfFloat(source[0] * scaleFactor);
-        source += 4;
-        destination += 1;
-    }
-}
-
-template&lt;&gt; ALWAYS_INLINE void pack&lt;GraphicsContext3D::DataFormatA16F, GraphicsContext3D::AlphaDoNothing, float, uint16_t&gt;(const float* source, uint16_t* destination, unsigned pixelsPerRow)
-{
-    for (unsigned i = 0; i &lt; pixelsPerRow; ++i) {
-        destination[0] = convertFloatToHalfFloat(source[3]);
-        source += 4;
-        destination += 1;
-    }
-}
-
-ALWAYS_INLINE bool HasAlpha(int format)
-{
-    return format == GraphicsContext3D::DataFormatA8
-        || format == GraphicsContext3D::DataFormatA16F
-        || format == GraphicsContext3D::DataFormatA32F
-        || format == GraphicsContext3D::DataFormatRA8
-        || format == GraphicsContext3D::DataFormatAR8
-        || format == GraphicsContext3D::DataFormatRA16F
-        || format == GraphicsContext3D::DataFormatRA32F
-        || format == GraphicsContext3D::DataFormatRGBA8
-        || format == GraphicsContext3D::DataFormatBGRA8
-        || format == GraphicsContext3D::DataFormatARGB8
-        || format == GraphicsContext3D::DataFormatABGR8
-        || format == GraphicsContext3D::DataFormatRGBA16F
-        || format == GraphicsContext3D::DataFormatRGBA32F
-        || format == GraphicsContext3D::DataFormatRGBA4444
-        || format == GraphicsContext3D::DataFormatRGBA5551;
-}
-
-ALWAYS_INLINE bool HasColor(int format)
-{
-    return format == GraphicsContext3D::DataFormatRGBA8
-        || format == GraphicsContext3D::DataFormatRGBA16F
-        || format == GraphicsContext3D::DataFormatRGBA32F
-        || format == GraphicsContext3D::DataFormatRGB8
-        || format == GraphicsContext3D::DataFormatRGB16F
-        || format == GraphicsContext3D::DataFormatRGB32F
-        || format == GraphicsContext3D::DataFormatBGR8
-        || format == GraphicsContext3D::DataFormatBGRA8
-        || format == GraphicsContext3D::DataFormatARGB8
-        || format == GraphicsContext3D::DataFormatABGR8
-        || format == GraphicsContext3D::DataFormatRGBA5551
-        || format == GraphicsContext3D::DataFormatRGBA4444
-        || format == GraphicsContext3D::DataFormatRGB565
-        || format == GraphicsContext3D::DataFormatR8
-        || format == GraphicsContext3D::DataFormatR16F
-        || format == GraphicsContext3D::DataFormatR32F
-        || format == GraphicsContext3D::DataFormatRA8
-        || format == GraphicsContext3D::DataFormatRA16F
-        || format == GraphicsContext3D::DataFormatRA32F
-        || format == GraphicsContext3D::DataFormatAR8;
-}
-
-template&lt;int Format&gt;
-struct IsFloatFormat {
-    static const bool Value =
-        Format == GraphicsContext3D::DataFormatRGBA32F
-        || Format == GraphicsContext3D::DataFormatRGB32F
-        || Format == GraphicsContext3D::DataFormatRA32F
-        || Format == GraphicsContext3D::DataFormatR32F
-        || Format == GraphicsContext3D::DataFormatA32F;
-};
-
-template&lt;int Format&gt;
-struct IsHalfFloatFormat {
-    static const bool Value =
-        Format == GraphicsContext3D::DataFormatRGBA16F
-        || Format == GraphicsContext3D::DataFormatRGB16F
-        || Format == GraphicsContext3D::DataFormatRA16F
-        || Format == GraphicsContext3D::DataFormatR16F
-        || Format == GraphicsContext3D::DataFormatA16F;
-};
-
-template&lt;int Format&gt;
-struct Is16bppFormat {
-    static const bool Value =
-        Format == GraphicsContext3D::DataFormatRGBA5551
-        || Format == GraphicsContext3D::DataFormatRGBA4444
-        || Format == GraphicsContext3D::DataFormatRGB565;
-};
-
-template&lt;int Format, bool IsFloat = IsFloatFormat&lt;Format&gt;::Value, bool IsHalfFloat = IsHalfFloatFormat&lt;Format&gt;::Value, bool Is16bpp = Is16bppFormat&lt;Format&gt;::Value&gt;
-struct DataTypeForFormat {
-    typedef uint8_t Type;
-};
-
-template&lt;int Format&gt;
-struct DataTypeForFormat&lt;Format, true, false, false&gt; {
-    typedef float Type;
-};
-
-template&lt;int Format&gt;
-struct DataTypeForFormat&lt;Format, false, true, false&gt; {
-    typedef uint16_t Type;
-};
-
-template&lt;int Format&gt;
-struct DataTypeForFormat&lt;Format, false, false, true&gt; {
-    typedef uint16_t Type;
-};
-
-template&lt;int Format&gt;
-struct IntermediateFormat {
-    static const int Value = (IsFloatFormat&lt;Format&gt;::Value || IsHalfFloatFormat&lt;Format&gt;::Value) ? GraphicsContext3D::DataFormatRGBA32F : GraphicsContext3D::DataFormatRGBA8;
-};
-
</del><span class="cx"> ALWAYS_INLINE unsigned TexelBytesForFormat(GraphicsContext3D::DataFormat format)
</span><span class="cx"> {
</span><span class="cx">     switch (format) {
</span><span class="lines">@@ -1496,191 +335,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-/* END CODE SHARED WITH MOZILLA FIREFOX */
-
-class FormatConverter {
-public:
-    FormatConverter(unsigned width, unsigned height,
-        const void* srcStart, void* dstStart, int srcStride, int dstStride)
-        : m_width(width), m_height(height), m_srcStart(srcStart), m_dstStart(dstStart), m_srcStride(srcStride), m_dstStride(dstStride), m_success(false)
-    {
-        const unsigned MaxNumberOfComponents = 4;
-        const unsigned MaxBytesPerComponent  = 4;
-        m_unpackedIntermediateSrcData = std::make_unique&lt;uint8_t[]&gt;(m_width * MaxNumberOfComponents * MaxBytesPerComponent);
-
-        ASSERT(m_unpackedIntermediateSrcData.get());
-    }
-
-    void convert(GraphicsContext3D::DataFormat srcFormat, GraphicsContext3D::DataFormat dstFormat, GraphicsContext3D::AlphaOp);
-    bool Success() const { return m_success; }
-
-private:
-    template&lt;GraphicsContext3D::DataFormat SrcFormat&gt;
-    ALWAYS_INLINE void convert(GraphicsContext3D::DataFormat dstFormat, GraphicsContext3D::AlphaOp);
-
-    template&lt;GraphicsContext3D::DataFormat SrcFormat, GraphicsContext3D::DataFormat DstFormat&gt;
-    ALWAYS_INLINE void convert(GraphicsContext3D::AlphaOp);
-
-    template&lt;GraphicsContext3D::DataFormat SrcFormat, GraphicsContext3D::DataFormat DstFormat, GraphicsContext3D::AlphaOp alphaOp&gt;
-    ALWAYS_INLINE void convert();
-
-    const unsigned m_width, m_height;
-    const void* const m_srcStart;
-    void* const m_dstStart;
-    const int m_srcStride, m_dstStride;
-    bool m_success;
-    std::unique_ptr&lt;uint8_t[]&gt; m_unpackedIntermediateSrcData;
-};
-
-void FormatConverter::convert(GraphicsContext3D::DataFormat srcFormat, GraphicsContext3D::DataFormat dstFormat, GraphicsContext3D::AlphaOp alphaOp)
-{
-#define FORMATCONVERTER_CASE_SRCFORMAT(SrcFormat) \
-    case SrcFormat: \
-        return convert&lt;SrcFormat&gt;(dstFormat, alphaOp);
-
-        switch (srcFormat) {
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatR8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatA8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatR32F)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatA32F)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRA8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRA32F)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGB8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatBGR8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGB565)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGB32F)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGBA8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatARGB8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatABGR8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatAR8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatBGRA8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGBA5551)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGBA4444)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGBA32F)
-        default:
-            ASSERT_NOT_REACHED();
-        }
-#undef FORMATCONVERTER_CASE_SRCFORMAT
-}
-
-template&lt;GraphicsContext3D::DataFormat SrcFormat&gt;
-ALWAYS_INLINE void FormatConverter::convert(GraphicsContext3D::DataFormat dstFormat, GraphicsContext3D::AlphaOp alphaOp)
-{
-#define FORMATCONVERTER_CASE_DSTFORMAT(DstFormat) \
-    case DstFormat: \
-        return convert&lt;SrcFormat, DstFormat&gt;(alphaOp);
-
-        switch (dstFormat) {
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatR8)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatR16F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatR32F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatA8)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatA16F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatA32F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRA8)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRA16F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRA32F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGB8)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGB565)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGB16F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGB32F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA8)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA5551)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA4444)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA16F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA32F)
-        default:
-            ASSERT_NOT_REACHED();
-        }
-
-#undef FORMATCONVERTER_CASE_DSTFORMAT
-}
-
-template&lt;GraphicsContext3D::DataFormat SrcFormat, GraphicsContext3D::DataFormat DstFormat&gt;
-ALWAYS_INLINE void FormatConverter::convert(GraphicsContext3D::AlphaOp alphaOp)
-{
-#define FORMATCONVERTER_CASE_ALPHAOP(alphaOp) \
-    case alphaOp: \
-        return convert&lt;SrcFormat, DstFormat, alphaOp&gt;();
-
-        switch (alphaOp) {
-            FORMATCONVERTER_CASE_ALPHAOP(GraphicsContext3D::AlphaDoNothing)
-            FORMATCONVERTER_CASE_ALPHAOP(GraphicsContext3D::AlphaDoPremultiply)
-            FORMATCONVERTER_CASE_ALPHAOP(GraphicsContext3D::AlphaDoUnmultiply)
-        default:
-            ASSERT_NOT_REACHED();
-        }
-#undef FORMATCONVERTER_CASE_ALPHAOP
-}
-
-template&lt;GraphicsContext3D::DataFormat SrcFormat, GraphicsContext3D::DataFormat DstFormat, GraphicsContext3D::AlphaOp alphaOp&gt;
-ALWAYS_INLINE_EXCEPT_MSVC void FormatConverter::convert()
-{
-    // Many instantiations of this template function will never be entered, so we try
-    // to return immediately in these cases to avoid the compiler to generate useless code.
-    if (SrcFormat == DstFormat &amp;&amp; alphaOp == GraphicsContext3D::AlphaDoNothing) {
-        ASSERT_NOT_REACHED();
-        return;
-    }
-    if (!IsFloatFormat&lt;DstFormat&gt;::Value &amp;&amp; IsFloatFormat&lt;SrcFormat&gt;::Value) {
-        ASSERT_NOT_REACHED();
-        return;
-    }
-
-    // Only textures uploaded from DOM elements or ImageData can allow DstFormat != SrcFormat.
-    const bool srcFormatComesFromDOMElementOrImageData = GraphicsContext3D::srcFormatComesFromDOMElementOrImageData(SrcFormat);
-    if (!srcFormatComesFromDOMElementOrImageData &amp;&amp; SrcFormat != DstFormat) {
-        ASSERT_NOT_REACHED();
-        return;
-    }
-    // Likewise, only textures uploaded from DOM elements or ImageData can possibly have to be unpremultiplied.
-    if (!srcFormatComesFromDOMElementOrImageData &amp;&amp; alphaOp == GraphicsContext3D::AlphaDoUnmultiply) {
-        ASSERT_NOT_REACHED();
-        return;
-    }
-    if ((!HasAlpha(SrcFormat) || !HasColor(SrcFormat) || !HasColor(DstFormat)) &amp;&amp; alphaOp != GraphicsContext3D::AlphaDoNothing) {
-        ASSERT_NOT_REACHED();
-        return;
-    }
-
-    typedef typename DataTypeForFormat&lt;SrcFormat&gt;::Type SrcType;
-    typedef typename DataTypeForFormat&lt;DstFormat&gt;::Type DstType;
-    const int IntermediateSrcFormat = IntermediateFormat&lt;DstFormat&gt;::Value;
-    typedef typename DataTypeForFormat&lt;IntermediateSrcFormat&gt;::Type IntermediateSrcType;
-    const ptrdiff_t srcStrideInElements = m_srcStride / sizeof(SrcType);
-    const ptrdiff_t dstStrideInElements = m_dstStride / sizeof(DstType);
-    const bool trivialUnpack = (SrcFormat == GraphicsContext3D::DataFormatRGBA8 &amp;&amp; !IsFloatFormat&lt;DstFormat&gt;::Value &amp;&amp; !IsHalfFloatFormat&lt;DstFormat&gt;::Value) || SrcFormat == GraphicsContext3D::DataFormatRGBA32F;
-    const bool trivialPack = (DstFormat == GraphicsContext3D::DataFormatRGBA8 || DstFormat == GraphicsContext3D::DataFormatRGBA32F) &amp;&amp; alphaOp == GraphicsContext3D::AlphaDoNothing &amp;&amp; m_dstStride &gt; 0;
-    ASSERT(!trivialUnpack || !trivialPack);
-
-    const SrcType *srcRowStart = static_cast&lt;const SrcType*&gt;(m_srcStart);
-    DstType* dstRowStart = static_cast&lt;DstType*&gt;(m_dstStart);
-    if (!trivialUnpack &amp;&amp; trivialPack) {
-        for (size_t i = 0; i &lt; m_height; ++i) {
-            unpack&lt;SrcFormat&gt;(srcRowStart, dstRowStart, m_width);
-            srcRowStart += srcStrideInElements;
-            dstRowStart += dstStrideInElements;
-        }
-    } else if (!trivialUnpack &amp;&amp; !trivialPack) {
-        for (size_t i = 0; i &lt; m_height; ++i) {
-            unpack&lt;SrcFormat&gt;(srcRowStart, reinterpret_cast_ptr&lt;IntermediateSrcType*&gt;(m_unpackedIntermediateSrcData.get()), m_width);
-            pack&lt;DstFormat, alphaOp&gt;(reinterpret_cast_ptr&lt;IntermediateSrcType*&gt;(m_unpackedIntermediateSrcData.get()), dstRowStart, m_width);
-            srcRowStart += srcStrideInElements;
-            dstRowStart += dstStrideInElements;
-        }
-    } else {
-        for (size_t i = 0; i &lt; m_height; ++i) {
-            pack&lt;DstFormat, alphaOp&gt;(srcRowStart, dstRowStart, m_width);
-            srcRowStart += srcStrideInElements;
-            dstRowStart += dstStrideInElements;
-        }
-    }
-    m_success = true;
-    return;
-}
-
-} // anonymous namespace
-
</del><span class="cx"> bool GraphicsContext3D::packPixels(const uint8_t* sourceData, DataFormat sourceDataFormat, unsigned width, unsigned height, unsigned sourceUnpackAlignment, unsigned destinationFormat, unsigned destinationType, AlphaOp alphaOp, void* destinationData, bool flipY)
</span><span class="cx"> {
</span><span class="cx">     int validSrc = width * TexelBytesForFormat(sourceDataFormat);
</span><span class="lines">@@ -1693,7 +347,7 @@
</span><span class="cx">         destinationData = static_cast&lt;uint8_t*&gt;(destinationData) + dstStride*(height - 1);
</span><span class="cx">         dstStride = -dstStride;
</span><span class="cx">     }
</span><del>-    if (!HasAlpha(sourceDataFormat) || !HasColor(sourceDataFormat) || !HasColor(dstDataFormat))
</del><ins>+    if (!hasAlpha(sourceDataFormat) || !hasColor(sourceDataFormat) || !hasColor(dstDataFormat))
</ins><span class="cx">         alphaOp = AlphaDoNothing;
</span><span class="cx"> 
</span><span class="cx">     if (sourceDataFormat == dstDataFormat &amp;&amp; alphaOp == AlphaDoNothing) {
</span><span class="lines">@@ -1711,7 +365,7 @@
</span><span class="cx"> 
</span><span class="cx">     FormatConverter converter(width, height, sourceData, destinationData, srcStride, dstStride);
</span><span class="cx">     converter.convert(sourceDataFormat, dstDataFormat, alphaOp);
</span><del>-    if (!converter.Success())
</del><ins>+    if (!converter.success())
</ins><span class="cx">         return false;
</span><span class="cx">     return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContext3Dh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (161782 => 161783)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h        2014-01-11 21:58:23 UTC (rev 161782)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h        2014-01-11 22:56:40 UTC (rev 161783)
</span><span class="lines">@@ -606,6 +606,49 @@
</span><span class="cx">         DataFormatNumFormats
</span><span class="cx">     };
</span><span class="cx"> 
</span><ins>+    ALWAYS_INLINE static bool hasAlpha(DataFormat format)
+    {
+        return format == GraphicsContext3D::DataFormatA8
+            || format == GraphicsContext3D::DataFormatA16F
+            || format == GraphicsContext3D::DataFormatA32F
+            || format == GraphicsContext3D::DataFormatRA8
+            || format == GraphicsContext3D::DataFormatAR8
+            || format == GraphicsContext3D::DataFormatRA16F
+            || format == GraphicsContext3D::DataFormatRA32F
+            || format == GraphicsContext3D::DataFormatRGBA8
+            || format == GraphicsContext3D::DataFormatBGRA8
+            || format == GraphicsContext3D::DataFormatARGB8
+            || format == GraphicsContext3D::DataFormatABGR8
+            || format == GraphicsContext3D::DataFormatRGBA16F
+            || format == GraphicsContext3D::DataFormatRGBA32F
+            || format == GraphicsContext3D::DataFormatRGBA4444
+            || format == GraphicsContext3D::DataFormatRGBA5551;
+    }
+
+    ALWAYS_INLINE static bool hasColor(DataFormat format)
+    {
+        return format == GraphicsContext3D::DataFormatRGBA8
+            || format == GraphicsContext3D::DataFormatRGBA16F
+            || format == GraphicsContext3D::DataFormatRGBA32F
+            || format == GraphicsContext3D::DataFormatRGB8
+            || format == GraphicsContext3D::DataFormatRGB16F
+            || format == GraphicsContext3D::DataFormatRGB32F
+            || format == GraphicsContext3D::DataFormatBGR8
+            || format == GraphicsContext3D::DataFormatBGRA8
+            || format == GraphicsContext3D::DataFormatARGB8
+            || format == GraphicsContext3D::DataFormatABGR8
+            || format == GraphicsContext3D::DataFormatRGBA5551
+            || format == GraphicsContext3D::DataFormatRGBA4444
+            || format == GraphicsContext3D::DataFormatRGB565
+            || format == GraphicsContext3D::DataFormatR8
+            || format == GraphicsContext3D::DataFormatR16F
+            || format == GraphicsContext3D::DataFormatR32F
+            || format == GraphicsContext3D::DataFormatRA8
+            || format == GraphicsContext3D::DataFormatRA16F
+            || format == GraphicsContext3D::DataFormatRA32F
+            || format == GraphicsContext3D::DataFormatAR8;
+    }
+
</ins><span class="cx">     // Check if the format is one of the formats from the ImageData or DOM elements.
</span><span class="cx">     // The formats from ImageData is always RGBA8.
</span><span class="cx">     // The formats from DOM elements vary with Graphics ports. It can only be RGBA8 or BGRA8 for non-CG port while a little more for CG port.
</span></span></pre>
</div>
</div>

</body>
</html>