Bug 1510467 - Preserve purposely-formatted code from clang-format. (webgl, gfx/gl)
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 27 Nov 2018 00:47:49 -0800
changeset 504884 2d672bed9a1db1051426642e304e8ec7ee21c8d3
parent 504883 c3fe435e473a463fbc22d4afa531bdedb757079c
child 504885 77c14850b8c700541cc1273f5b7f7f14fa60e713
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1510467
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1510467 - Preserve purposely-formatted code from clang-format. (webgl, gfx/gl) MozReview-Commit-ID: 2U2oqQ53nTZ
dom/canvas/WebGLContext.cpp
dom/canvas/WebGLContext.h
dom/canvas/WebGLFormats.cpp
gfx/gl/GLBlitHelper.cpp
gfx/gl/GLConsts.h
gfx/gl/GLContext.cpp
gfx/gl/GLDefs.h
gfx/gl/GLParseRegistryXML.py
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -2038,48 +2038,52 @@ IndexedBufferBinding::ByteCount() const
 }
 
 ////////////////////////////////////////
 
 ScopedUnpackReset::ScopedUnpackReset(const WebGLContext* const webgl)
     : ScopedGLWrapper<ScopedUnpackReset>(webgl->gl)
     , mWebGL(webgl)
 {
+    // clang-format off
     if (mWebGL->mPixelStore_UnpackAlignment != 4) mGL->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
 
     if (mWebGL->IsWebGL2()) {
         if (mWebGL->mPixelStore_UnpackRowLength   != 0) mGL->fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH  , 0);
         if (mWebGL->mPixelStore_UnpackImageHeight != 0) mGL->fPixelStorei(LOCAL_GL_UNPACK_IMAGE_HEIGHT, 0);
         if (mWebGL->mPixelStore_UnpackSkipPixels  != 0) mGL->fPixelStorei(LOCAL_GL_UNPACK_SKIP_PIXELS , 0);
         if (mWebGL->mPixelStore_UnpackSkipRows    != 0) mGL->fPixelStorei(LOCAL_GL_UNPACK_SKIP_ROWS   , 0);
         if (mWebGL->mPixelStore_UnpackSkipImages  != 0) mGL->fPixelStorei(LOCAL_GL_UNPACK_SKIP_IMAGES , 0);
 
         if (mWebGL->mBoundPixelUnpackBuffer) mGL->fBindBuffer(LOCAL_GL_PIXEL_UNPACK_BUFFER, 0);
     }
+    // clang-format on
 }
 
 void
 ScopedUnpackReset::UnwrapImpl()
 {
+    // clang-format off
     mGL->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, mWebGL->mPixelStore_UnpackAlignment);
 
     if (mWebGL->IsWebGL2()) {
         mGL->fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH  , mWebGL->mPixelStore_UnpackRowLength  );
         mGL->fPixelStorei(LOCAL_GL_UNPACK_IMAGE_HEIGHT, mWebGL->mPixelStore_UnpackImageHeight);
         mGL->fPixelStorei(LOCAL_GL_UNPACK_SKIP_PIXELS , mWebGL->mPixelStore_UnpackSkipPixels );
         mGL->fPixelStorei(LOCAL_GL_UNPACK_SKIP_ROWS   , mWebGL->mPixelStore_UnpackSkipRows   );
         mGL->fPixelStorei(LOCAL_GL_UNPACK_SKIP_IMAGES , mWebGL->mPixelStore_UnpackSkipImages );
 
         GLuint pbo = 0;
         if (mWebGL->mBoundPixelUnpackBuffer) {
             pbo = mWebGL->mBoundPixelUnpackBuffer->mGLName;
         }
 
         mGL->fBindBuffer(LOCAL_GL_PIXEL_UNPACK_BUFFER, pbo);
     }
+    // clang-format on
 }
 
 ////////////////////
 
 void
 ScopedFBRebinder::UnwrapImpl()
 {
     const auto fnName = [&](WebGLFramebuffer* fb) {
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -43,25 +43,25 @@
 #include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsWrapperCache.h"
 #include "nsLayoutUtils.h"
 #include "mozilla/dom/WebGLRenderingContextBinding.h"
 #include "mozilla/dom/WebGL2RenderingContextBinding.h"
 
 class nsIDocShell;
 
-/*
- * WebGL-only GLenums
- */
-#define LOCAL_GL_BROWSER_DEFAULT_WEBGL                       0x9244
-#define LOCAL_GL_CONTEXT_LOST_WEBGL                          0x9242
-#define LOCAL_GL_MAX_CLIENT_WAIT_TIMEOUT_WEBGL               0x9247
-#define LOCAL_GL_UNPACK_COLORSPACE_CONVERSION_WEBGL          0x9243
-#define LOCAL_GL_UNPACK_FLIP_Y_WEBGL                         0x9240
-#define LOCAL_GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL              0x9241
+// WebGL-only GLenums
+// clang-format off
+#define LOCAL_GL_BROWSER_DEFAULT_WEBGL              0x9244
+#define LOCAL_GL_CONTEXT_LOST_WEBGL                 0x9242
+#define LOCAL_GL_MAX_CLIENT_WAIT_TIMEOUT_WEBGL      0x9247
+#define LOCAL_GL_UNPACK_COLORSPACE_CONVERSION_WEBGL 0x9243
+#define LOCAL_GL_UNPACK_FLIP_Y_WEBGL                0x9240
+#define LOCAL_GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL     0x9241
+// clang-format on
 
 namespace mozilla {
 class ScopedCopyTexImageSource;
 class ScopedDrawCallWrapper;
 class ScopedResolveTexturesForDraw;
 class ScopedUnpackReset;
 class WebGLActiveInfo;
 class WebGLBuffer;
--- a/dom/canvas/WebGLFormats.cpp
+++ b/dom/canvas/WebGLFormats.cpp
@@ -113,16 +113,18 @@ AddCompressedFormatInfo(EffectiveFormat 
     const CompressedFormatInfo info = { format, uint8_t(bytesPerBlock), blockWidth,
                                         blockHeight, family };
     AlwaysInsert(gCompressedFormatInfoMap, format, info);
 }
 
 static void
 InitCompressedFormatInfo()
 {
+    // clang-format off
+
     // GLES 3.0.4, p147, table 3.19
     // GLES 3.0.4, p286+, $C.1 "ETC Compressed Texture Image Formats"
     AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGB8_ETC2                     ,  64, 4, 4, CompressionFamily::ES3);
     AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ETC2                    ,  64, 4, 4, CompressionFamily::ES3);
     AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA8_ETC2_EAC                , 128, 4, 4, CompressionFamily::ES3);
     AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC         , 128, 4, 4, CompressionFamily::ES3);
     AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_R11_EAC                       ,  64, 4, 4, CompressionFamily::ES3);
     AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RG11_EAC                      , 128, 4, 4, CompressionFamily::ES3);
@@ -189,16 +191,18 @@ InitCompressedFormatInfo()
     // IMG_texture_compression_pvrtc
     AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGB_PVRTC_4BPPV1 , 256,  8, 8, CompressionFamily::PVRTC);
     AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_PVRTC_4BPPV1, 256,  8, 8, CompressionFamily::PVRTC);
     AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGB_PVRTC_2BPPV1 , 256, 16, 8, CompressionFamily::PVRTC);
     AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_PVRTC_2BPPV1, 256, 16, 8, CompressionFamily::PVRTC);
 
     // OES_compressed_ETC1_RGB8_texture
     AddCompressedFormatInfo(EffectiveFormat::ETC1_RGB8_OES, 64, 4, 4, CompressionFamily::ETC1);
+
+    // clang-format on
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
 
 static void
 AddFormatInfo(EffectiveFormat format, const char* name, GLenum sizedFormat,
               uint8_t bytesPerPixel, uint8_t r, uint8_t g, uint8_t b, uint8_t a,
               uint8_t d, uint8_t s, UnsizedFormat unsizedFormat, bool isSRGB,
@@ -267,16 +271,19 @@ AddFormatInfo(EffectiveFormat format, co
                               ToBaseType(componentType), isSRGB, compressedFormatInfo,
                               bytesPerPixel, r,g,b,a,d,s };
     AlwaysInsert(gFormatInfoMap, format, info);
 }
 
 static void
 InitFormatInfo()
 {
+    // This function is full of expressive formatting, so:
+    // clang-format off
+
 #define FOO(x) EffectiveFormat::x, #x, LOCAL_GL_ ## x
 
     // GLES 3.0.4, p130-132, table 3.13
     AddFormatInfo(FOO(R8            ),  1,  8, 0, 0, 0,  0,0, UnsizedFormat::R   , false, ComponentType::NormUInt);
     AddFormatInfo(FOO(R8_SNORM      ),  1,  8, 0, 0, 0,  0,0, UnsizedFormat::R   , false, ComponentType::NormInt );
     AddFormatInfo(FOO(RG8           ),  2,  8, 8, 0, 0,  0,0, UnsizedFormat::RG  , false, ComponentType::NormUInt);
     AddFormatInfo(FOO(RG8_SNORM     ),  2,  8, 8, 0, 0,  0,0, UnsizedFormat::RG  , false, ComponentType::NormInt );
     AddFormatInfo(FOO(RGB8          ),  3,  8, 8, 8, 0,  0,0, UnsizedFormat::RGB , false, ComponentType::NormUInt);
@@ -484,16 +491,17 @@ InitFormatInfo()
 
     SET_BY_SUFFIX(8)   // WebGL decided that RGB8 should be guaranteed renderable.
     SET_BY_SUFFIX(16F) // RGB16F is renderable in EXT_color_buffer_half_float, though not
                        // EXT_color_buffer_float.
     SET_BY_SUFFIX(32F) // Technically RGB32F is never renderable, but no harm here.
 
 #undef SET_BY_SUFFIX
 
+
     //////
 
 #define SET_BY_SUFFIX(X) \
         SET_COPY_DECAY(   R##X, R##X,   MAX,    MAX,     MAX, MAX, MAX, MAX) \
         SET_COPY_DECAY(  RG##X, R##X, RG##X,    MAX,     MAX, MAX, MAX, MAX) \
         SET_COPY_DECAY(RGBA##X, R##X, RG##X, RGB##X, RGBA##X, MAX, MAX, MAX)
 
     SET_BY_SUFFIX(8I)
@@ -516,16 +524,18 @@ InitFormatInfo()
 
     SET_COPY_DECAY(RGB10_A2UI, R8UI, RG8UI, RGB8UI, RGB10_A2UI, MAX, MAX, MAX)
 
     SET_COPY_DECAY(SRGB8_ALPHA8, MAX, MAX, MAX, SRGB8_ALPHA8, MAX, Alpha8, MAX)
 
     SET_COPY_DECAY(R11F_G11F_B10F, R16F, RG16F, R11F_G11F_B10F, MAX, Luminance16F, MAX, MAX)
 
 #undef SET_COPY_DECAY
+
+    // clang-format on
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
 
 bool gAreFormatTablesInitialized = false;
 
 static void
 EnsureInitFormatTables(const StaticMutexAutoLock&) // Prove that you locked it!
@@ -762,36 +772,42 @@ AddLegacyFormats_LA8(FormatUsageAuthorit
         pi = {LOCAL_GL_ALPHA, LOCAL_GL_UNSIGNED_BYTE};
         dui = {LOCAL_GL_R8, LOCAL_GL_RED, LOCAL_GL_UNSIGNED_BYTE};
         fnAdd(EffectiveFormat::Alpha8, FormatUsageInfo::kAlphaSwizzleRGBA);
 
         pi = {LOCAL_GL_LUMINANCE_ALPHA, LOCAL_GL_UNSIGNED_BYTE};
         dui = {LOCAL_GL_RG8, LOCAL_GL_RG, LOCAL_GL_UNSIGNED_BYTE};
         fnAdd(EffectiveFormat::Luminance8Alpha8, FormatUsageInfo::kLumAlphaSwizzleRGBA);
     } else {
+        // clang-format off
         AddSimpleUnsized(fua, LOCAL_GL_LUMINANCE      , LOCAL_GL_UNSIGNED_BYTE, EffectiveFormat::Luminance8      );
         AddSimpleUnsized(fua, LOCAL_GL_ALPHA          , LOCAL_GL_UNSIGNED_BYTE, EffectiveFormat::Alpha8          );
         AddSimpleUnsized(fua, LOCAL_GL_LUMINANCE_ALPHA, LOCAL_GL_UNSIGNED_BYTE, EffectiveFormat::Luminance8Alpha8);
+        // clang-format on
     }
 
     return true;
 }
 
 static bool
 AddUnsizedFormats(FormatUsageAuthority* fua, gl::GLContext* gl)
 {
+    // clang-format off
+
     // GLES 2.0.25, p63, Table 3.4
     AddSimpleUnsized(fua, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE         , EffectiveFormat::RGBA8  );
     AddSimpleUnsized(fua, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_SHORT_4_4_4_4, EffectiveFormat::RGBA4  );
     AddSimpleUnsized(fua, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_SHORT_5_5_5_1, EffectiveFormat::RGB5_A1);
     AddSimpleUnsized(fua, LOCAL_GL_RGB , LOCAL_GL_UNSIGNED_BYTE         , EffectiveFormat::RGB8   );
     AddSimpleUnsized(fua, LOCAL_GL_RGB , LOCAL_GL_UNSIGNED_SHORT_5_6_5  , EffectiveFormat::RGB565 );
 
     // L, A, LA
     return AddLegacyFormats_LA8(fua, gl);
+
+    // clang-format on
 }
 
 void
 FormatUsageInfo::SetRenderable()
 {
     this->isRenderable = true;
 
 #ifdef DEBUG
@@ -889,16 +905,17 @@ FormatUsageAuthority::CreateForWebGL2(gl
     {
         auto usage = ptr->EditUsage(effFormat);
 
         const PackingInfo pi = {unpackFormat, unpackType};
         const DriverUnpackInfo dui = {internalFormat, unpackFormat, unpackType};
         ptr->AddTexUnpack(usage, pi, dui);
     };
 
+    // clang-format off
 #define FOO(x) EffectiveFormat::x, LOCAL_GL_ ## x
 
     // RGBA
     fnAddSizedUnpack(FOO(RGBA8       ), LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE              );
     fnAddSizedUnpack(FOO(RGBA4       ), LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_SHORT_4_4_4_4     );
     fnAddSizedUnpack(FOO(RGBA4       ), LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE              );
     fnAddSizedUnpack(FOO(RGB5_A1     ), LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_SHORT_5_5_5_1     );
     fnAddSizedUnpack(FOO(RGB5_A1     ), LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE              );
@@ -979,16 +996,17 @@ FormatUsageAuthority::CreateForWebGL2(gl
     fnAddSizedUnpack(FOO(DEPTH_COMPONENT24 ), LOCAL_GL_DEPTH_COMPONENT, LOCAL_GL_UNSIGNED_INT  );
     fnAddSizedUnpack(FOO(DEPTH_COMPONENT32F), LOCAL_GL_DEPTH_COMPONENT, LOCAL_GL_FLOAT         );
 
     // DEPTH_STENCIL
     fnAddSizedUnpack(FOO(DEPTH24_STENCIL8 ), LOCAL_GL_DEPTH_STENCIL, LOCAL_GL_UNSIGNED_INT_24_8             );
     fnAddSizedUnpack(FOO(DEPTH32F_STENCIL8), LOCAL_GL_DEPTH_STENCIL, LOCAL_GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
 
 #undef FOO
+    // clang-format on
 
     ////////////////////////////////////////////////////////////////////////////
 
     // For renderable, see GLES 3.0.4, p212 "Framebuffer Completeness"
     // For filterable, see GLES 3.0.4, p161 "...a texture is complete unless..."
 
     const auto fnAllowES3TexFormat = [ptr](GLenum sizedFormat, EffectiveFormat effFormat,
                                            bool isRenderable, bool isFilterable)
--- a/gfx/gl/GLBlitHelper.cpp
+++ b/gfx/gl/GLBlitHelper.cpp
@@ -476,22 +476,24 @@ DrawBlitProg::Draw(const BaseArgs& args,
     GLenum vaa0Type;
     GLint vaa0Normalized;
     GLsizei vaa0Stride;
     GLvoid* vaa0Pointer;
     if (mParent.mQuadVAO) {
         oldVAO = gl->GetIntAs<GLuint>(LOCAL_GL_VERTEX_ARRAY_BINDING);
         gl->fBindVertexArray(mParent.mQuadVAO);
     } else {
+        // clang-format off
         gl->fGetVertexAttribiv(0, LOCAL_GL_VERTEX_ATTRIB_ARRAY_ENABLED, &vaa0Enabled);
         gl->fGetVertexAttribiv(0, LOCAL_GL_VERTEX_ATTRIB_ARRAY_SIZE, &vaa0Size);
         gl->fGetVertexAttribiv(0, LOCAL_GL_VERTEX_ATTRIB_ARRAY_TYPE, (GLint*)&vaa0Type);
         gl->fGetVertexAttribiv(0, LOCAL_GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &vaa0Normalized);
         gl->fGetVertexAttribiv(0, LOCAL_GL_VERTEX_ATTRIB_ARRAY_STRIDE, (GLint*)&vaa0Stride);
         gl->fGetVertexAttribPointerv(0, LOCAL_GL_VERTEX_ATTRIB_ARRAY_POINTER, &vaa0Pointer);
+        // clang-format on
 
         gl->fEnableVertexAttribArray(0);
         const ScopedBindArrayBuffer bindVBO(gl, mParent.mQuadVBO);
         gl->fVertexAttribPointer(0, 2, LOCAL_GL_FLOAT, false, 0, 0);
     }
 
     gl->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
 
--- a/gfx/gl/GLConsts.h
+++ b/gfx/gl/GLConsts.h
@@ -1,15 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GLCONSTS_H_
 #define GLCONSTS_H_
 
+// clang-format off
+
 /**
  * GENERATED FILE, DO NOT MODIFY DIRECTLY.
  * This is a file generated directly from the official OpenGL registry
  * xml available http://www.opengl.org/registry/#specfiles.
  *
  * To generate this file, see tutorial in 'GLParseRegistryXML.py'.
  */
 
@@ -6994,11 +6996,11 @@
 #define LOCAL_WGL_VIDEO_OUT_COLOR_NV                         0x20C3
 #define LOCAL_WGL_VIDEO_OUT_DEPTH_NV                         0x20C5
 #define LOCAL_WGL_VIDEO_OUT_FIELD_1                          0x20C9
 #define LOCAL_WGL_VIDEO_OUT_FIELD_2                          0x20CA
 #define LOCAL_WGL_VIDEO_OUT_FRAME                            0x20C8
 #define LOCAL_WGL_VIDEO_OUT_STACKED_FIELDS_1_2               0x20CB
 #define LOCAL_WGL_VIDEO_OUT_STACKED_FIELDS_2_1               0x20CC
 
-
+// clang-format on
 
 #endif // GLCONSTS_H_
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -58,21 +58,23 @@ namespace mozilla {
 namespace gl {
 
 using namespace mozilla::gfx;
 using namespace mozilla::layers;
 
 MOZ_THREAD_LOCAL(uintptr_t) GLContext::sCurrentContext;
 
 // If adding defines, don't forget to undefine symbols. See #undef block below.
+// clang-format off
 #define CORE_SYMBOL(x) { (PRFuncPtr*) &mSymbols.f##x, { #x, nullptr } }
 #define CORE_EXT_SYMBOL2(x,y,z) { (PRFuncPtr*) &mSymbols.f##x, { #x, #x #y, #x #z, nullptr } }
 #define EXT_SYMBOL2(x,y,z) { (PRFuncPtr*) &mSymbols.f##x, { #x #y, #x #z, nullptr } }
 #define EXT_SYMBOL3(x,y,z,w) { (PRFuncPtr*) &mSymbols.f##x, { #x #y, #x #z, #x #w, nullptr } }
 #define END_SYMBOLS { nullptr, { nullptr } }
+// clang-format on
 
 // should match the order of GLExtensions, and be null-terminated.
 static const char* const sExtensionNames[] = {
     "NO_EXTENSION",
     "GL_AMD_compressed_ATC_texture",
     "GL_ANGLE_depth_texture",
     "GL_ANGLE_framebuffer_blit",
     "GL_ANGLE_framebuffer_multisample",
@@ -378,16 +380,17 @@ GLContext::LoadFeatureSymbols(const char
 };
 
 bool
 GLContext::InitWithPrefixImpl(const char* prefix, bool trygl)
 {
     if (!MakeCurrent(true))
         return false;
 
+    // clang-format off
     const SymLoadStruct coreSymbols[] = {
         { (PRFuncPtr*) &mSymbols.fActiveTexture, { "ActiveTexture", "ActiveTextureARB", nullptr } },
         { (PRFuncPtr*) &mSymbols.fAttachShader, { "AttachShader", "AttachShaderARB", nullptr } },
         { (PRFuncPtr*) &mSymbols.fBindAttribLocation, { "BindAttribLocation", "BindAttribLocationARB", nullptr } },
         { (PRFuncPtr*) &mSymbols.fBindBuffer, { "BindBuffer", "BindBufferARB", nullptr } },
         { (PRFuncPtr*) &mSymbols.fBindTexture, { "BindTexture", "BindTextureARB", nullptr } },
         { (PRFuncPtr*) &mSymbols.fBlendColor, { "BlendColor", nullptr } },
         { (PRFuncPtr*) &mSymbols.fBlendEquation, { "BlendEquation", nullptr } },
@@ -506,16 +509,17 @@ GLContext::InitWithPrefixImpl(const char
 
         { (PRFuncPtr*) &mSymbols.fDeleteBuffers, { "DeleteBuffers", "DeleteBuffersARB", nullptr } },
         { (PRFuncPtr*) &mSymbols.fDeleteTextures, { "DeleteTextures", "DeleteTexturesARB", nullptr } },
         { (PRFuncPtr*) &mSymbols.fDeleteProgram, { "DeleteProgram", "DeleteProgramARB", nullptr } },
         { (PRFuncPtr*) &mSymbols.fDeleteShader, { "DeleteShader", "DeleteShaderARB", nullptr } },
 
         END_SYMBOLS
     };
+    // clang-format on
 
     if (!LoadGLSymbols(this, prefix, trygl, coreSymbols, "GL"))
         return false;
 
     {
         const SymLoadStruct symbols[] = {
             { (PRFuncPtr*) &mSymbols.fGetGraphicsResetStatus, { "GetGraphicsResetStatus",
                                                                 "GetGraphicsResetStatusARB",
@@ -582,47 +586,47 @@ GLContext::InitWithPrefixImpl(const char
         printf_stderr("OpenGL renderer: %s\n", fGetString(LOCAL_GL_RENDERER));
     }
 
     ////////////////
 
     // Load OpenGL ES 2.0 symbols, or desktop if we aren't using ES 2.
     if (mProfile == ContextProfile::OpenGLES) {
         const SymLoadStruct symbols[] = {
-            { (PRFuncPtr*) &mSymbols.fGetShaderPrecisionFormat, { "GetShaderPrecisionFormat", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fClearDepthf, { "ClearDepthf", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fDepthRangef, { "DepthRangef", nullptr } },
+            CORE_SYMBOL(GetShaderPrecisionFormat),
+            CORE_SYMBOL(ClearDepthf),
+            CORE_SYMBOL(DepthRangef),
             END_SYMBOLS
         };
 
         if (!LoadGLSymbols(this, prefix, trygl, symbols, "OpenGL ES"))
             return false;
     } else {
         const SymLoadStruct symbols[] = {
-            { (PRFuncPtr*) &mSymbols.fClearDepth, { "ClearDepth", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fDepthRange, { "DepthRange", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fReadBuffer, { "ReadBuffer", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fMapBuffer, { "MapBuffer", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fUnmapBuffer, { "UnmapBuffer", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fPointParameterf, { "PointParameterf", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fDrawBuffer, { "DrawBuffer", nullptr } },
+            CORE_SYMBOL(ClearDepth),
+            CORE_SYMBOL(DepthRange),
+            CORE_SYMBOL(ReadBuffer),
+            CORE_SYMBOL(MapBuffer),
+            CORE_SYMBOL(UnmapBuffer),
+            CORE_SYMBOL(PointParameterf),
+            CORE_SYMBOL(DrawBuffer),
             // The following functions are only used by Skia/GL in desktop mode.
             // Other parts of Gecko should avoid using these
-            { (PRFuncPtr*) &mSymbols.fDrawBuffers, { "DrawBuffers", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fClientActiveTexture, { "ClientActiveTexture", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fDisableClientState, { "DisableClientState", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fEnableClientState, { "EnableClientState", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fLoadIdentity, { "LoadIdentity", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fLoadMatrixf, { "LoadMatrixf", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fMatrixMode, { "MatrixMode", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fPolygonMode, { "PolygonMode", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fTexGeni, { "TexGeni", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fTexGenf, { "TexGenf", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fTexGenfv, { "TexGenfv", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fVertexPointer, { "VertexPointer", nullptr } },
+            CORE_SYMBOL(DrawBuffers),
+            CORE_SYMBOL(ClientActiveTexture),
+            CORE_SYMBOL(DisableClientState),
+            CORE_SYMBOL(EnableClientState),
+            CORE_SYMBOL(LoadIdentity),
+            CORE_SYMBOL(LoadMatrixf),
+            CORE_SYMBOL(MatrixMode),
+            CORE_SYMBOL(PolygonMode),
+            CORE_SYMBOL(TexGeni),
+            CORE_SYMBOL(TexGenf),
+            CORE_SYMBOL(TexGenfv),
+            CORE_SYMBOL(VertexPointer),
             END_SYMBOLS
         };
 
         if (!LoadGLSymbols(this, prefix, trygl, symbols, "Desktop OpenGL"))
             return false;
     }
 
     ////////////////
@@ -1035,54 +1039,56 @@ GLContext::LoadMoreSymbols(const char* p
                               resetStrategy);
             }
             MarkUnsupported(GLFeature::robustness);
         }
     }
 
     if (IsSupported(GLFeature::sync)) {
         const SymLoadStruct symbols[] = {
-            { (PRFuncPtr*) &mSymbols.fFenceSync,      { "FenceSync",      nullptr } },
-            { (PRFuncPtr*) &mSymbols.fIsSync,         { "IsSync",         nullptr } },
-            { (PRFuncPtr*) &mSymbols.fDeleteSync,     { "DeleteSync",     nullptr } },
-            { (PRFuncPtr*) &mSymbols.fClientWaitSync, { "ClientWaitSync", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fWaitSync,       { "WaitSync",       nullptr } },
-            { (PRFuncPtr*) &mSymbols.fGetInteger64v,  { "GetInteger64v",  nullptr } },
-            { (PRFuncPtr*) &mSymbols.fGetSynciv,      { "GetSynciv",      nullptr } },
+            CORE_SYMBOL(FenceSync),
+            CORE_SYMBOL(IsSync),
+            CORE_SYMBOL(DeleteSync),
+            CORE_SYMBOL(ClientWaitSync),
+            CORE_SYMBOL(WaitSync),
+            CORE_SYMBOL(GetInteger64v),
+            CORE_SYMBOL(GetSynciv),
             END_SYMBOLS
         };
         fnLoadForFeature(symbols, GLFeature::sync);
     }
 
     if (IsExtensionSupported(OES_EGL_image)) {
         const SymLoadStruct symbols[] = {
             { (PRFuncPtr*) &mSymbols.fEGLImageTargetTexture2D, { "EGLImageTargetTexture2DOES", nullptr } },
             { (PRFuncPtr*) &mSymbols.fEGLImageTargetRenderbufferStorage, { "EGLImageTargetRenderbufferStorageOES", nullptr } },
             END_SYMBOLS
         };
         fnLoadForExt(symbols, OES_EGL_image);
     }
 
     if (IsExtensionSupported(APPLE_texture_range)) {
         const SymLoadStruct symbols[] = {
-            { (PRFuncPtr*) &mSymbols.fTextureRangeAPPLE, { "TextureRangeAPPLE", nullptr } },
+            CORE_SYMBOL(TextureRangeAPPLE),
             END_SYMBOLS
         };
         fnLoadForExt(symbols, APPLE_texture_range);
     }
 
     if (IsExtensionSupported(APPLE_fence)) {
         const SymLoadStruct symbols[] = {
-            { (PRFuncPtr*) &mSymbols.fFinishObjectAPPLE, { "FinishObjectAPPLE", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fTestObjectAPPLE, { "TestObjectAPPLE", nullptr } },
+            CORE_SYMBOL(FinishObjectAPPLE),
+            CORE_SYMBOL(TestObjectAPPLE),
             END_SYMBOLS
         };
         fnLoadForExt(symbols, APPLE_fence);
     }
 
+// clang-format off
+
     if (IsSupported(GLFeature::vertex_array_object)) {
         const SymLoadStruct coreSymbols[] = {
             { (PRFuncPtr*) &mSymbols.fIsVertexArray, { "IsVertexArray", nullptr } },
             { (PRFuncPtr*) &mSymbols.fGenVertexArrays, { "GenVertexArrays", nullptr } },
             { (PRFuncPtr*) &mSymbols.fBindVertexArray, { "BindVertexArray", nullptr } },
             { (PRFuncPtr*) &mSymbols.fDeleteVertexArrays, { "DeleteVertexArrays", nullptr } },
             END_SYMBOLS
         };
@@ -1495,44 +1501,46 @@ GLContext::LoadMoreSymbols(const char* p
             { (PRFuncPtr*) &mSymbols.fFinishFence,  { "FinishFenceNV",  nullptr } },
             { (PRFuncPtr*) &mSymbols.fIsFence,      { "IsFenceNV",      nullptr } },
             { (PRFuncPtr*) &mSymbols.fGetFenceiv,   { "GetFenceivNV",   nullptr } },
             END_SYMBOLS
         };
         fnLoadForExt(symbols, NV_fence);
     }
 
+// clang-format off
+
     if (IsExtensionSupported(NV_texture_barrier)) {
         const SymLoadStruct symbols[] = {
             { (PRFuncPtr*) &mSymbols.fTextureBarrier, { "TextureBarrierNV", nullptr } },
             END_SYMBOLS
         };
         fnLoadForExt(symbols, NV_texture_barrier);
     }
 
     if (IsSupported(GLFeature::read_buffer)) {
         const SymLoadStruct symbols[] = {
-            { (PRFuncPtr*) &mSymbols.fReadBuffer, { "ReadBuffer", nullptr } },
+            CORE_SYMBOL(ReadBuffer),
             END_SYMBOLS
         };
         fnLoadForFeature(symbols, GLFeature::read_buffer);
     }
 
     if (IsExtensionSupported(APPLE_framebuffer_multisample)) {
         const SymLoadStruct symbols[] = {
-            { (PRFuncPtr*) &mSymbols.fResolveMultisampleFramebufferAPPLE, { "ResolveMultisampleFramebufferAPPLE", nullptr } },
+            CORE_SYMBOL(ResolveMultisampleFramebufferAPPLE),
             END_SYMBOLS
         };
         fnLoadForExt(symbols, APPLE_framebuffer_multisample);
     }
 
     // Load developer symbols, don't fail if we can't find them.
     const SymLoadStruct devSymbols[] = {
-            { (PRFuncPtr*) &mSymbols.fGetTexImage, { "GetTexImage", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fGetTexLevelParameteriv, { "GetTexLevelParameteriv", nullptr } },
+            CORE_SYMBOL(GetTexImage),
+            CORE_SYMBOL(GetTexLevelParameteriv),
             END_SYMBOLS
     };
     const bool warnOnFailures = ShouldSpew();
     LoadSymbols(devSymbols, trygl, prefix, warnOnFailures);
 }
 
 #undef CORE_SYMBOL
 #undef CORE_EXT_SYMBOL2
--- a/gfx/gl/GLDefs.h
+++ b/gfx/gl/GLDefs.h
@@ -15,16 +15,18 @@ bool CheckContextLost(const GLContext* g
 }
 }
 
 #define MOZ_GL_ASSERT(glContext,expr) \
   MOZ_ASSERT((expr) || mozilla::gl::CheckContextLost(glContext))
 
 // -
 
+// clang-format off
+
 // TODO: use official constant names instead of followed ones.
 
 // IMG_texture_compression_pvrtc
 #define LOCAL_GL_COMPRESSED_RGB_PVRTC_4BPPV1            0x8C00
 #define LOCAL_GL_COMPRESSED_RGB_PVRTC_2BPPV1            0x8C01
 #define LOCAL_GL_COMPRESSED_RGBA_PVRTC_4BPPV1           0x8C02
 #define LOCAL_GL_COMPRESSED_RGBA_PVRTC_2BPPV1           0x8C03
 
@@ -88,9 +90,11 @@ bool CheckContextLost(const GLContext* g
 // Others
 #define LOCAL_EGL_PRESERVED_RESOURCES                   0x3030
 #define LOCAL_EGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_EXT 0x3138
 #define LOCAL_GL_CONTEXT_FLAGS_ARB                      0x2094
 #define LOCAL_GL_CONTEXT_CORE_PROFILE_BIT_ARB           0x00000001
 #define LOCAL_GL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB  0x00000002
 #define LOCAL_GL_CONTEXT_ROBUST_ACCESS_BIT_ARB          0x00000004
 
+// clang-format on
+
 #endif
--- a/gfx/gl/GLParseRegistryXML.py
+++ b/gfx/gl/GLParseRegistryXML.py
@@ -50,16 +50,18 @@ class GLConstHeader:
         self.write([
             '/* This Source Code Form is subject to the terms of the Mozilla Public',
             ' * License, v. 2.0. If a copy of the MPL was not distributed with this',
             ' * file, You can obtain one at http://mozilla.org/MPL/2.0/. */',
             '',
             '#ifndef GLCONSTS_H_',
             '#define GLCONSTS_H_',
             '',
+            '// clang-format off',
+            '',
             '/**',
             ' * GENERATED FILE, DO NOT MODIFY DIRECTLY.',
             ' * This is a file generated directly from the official OpenGL registry',
             ' * xml available http://www.opengl.org/registry/#specfiles.',
             ' *',
             ' * To generate this file, see tutorial in \'GLParseRegistryXML.py\'.',
             ' */',
             ''
@@ -84,16 +86,18 @@ class GLConstHeader:
 
     def formatLibEnd(self, lib):
         # lib would be 'GL', 'EGL', 'GLX' or 'WGL'
         self.write(2)
 
     def formatFileEnd(self):
         self.write([
             '',
+            '// clang-format on',
+            '',
             '#endif // GLCONSTS_H_'
         ])
 
 
 ################################################################################
 # underground code
 
 def getScriptDir():