Bug 1308057 - Convert WebGLExtensionDisjointTimerQuery.cpp to 4-space.
authorJeff Gilbert (:jgilbert) <jgilbert@mozilla.com>
Fri, 30 Sep 2016 14:04:37 -0700
changeset 367480 7bba645e82e80f590d8d2cccd315c693117d59b1
parent 367479 4402b0c5fcb27bf6e0658a33dc999698bfecd2e4
child 367481 e8992921aab56ad2a02ea5c1f383c629b9aa0250
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1308057
milestone52.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 1308057 - Convert WebGLExtensionDisjointTimerQuery.cpp to 4-space. MozReview-Commit-ID: A9llSqU5ghR
dom/canvas/WebGLExtensionDisjointTimerQuery.cpp
--- a/dom/canvas/WebGLExtensionDisjointTimerQuery.cpp
+++ b/dom/canvas/WebGLExtensionDisjointTimerQuery.cpp
@@ -15,244 +15,252 @@
 #include "WebGLTimerQuery.h"
 
 namespace mozilla {
 
 WebGLExtensionDisjointTimerQuery::WebGLExtensionDisjointTimerQuery(WebGLContext* webgl)
   : WebGLExtensionBase(webgl)
   , mActiveQuery(nullptr)
 {
-  MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
+    MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
 }
 
 WebGLExtensionDisjointTimerQuery::~WebGLExtensionDisjointTimerQuery()
 {
 }
 
 already_AddRefed<WebGLTimerQuery>
 WebGLExtensionDisjointTimerQuery::CreateQueryEXT()
 {
-  if (mIsLost)
-    return nullptr;
+    if (mIsLost)
+        return nullptr;
 
-  RefPtr<WebGLTimerQuery> query = WebGLTimerQuery::Create(mContext);
-  return query.forget();
+    RefPtr<WebGLTimerQuery> query = WebGLTimerQuery::Create(mContext);
+    return query.forget();
 }
 
 void
 WebGLExtensionDisjointTimerQuery::DeleteQueryEXT(WebGLTimerQuery* query)
 {
-  if (mIsLost)
-    return;
+    if (mIsLost)
+        return;
 
-  if (!mContext->ValidateObject("deleteQueryEXT", query))
-    return;
+    if (!mContext->ValidateObject("deleteQueryEXT", query))
+        return;
 
-  query->RequestDelete();
+    query->RequestDelete();
 }
 
 bool
 WebGLExtensionDisjointTimerQuery::IsQueryEXT(WebGLTimerQuery* query)
 {
-  if (!query)
-    return false;
+    if (!query)
+        return false;
 
-  if (!mContext->ValidateObjectAllowDeleted("isQueryEXT", query))
-    return false;
+    if (!mContext->ValidateObjectAllowDeleted("isQueryEXT", query))
+        return false;
 
-  if (query->IsDeleted())
-    return false;
+    if (query->IsDeleted())
+        return false;
 
-  return true;
+    return true;
 }
 
 void
 WebGLExtensionDisjointTimerQuery::BeginQueryEXT(GLenum target,
                                                 WebGLTimerQuery* query)
 {
-  if (mIsLost)
-    return;
+    if (mIsLost)
+        return;
 
-  if (!mContext->ValidateObject("beginQueryEXT", query))
-    return;
+    if (!mContext->ValidateObject("beginQueryEXT", query))
+        return;
 
-  if (query->HasEverBeenBound() && query->Target() != target) {
-    mContext->ErrorInvalidOperation("beginQueryEXT: Query is already bound"
-                                    " to a different target.");
-    return;
-  }
+    if (query->HasEverBeenBound() && query->Target() != target) {
+        mContext->ErrorInvalidOperation("beginQueryEXT: Query is already bound"
+                                        " to a different target.");
+        return;
+    }
 
-  if (target != LOCAL_GL_TIME_ELAPSED_EXT) {
-    mContext->ErrorInvalidEnumInfo("beginQueryEXT: Can only begin on target"
-                                   " TIME_ELAPSED_EXT.", target);
-    return;
-  }
+    if (target != LOCAL_GL_TIME_ELAPSED_EXT) {
+        mContext->ErrorInvalidEnumInfo("beginQueryEXT: Can only begin on target"
+                                       " TIME_ELAPSED_EXT.", target);
+        return;
+    }
 
-  if (mActiveQuery) {
-    mContext->ErrorInvalidOperation("beginQueryEXT: A query is already"
-                                    " active.");
-    return;
-  }
+    if (mActiveQuery) {
+        mContext->ErrorInvalidOperation("beginQueryEXT: A query is already"
+                                        " active.");
+        return;
+    }
 
-  mContext->MakeContextCurrent();
-  gl::GLContext* gl = mContext->GL();
-  gl->fBeginQuery(target, query->mGLName);
-  query->mTarget = LOCAL_GL_TIME_ELAPSED_EXT;
-  mActiveQuery = query;
+    mContext->MakeContextCurrent();
+    gl::GLContext* gl = mContext->GL();
+    gl->fBeginQuery(target, query->mGLName);
+    query->mTarget = LOCAL_GL_TIME_ELAPSED_EXT;
+    mActiveQuery = query;
 }
 
 void
 WebGLExtensionDisjointTimerQuery::EndQueryEXT(GLenum target)
 {
-  if (mIsLost)
-    return;
+    if (mIsLost)
+        return;
 
-  if (target != LOCAL_GL_TIME_ELAPSED_EXT) {
-    mContext->ErrorInvalidEnumInfo("endQueryEXT: Can only end on"
-                                   " TIME_ELAPSED_EXT.", target);
-    return;
-  }
+    if (target != LOCAL_GL_TIME_ELAPSED_EXT) {
+        mContext->ErrorInvalidEnumInfo("endQueryEXT: Can only end on"
+                                       " TIME_ELAPSED_EXT.", target);
+        return;
+    }
 
-  if (!mActiveQuery) {
-    mContext->ErrorInvalidOperation("endQueryEXT: A query is not active.");
-    return;
-  }
+    if (!mActiveQuery) {
+        mContext->ErrorInvalidOperation("endQueryEXT: A query is not active.");
+        return;
+    }
 
-  mContext->MakeContextCurrent();
-  mContext->GL()->fEndQuery(target);
-  mActiveQuery->QueueAvailablity();
-  mActiveQuery = nullptr;
+    mContext->MakeContextCurrent();
+    mContext->GL()->fEndQuery(target);
+    mActiveQuery->QueueAvailablity();
+    mActiveQuery = nullptr;
 }
 
 void
 WebGLExtensionDisjointTimerQuery::QueryCounterEXT(WebGLTimerQuery* query,
                                                   GLenum target)
 {
-  if (mIsLost)
-    return;
+    if (mIsLost)
+        return;
 
-  if (!mContext->ValidateObject("queryCounterEXT", query))
-    return;
+    if (!mContext->ValidateObject("queryCounterEXT", query))
+        return;
 
-  if (target != LOCAL_GL_TIMESTAMP_EXT) {
-    mContext->ErrorInvalidEnumInfo("queryCounterEXT: requires"
-                                   " TIMESTAMP_EXT.", target);
-    return;
-  }
+    if (target != LOCAL_GL_TIMESTAMP_EXT) {
+        mContext->ErrorInvalidEnumInfo("queryCounterEXT: requires"
+                                       " TIMESTAMP_EXT.", target);
+        return;
+    }
 
-  mContext->MakeContextCurrent();
-  mContext->GL()->fQueryCounter(query->mGLName, target);
-  query->mTarget = LOCAL_GL_TIMESTAMP_EXT;
-  query->QueueAvailablity();
+    mContext->MakeContextCurrent();
+    mContext->GL()->fQueryCounter(query->mGLName, target);
+    query->mTarget = LOCAL_GL_TIMESTAMP_EXT;
+    query->QueueAvailablity();
 }
 
 void
 WebGLExtensionDisjointTimerQuery::GetQueryEXT(JSContext* cx, GLenum target,
                                               GLenum pname,
                                               JS::MutableHandle<JS::Value> retval)
 {
-  if (mIsLost)
-    return;
+    if (mIsLost)
+        return;
+
+    mContext->MakeContextCurrent();
+    switch (pname) {
+    case LOCAL_GL_CURRENT_QUERY_EXT:
+        if (target != LOCAL_GL_TIME_ELAPSED_EXT) {
+            mContext->ErrorInvalidEnumInfo("getQueryEXT: Invalid query target.",
+                                           target);
+            return;
+        }
+        if (mActiveQuery) {
+            JS::Rooted<JS::Value> v(cx);
+            dom::GetOrCreateDOMReflector(cx, mActiveQuery.get(), &v);
+            retval.set(v);
+        } else {
+            retval.set(JS::NullValue());
+        }
+        break;
 
-  mContext->MakeContextCurrent();
-  switch (pname) {
-  case LOCAL_GL_CURRENT_QUERY_EXT: {
-    if (target != LOCAL_GL_TIME_ELAPSED_EXT) {
-      mContext->ErrorInvalidEnumInfo("getQueryEXT: Invalid query target.",
-                                     target);
-      return;
-    }
-    if (mActiveQuery) {
-      JS::Rooted<JS::Value> v(cx);
-      dom::GetOrCreateDOMReflector(cx, mActiveQuery.get(), &v);
-      retval.set(v);
-    } else {
-      retval.set(JS::NullValue());
+    case LOCAL_GL_QUERY_COUNTER_BITS_EXT:
+        if (target != LOCAL_GL_TIME_ELAPSED_EXT &&
+            target != LOCAL_GL_TIMESTAMP_EXT)
+        {
+            mContext->ErrorInvalidEnumInfo("getQueryEXT: Invalid query target.",
+                                           target);
+            return;
+        }
+
+        {
+            GLint bits = 0;
+            if (mContext->HasTimestampBits()) {
+                mContext->GL()->fGetQueryiv(target, pname, &bits);
+            }
+            retval.set(JS::Int32Value(int32_t(bits)));
+        }
+        break;
+
+    default:
+        mContext->ErrorInvalidEnumInfo("getQueryEXT: Invalid query property.",
+                                       pname);
+        break;
     }
-    break;
-  }
-  case LOCAL_GL_QUERY_COUNTER_BITS_EXT: {
-    if (target != LOCAL_GL_TIME_ELAPSED_EXT &&
-        target != LOCAL_GL_TIMESTAMP_EXT) {
-      mContext->ErrorInvalidEnumInfo("getQueryEXT: Invalid query target.",
-                                     target);
-      return;
-    }
-    GLint bits = 0;
-    if (mContext->HasTimestampBits()) {
-      mContext->GL()->fGetQueryiv(target, pname, &bits);
-    }
-    retval.set(JS::Int32Value(int32_t(bits)));
-    break;
-  }
-  default:
-    mContext->ErrorInvalidEnumInfo("getQueryEXT: Invalid query property.",
-                                   pname);
-    break;
-  }
 }
 
 void
 WebGLExtensionDisjointTimerQuery::GetQueryObjectEXT(JSContext* cx,
                                                     WebGLTimerQuery* query,
                                                     GLenum pname,
                                                     JS::MutableHandle<JS::Value> retval)
 {
-  if (mIsLost)
-    return;
+    if (mIsLost)
+        return;
 
-  if (!mContext->ValidateObject("getQueryObjectEXT", query))
-    return;
+    if (!mContext->ValidateObject("getQueryObjectEXT", query))
+        return;
 
-  if (query == mActiveQuery.get()) {
-    mContext->ErrorInvalidOperation("getQueryObjectEXT: Query must not be"
-                                    " active.");
-  }
+    if (query == mActiveQuery.get()) {
+        mContext->ErrorInvalidOperation("getQueryObjectEXT: Query must not be"
+                                        " active.");
+    }
 
-  mContext->MakeContextCurrent();
-  // XXX: Note that the query result *may change* within the same task!
-  // This does not follow the specification, which states that all calls
-  // checking query results must return the same value until the event loop
-  // is empty.
-  switch (pname) {
-  case LOCAL_GL_QUERY_RESULT_EXT: {
-    GLuint64 result = 0;
-    mContext->GL()->fGetQueryObjectui64v(query->mGLName,
-                                         LOCAL_GL_QUERY_RESULT_EXT,
-                                         &result);
-    retval.set(JS::NumberValue(result));
-    break;
-  }
-  case LOCAL_GL_QUERY_RESULT_AVAILABLE_EXT: {
-    GLuint avail = 0;
-    mContext->GL()->fGetQueryObjectuiv(query->mGLName,
-                                       LOCAL_GL_QUERY_RESULT_AVAILABLE_EXT,
-                                       &avail);
-    bool canBeAvailable = query->CanBeAvailable() || gfxPrefs::WebGLImmediateQueries();
-    retval.set(JS::BooleanValue(bool(avail) && canBeAvailable));
-    break;
-  }
-  default:
-    mContext->ErrorInvalidEnumInfo("getQueryObjectEXT: Invalid query"
-                                   " property.", pname);
-    break;
-  }
+    mContext->MakeContextCurrent();
+    // XXX: Note that the query result *may change* within the same task!
+    // This does not follow the specification, which states that all calls
+    // checking query results must return the same value until the event loop
+    // is empty.
+    switch (pname) {
+    case LOCAL_GL_QUERY_RESULT_EXT:
+        {
+            GLuint64 result = 0;
+            mContext->GL()->fGetQueryObjectui64v(query->mGLName,
+                                                 LOCAL_GL_QUERY_RESULT_EXT,
+                                                 &result);
+            retval.set(JS::NumberValue(result));
+        }
+        break;
+
+    case LOCAL_GL_QUERY_RESULT_AVAILABLE_EXT:
+        {
+            GLuint avail = 0;
+            mContext->GL()->fGetQueryObjectuiv(query->mGLName,
+                                               LOCAL_GL_QUERY_RESULT_AVAILABLE_EXT,
+                                               &avail);
+            bool canBeAvailable = query->CanBeAvailable() || gfxPrefs::WebGLImmediateQueries();
+            retval.set(JS::BooleanValue(bool(avail) && canBeAvailable));
+        }
+        break;
+
+    default:
+        mContext->ErrorInvalidEnumInfo("getQueryObjectEXT: Invalid query"
+                                       " property.", pname);
+        break;
+    }
 }
 
 bool
 WebGLExtensionDisjointTimerQuery::IsSupported(const WebGLContext* webgl)
 {
-  webgl->MakeContextCurrent();
-  gl::GLContext* gl = webgl->GL();
-  return gl->IsSupported(gl::GLFeature::query_objects) &&
-         gl->IsSupported(gl::GLFeature::get_query_object_i64v) &&
-         gl->IsSupported(gl::GLFeature::query_counter); // provides GL_TIMESTAMP
+    webgl->MakeContextCurrent();
+    gl::GLContext* gl = webgl->GL();
+    return gl->IsSupported(gl::GLFeature::query_objects) &&
+           gl->IsSupported(gl::GLFeature::get_query_object_i64v) &&
+           gl->IsSupported(gl::GLFeature::query_counter); // provides GL_TIMESTAMP
 }
 
 void
 WebGLExtensionDisjointTimerQuery::OnMarkLost()
 {
-  mActiveQuery = nullptr;
+    mActiveQuery = nullptr;
 }
 
 IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionDisjointTimerQuery, EXT_disjoint_timer_query)
 
 } // namespace mozilla