1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #include "WebGLExtensions.h"
8 
9 #include "GLContext.h"
10 #include "mozilla/dom/WebGLRenderingContextBinding.h"
11 #include "mozilla/dom/BindingUtils.h"
12 #include "mozilla/StaticPrefs_webgl.h"
13 #include "WebGLContext.h"
14 #include "WebGLQuery.h"
15 
16 namespace mozilla {
17 
WebGLExtensionDisjointTimerQuery(WebGLContext * webgl)18 WebGLExtensionDisjointTimerQuery::WebGLExtensionDisjointTimerQuery(
19     WebGLContext* webgl)
20     : WebGLExtensionBase(webgl) {
21   MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
22 }
23 
IsSupported(const WebGLContext * const webgl)24 bool WebGLExtensionDisjointTimerQuery::IsSupported(
25     const WebGLContext* const webgl) {
26   if (!StaticPrefs::webgl_enable_privileged_extensions()) return false;
27 
28   gl::GLContext* gl = webgl->GL();
29   return gl->IsSupported(gl::GLFeature::query_objects) &&
30          gl->IsSupported(gl::GLFeature::get_query_object_i64v) &&
31          gl->IsSupported(
32              gl::GLFeature::query_counter);  // provides GL_TIMESTAMP
33 }
34 
35 }  // namespace mozilla
36