Clang-format the codebase

BUG=None
TEST=clang-format --style=Chromium -i *.cc *.h

Change-Id: Ia2359ab508971d02d05d347e952ae5e33d060131
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/glbench/+/3061325
Reviewed-by: Ilja H. Friedel <ihf@chromium.org>
Commit-Queue: Ilja H. Friedel <ihf@chromium.org>
Commit-Queue: Po-Hsien Wang <pwang@chromium.org>
Tested-by: Po-Hsien Wang <pwang@chromium.org>
Auto-Submit: Po-Hsien Wang <pwang@chromium.org>
diff --git a/src/bufferstreamingtest.cc b/src/bufferstreamingtest.cc
index c8e778a..cba697a 100644
--- a/src/bufferstreamingtest.cc
+++ b/src/bufferstreamingtest.cc
@@ -10,58 +10,56 @@
 namespace glbench {
 
 class BufferStreamingTest : public TestBase {
-  public:
-    BufferStreamingTest()
-      : buffer_size_(1 * 1024 * 1024)
-    {
-      // clockwise such that the triangle is culled
-      const GLfloat vertices[3][2] = {
-        { 0.0f, 0.0f },
-        { 0.0f, 1.0f },
-        { 1.0f, 0.0f },
-      };
-
-      memcpy(data_, vertices, sizeof(vertices));
-      data_size_ = sizeof(vertices);
-    }
-
-    virtual ~BufferStreamingTest() {}
-    virtual bool TestFunc(uint64_t iterations);
-    virtual bool Run();
-    virtual const char* Name() const { return "buffer_streaming"; }
-    virtual bool IsDrawTest() const { return false; }
-    virtual const char* Unit() const { return "mbytes_sec"; }
-
-  private:
-    enum streaming_mode {
-      STREAMING_MODE_SUBDATA_OVERWRITE,
-      STREAMING_MODE_SUBDATA,
-
-      STREAMING_MODE_COUNT,
+ public:
+  BufferStreamingTest() : buffer_size_(1 * 1024 * 1024) {
+    // clockwise such that the triangle is culled
+    const GLfloat vertices[3][2] = {
+        {0.0f, 0.0f},
+        {0.0f, 1.0f},
+        {1.0f, 0.0f},
     };
 
-    const GLsizeiptr buffer_size_;
+    memcpy(data_, vertices, sizeof(vertices));
+    data_size_ = sizeof(vertices);
+  }
 
-    GLbyte data_[sizeof(GLfloat) * 2 * 3];
-    GLsizeiptr data_size_;
+  virtual ~BufferStreamingTest() {}
+  virtual bool TestFunc(uint64_t iterations);
+  virtual bool Run();
+  virtual const char* Name() const { return "buffer_streaming"; }
+  virtual bool IsDrawTest() const { return false; }
+  virtual const char* Unit() const { return "mbytes_sec"; }
 
-    enum streaming_mode streaming_mode_;
+ private:
+  enum streaming_mode {
+    STREAMING_MODE_SUBDATA_OVERWRITE,
+    STREAMING_MODE_SUBDATA,
 
-    const char *CurrentStreamingModeName() const {
-      switch (streaming_mode_) {
+    STREAMING_MODE_COUNT,
+  };
+
+  const GLsizeiptr buffer_size_;
+
+  GLbyte data_[sizeof(GLfloat) * 2 * 3];
+  GLsizeiptr data_size_;
+
+  enum streaming_mode streaming_mode_;
+
+  const char* CurrentStreamingModeName() const {
+    switch (streaming_mode_) {
       case STREAMING_MODE_SUBDATA:
         return "subdata";
       case STREAMING_MODE_SUBDATA_OVERWRITE:
         return "subdata_overwrite";
       default:
         return "invalid";
-      }
     }
+  }
 
-    bool TestSubData(uint64_t iterations);
-    bool TestSubDataOverwrite(uint64_t iterations);
+  bool TestSubData(uint64_t iterations);
+  bool TestSubDataOverwrite(uint64_t iterations);
 
-    DISALLOW_COPY_AND_ASSIGN(BufferStreamingTest);
+  DISALLOW_COPY_AND_ASSIGN(BufferStreamingTest);
 };
 
 bool BufferStreamingTest::TestSubData(uint64_t iterations) {
@@ -99,26 +97,26 @@
   glBufferData(GL_ARRAY_BUFFER, buffer_size_, NULL, GL_STREAM_DRAW);
 
   switch (streaming_mode_) {
-  case STREAMING_MODE_SUBDATA:
-    return TestSubData(iterations);
-  case STREAMING_MODE_SUBDATA_OVERWRITE:
-    return TestSubDataOverwrite(iterations);
-  default:
-    return false;
+    case STREAMING_MODE_SUBDATA:
+      return TestSubData(iterations);
+    case STREAMING_MODE_SUBDATA_OVERWRITE:
+      return TestSubDataOverwrite(iterations);
+    default:
+      return false;
   }
 }
 
 bool BufferStreamingTest::Run() {
   const char vs[] =
-    "attribute vec4 pos;"
-    "void main() {"
-    "  gl_Position = pos;"
-    "}";
+      "attribute vec4 pos;"
+      "void main() {"
+      "  gl_Position = pos;"
+      "}";
 
   const char fs[] =
-    "void main() {"
-    "  gl_FragColor = vec4(1.0);"
-    "}";
+      "void main() {"
+      "  gl_FragColor = vec4(1.0);"
+      "}";
   GLuint program = InitShaderProgram(vs, fs);
 
   GLuint buffer;
@@ -136,8 +134,8 @@
   for (int i = 0; i < STREAMING_MODE_COUNT; i++) {
     streaming_mode_ = static_cast<enum streaming_mode>(i);
 
-    const std::string name = std::string(Name()) + "_" +
-      CurrentStreamingModeName();
+    const std::string name =
+        std::string(Name()) + "_" + CurrentStreamingModeName();
     RunTest(this, name.c_str(), data_size_, g_width, g_height, true);
     CHECK(!glGetError());
   }
@@ -152,4 +150,4 @@
   return new BufferStreamingTest;
 }
 
-} // namespace glbench
+}  // namespace glbench
diff --git a/src/bufferuploadsubtest.cc b/src/bufferuploadsubtest.cc
index 1000dbd..0287a7b 100644
--- a/src/bufferuploadsubtest.cc
+++ b/src/bufferuploadsubtest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2018 The Chromium OS Authors. All rights reserved.
+// Copyright 2018 The Chromium OS Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
@@ -10,27 +10,24 @@
 namespace glbench {
 
 class BufferUploadSubTest : public TestBase {
-  public:
-    BufferUploadSubTest()
-      : buffer_size_(1572864),
-      target_(GL_ARRAY_BUFFER),
-      size_(0)
-  {
+ public:
+  BufferUploadSubTest()
+      : buffer_size_(1572864), target_(GL_ARRAY_BUFFER), size_(0) {
     memset(data_, 0, sizeof(data_));
   }
-    virtual ~BufferUploadSubTest() {}
-    virtual bool TestFunc(uint64_t iterations);
-    virtual bool Run();
-    virtual const char* Name() const { return "buffer_upload_sub"; }
-    virtual bool IsDrawTest() const { return false; }
-    virtual const char* Unit() const { return "mbytes_sec"; }
+  virtual ~BufferUploadSubTest() {}
+  virtual bool TestFunc(uint64_t iterations);
+  virtual bool Run();
+  virtual const char* Name() const { return "buffer_upload_sub"; }
+  virtual bool IsDrawTest() const { return false; }
+  virtual const char* Unit() const { return "mbytes_sec"; }
 
-  private:
-    GLsizeiptr buffer_size_;
-    GLenum target_;
-    GLsizeiptr size_;
-    GLbyte data_[256 * 1024];
-    DISALLOW_COPY_AND_ASSIGN(BufferUploadSubTest);
+ private:
+  GLsizeiptr buffer_size_;
+  GLenum target_;
+  GLsizeiptr size_;
+  GLbyte data_[256 * 1024];
+  DISALLOW_COPY_AND_ASSIGN(BufferUploadSubTest);
 };
 
 bool BufferUploadSubTest::TestFunc(uint64_t iterations) {
@@ -47,11 +44,11 @@
 
 bool BufferUploadSubTest::Run() {
   const GLenum usages[] = {GL_DYNAMIC_DRAW, GL_STATIC_DRAW};
-  const char * usage_names[] = {"dynamic", "static"};
+  const char* usage_names[] = {"dynamic", "static"};
   const GLenum targets[] = {GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER};
-  const char * target_names[] = {"array", "element_array"};
-  const int sizes[] = {8, 12, 16, 32, 64, 128, 192, 256, 512, 1024, 2048,
-                        4096, 8192, 16384, 32768, 65536, 131072};
+  const char* target_names[] = {"array", "element_array"};
+  const int sizes[] = {8,    12,   16,   32,   64,    128,   192,   256,   512,
+                       1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072};
 
   for (unsigned int uidx = 0; uidx < arraysize(usages); uidx++) {
     GLenum usage = usages[uidx];
@@ -67,7 +64,7 @@
         glBufferData(target_, buffer_size_, NULL, usage);
 
         std::string name = std::string(Name()) + "_" + usage_names[uidx] + "_" +
-                            target_names[tidx] + "_" + IntToString(size_);
+                           target_names[tidx] + "_" + IntToString(size_);
         RunTest(this, name.c_str(), sizes[sidx], g_width, g_height, true);
         CHECK(!glGetError());
       }
@@ -83,4 +80,4 @@
   return new BufferUploadSubTest;
 }
 
-} // namespace glbench
+}  // namespace glbench
diff --git a/src/bufferuploadtest.cc b/src/bufferuploadtest.cc
index 8ae1405..b2dbd07 100644
--- a/src/bufferuploadtest.cc
+++ b/src/bufferuploadtest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2018 The Chromium OS Authors. All rights reserved.
+// Copyright 2018 The Chromium OS Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
@@ -13,15 +13,12 @@
 
 const int kNumberOfBuffers = 1;
 
-} // namespace
+}  // namespace
 
 class BufferUploadTest : public TestBase {
  public:
   BufferUploadTest()
-      : target_(GL_ARRAY_BUFFER),
-        size_(0),
-        usage_(GL_DYNAMIC_DRAW)
-  {
+      : target_(GL_ARRAY_BUFFER), size_(0), usage_(GL_DYNAMIC_DRAW) {
     memset(data_, 0, sizeof(data_));
   }
   virtual ~BufferUploadTest() {}
@@ -52,11 +49,11 @@
 
 bool BufferUploadTest::Run() {
   const GLenum usages[] = {GL_DYNAMIC_DRAW, GL_STATIC_DRAW};
-  const char * usage_names[] = {"dynamic", "static"};
+  const char* usage_names[] = {"dynamic", "static"};
   const GLenum targets[] = {GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER};
-  const char * target_names[] = {"array", "element_array"};
-  const int sizes[] = {8, 12, 16, 32, 64, 128, 192, 256, 512, 1024, 2048,
-                       4096, 8192, 16384, 32768, 65536, 131072};
+  const char* target_names[] = {"array", "element_array"};
+  const int sizes[] = {8,    12,   16,   32,   64,    128,   192,   256,   512,
+                       1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072};
 
   for (unsigned int uidx = 0; uidx < arraysize(usages); uidx++) {
     usage_ = usages[uidx];
@@ -88,4 +85,4 @@
   return new BufferUploadTest;
 }
 
-} // namespace glbench
+}  // namespace glbench
diff --git a/src/egl_stuff.cc b/src/egl_stuff.cc
index 93e4c71..59f4c63 100644
--- a/src/egl_stuff.cc
+++ b/src/egl_stuff.cc
@@ -43,15 +43,14 @@
 
 XVisualInfo* EGLInterface::GetXVisual() {
   if (!config_) {
-    EGLint attribs[] = {
-      EGL_RED_SIZE, 1,
-      EGL_GREEN_SIZE, 1,
-      EGL_BLUE_SIZE, 1,
-      EGL_DEPTH_SIZE, 1,
-      EGL_STENCIL_SIZE, 1,
-      EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
-      EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
-      EGL_NONE};
+    EGLint attribs[] = {EGL_RED_SIZE, 1,
+                        EGL_GREEN_SIZE, 1,
+                        EGL_BLUE_SIZE, 1,
+                        EGL_DEPTH_SIZE, 1,
+                        EGL_STENCIL_SIZE, 1,
+                        EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
+                        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+                        EGL_NONE};
 
     EGLNativeDisplayType native_display =
         static_cast<EGLNativeDisplayType>(g_xlib_display);
diff --git a/src/glx_stuff.cc b/src/glx_stuff.cc
index 5996332..c2909db 100644
--- a/src/glx_stuff.cc
+++ b/src/glx_stuff.cc
@@ -15,7 +15,7 @@
 #define F(fun, type) type fun = NULL;
 LIST_PROC_FUNCTIONS(F)
 #undef F
-};
+};  // namespace gl
 
 #ifndef GLX_MESA_swap_control
 typedef GLint (*PFNGLXSWAPINTERVALMESAPROC)(unsigned interval);
diff --git a/src/main.h b/src/main.h
index a3f39a1..b801d15 100644
--- a/src/main.h
+++ b/src/main.h
@@ -14,11 +14,11 @@
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 
-#define LIST_PROC_FUNCTIONS(F)                                     \
-  F(glBeginQueryEXT, PFNGLBEGINQUERYEXTPROC)                       \
-  F(glEndQueryEXT, PFNGLENDQUERYEXTPROC)                           \
-  F(glDeleteQueriesEXT, PFNGLDELETEQUERIESEXTPROC)                 \
-  F(glGenQueriesEXT, PFNGLGENQUERIESEXTPROC)                       \
+#define LIST_PROC_FUNCTIONS(F)                     \
+  F(glBeginQueryEXT, PFNGLBEGINQUERYEXTPROC)       \
+  F(glEndQueryEXT, PFNGLENDQUERYEXTPROC)           \
+  F(glDeleteQueriesEXT, PFNGLDELETEQUERIESEXTPROC) \
+  F(glGenQueriesEXT, PFNGLGENQUERIESEXTPROC)       \
   F(glGetQueryObjectuivEXT, PFNGLGETQUERYOBJECTUIVEXTPROC)
 
 #elif defined(USE_OPENGL)
@@ -82,7 +82,7 @@
 #define F(fun, type) extern type fun;
 LIST_PROC_FUNCTIONS(F)
 #undef F
-};
+};  // namespace gl
 
 using namespace gl;
 inline uint64_t GetUTime() {
diff --git a/src/png_helper.cc b/src/png_helper.cc
index 43ed005..332c613 100644
--- a/src/png_helper.cc
+++ b/src/png_helper.cc
@@ -39,10 +39,10 @@
     row_pointers[y] = (png_byte*)malloc(4 * width);
     for (x = 0; x < width; x++) {
       png_byte* pixel = &(row_pointers[y][x * 4]);
-      pixel[0] = *(p);  // R
-      pixel[1] = *(p+1);  // G
-      pixel[2] = *(p+2);  // B
-      pixel[3] = *(p+3);  // A
+      pixel[0] = *(p);      // R
+      pixel[1] = *(p + 1);  // G
+      pixel[2] = *(p + 2);  // B
+      pixel[3] = *(p + 3);  // A
       p += 4;
     }
   }
diff --git a/src/querygettest.cc b/src/querygettest.cc
index 462f6ab..d02edb5 100644
--- a/src/querygettest.cc
+++ b/src/querygettest.cc
@@ -19,21 +19,21 @@
 namespace glbench {
 
 class QueryGetTest : public TestBase {
-  public:
-    QueryGetTest() {}
-    virtual ~QueryGetTest() {}
+ public:
+  QueryGetTest() {}
+  virtual ~QueryGetTest() {}
 
-    virtual bool TestFunc(uint64_t iterations);
-    virtual bool Run();
-    virtual const char* Name() const { return "query_get"; }
-    virtual bool IsDrawTest() const { return true; }
-    virtual const char* Unit() const { return "us"; }
+  virtual bool TestFunc(uint64_t iterations);
+  virtual bool Run();
+  virtual const char* Name() const { return "query_get"; }
+  virtual bool IsDrawTest() const { return true; }
+  virtual const char* Unit() const { return "us"; }
 
-  private:
-    std::vector<GLuint> queries_;
-    GLenum target_;
+ private:
+  std::vector<GLuint> queries_;
+  GLenum target_;
 
-    DISALLOW_COPY_AND_ASSIGN(QueryGetTest);
+  DISALLOW_COPY_AND_ASSIGN(QueryGetTest);
 };
 
 bool QueryGetTest::TestFunc(uint64_t iterations) {
@@ -67,7 +67,7 @@
 }
 
 bool QueryGetTest::Run() {
-  const char *exts = (const char *) glGetString(GL_EXTENSIONS);
+  const char* exts = (const char*)glGetString(GL_EXTENSIONS);
   if (!strstr(exts, "GL_ARB_occlusion_query2") &&
       !strstr(exts, "GL_EXT_occlusion_query_boolean")) {
     printf("# Warning: QueryGetTest could not find query extension(s).\n");
@@ -79,8 +79,7 @@
   glGenQueries(queries_.size(), queries_.data());
 
   target_ = GL_ANY_SAMPLES_PASSED;
-  RunTest(this, "query_get_any_samples_passed",
-      1.0, g_width, g_height, false);
+  RunTest(this, "query_get_any_samples_passed", 1.0, g_width, g_height, false);
 
   glDeleteQueries(queries_.size(), queries_.data());
 
@@ -91,4 +90,4 @@
   return new QueryGetTest;
 }
 
-} // namespace glbench
+}  // namespace glbench
diff --git a/src/testbase.cc b/src/testbase.cc
index 8065235..6e20d46 100644
--- a/src/testbase.cc
+++ b/src/testbase.cc
@@ -36,8 +36,9 @@
 }
 
 // Target minimum iteration duration of 0.4s. This means the final/longest
-// iteration is between 0.4s and 0.8s and the machine is active for 0.8s to 1.6s.
-// Notice as of March 2014 the BVT suite has a hard limit per job of 20 minutes.
+// iteration is between 0.4s and 0.8s and the machine is active for 0.8s
+// to 1.6s. Notice as of March 2014 the BVT suite has a hard limit per job of 20
+// minutes.
 #define MIN_ITERATION_DURATION_NS 400000000
 
 #define MAX_TESTNAME 46
@@ -88,7 +89,8 @@
     // by the caller to compute Mpixel/sec.
     if (time > MIN_ITERATION_DURATION_NS / (::g_hasty ? 20.0 : 1.0))
       return (static_cast<double>(time + time_prev) /
-              (iterations + iterations_prev)) / 1000.0;
+              (iterations + iterations_prev)) /
+             1000.0;
 
     time_prev = time;
     iterations_prev = iterations;
diff --git a/src/texturerebind.cc b/src/texturerebind.cc
index a325a85..832ec83 100644
--- a/src/texturerebind.cc
+++ b/src/texturerebind.cc
@@ -20,19 +20,17 @@
   virtual bool IsTextureUploadTest() const { return false; }
 };
 
-
-bool TextureRebindTest::TextureMetaDataInit(){
-    kTexelFormats.push_back(GL_RGBA);
-    kTexelFormatNames[GL_RGBA] = "rgba";
-    kTexelFormatSizes[GL_RGBA] = 4;
-    kFlavors[TEX_IMAGE] = "teximage2d";
-    return true;
+bool TextureRebindTest::TextureMetaDataInit() {
+  kTexelFormats.push_back(GL_RGBA);
+  kTexelFormatNames[GL_RGBA] = "rgba";
+  kTexelFormatSizes[GL_RGBA] = 4;
+  kFlavors[TEX_IMAGE] = "teximage2d";
+  return true;
 }
 
 bool TextureRebindTest::TestFunc(uint64_t iterations) {
   for (uint64_t i = 0; i < iterations; ++i) {
-    for (uint64_t texture_idx = 0;
-         texture_idx < kNumberOfTextures;
+    for (uint64_t texture_idx = 0; texture_idx < kNumberOfTextures;
          texture_idx++) {
       glBindTexture(GL_TEXTURE_2D, textures_[texture_idx]);
       glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
diff --git a/src/texturetest.cc b/src/texturetest.cc
index 4966de8..1e197a6 100644
--- a/src/texturetest.cc
+++ b/src/texturetest.cc
@@ -3,8 +3,8 @@
 // found in the LICENSE file.
 
 #include "texturetest.h"
-#include "arraysize.h"
 #include <assert.h>
+#include "arraysize.h"
 
 namespace glbench {
 
@@ -84,7 +84,7 @@
     texel_gl_format_ = fmt;
     std::string texel_gl_format_name = kTexelFormatNames.at(texel_gl_format_);
     unsigned int texel_size = kTexelFormatSizes[texel_gl_format_];
-    for (auto flv : kFlavors){
+    for (auto flv : kFlavors) {
       flavor_ = flv.first;
       std::string flavor_name = flv.second;
 
@@ -95,8 +95,7 @@
           continue;
 
         std::string name = std::string(Name()) + "_" + texel_gl_format_name +
-                           "_" + flavor_name + "_" +
-                           IntToString(sizes[j]);
+                           "_" + flavor_name + "_" + IntToString(sizes[j]);
 
         width_ = height_ = sizes[j];
         const unsigned int buffer_size = width_ * height_ * texel_size;
@@ -123,9 +122,8 @@
             glBindTexture(GL_TEXTURE_2D, textures_[i]);
             switch (flavor_) {
               case TEX_IMAGE:
-                glTexImage2D(GL_TEXTURE_2D, 0, texel_gl_format_,
-                             width_, height_, 0,
-                             texel_gl_format_, GL_UNSIGNED_BYTE,
+                glTexImage2D(GL_TEXTURE_2D, 0, texel_gl_format_, width_,
+                             height_, 0, texel_gl_format_, GL_UNSIGNED_BYTE,
                              pixels_[i % kNumberOfTextures].get());
                 break;
               case TEX_SUBIMAGE:
diff --git a/src/waffle_stuff.cc b/src/waffle_stuff.cc
index 0cc0d6c..61bd2e3 100644
--- a/src/waffle_stuff.cc
+++ b/src/waffle_stuff.cc
@@ -20,7 +20,7 @@
 #define F(fun, type) type fun = NULL;
 LIST_PROC_FUNCTIONS(F)
 #undef F
-};
+};  // namespace gl
 
 #ifdef USE_OPENGL
 #define GL_API WAFFLE_CONTEXT_OPENGL