Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/canvas/WebGLExtensionDisjointTimerQuery.cpp
Line
Count
Source (jump to first uncovered line)
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 "gfxPrefs.h"
10
#include "GLContext.h"
11
#include "mozilla/dom/ToJSValue.h"
12
#include "mozilla/dom/WebGLRenderingContextBinding.h"
13
#include "mozilla/dom/BindingUtils.h"
14
#include "WebGLContext.h"
15
#include "WebGLQuery.h"
16
17
namespace mozilla {
18
19
WebGLExtensionDisjointTimerQuery::WebGLExtensionDisjointTimerQuery(WebGLContext* webgl)
20
  : WebGLExtensionBase(webgl)
21
0
{
22
0
    MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
23
0
}
24
25
WebGLExtensionDisjointTimerQuery::~WebGLExtensionDisjointTimerQuery()
26
0
{
27
0
}
28
29
already_AddRefed<WebGLQuery>
30
WebGLExtensionDisjointTimerQuery::CreateQueryEXT() const
31
0
{
32
0
    if (mIsLost)
33
0
        return nullptr;
34
0
    const WebGLContext::FuncScope funcScope(*mContext, "createQueryEXT");
35
0
    MOZ_ASSERT(!mContext->IsContextLost());
36
0
37
0
    return mContext->CreateQuery();
38
0
}
39
40
void
41
WebGLExtensionDisjointTimerQuery::DeleteQueryEXT(WebGLQuery* query) const
42
0
{
43
0
    if (mIsLost)
44
0
        return;
45
0
    const WebGLContext::FuncScope funcScope(*mContext, "deleteQueryEXT");
46
0
    MOZ_ASSERT(!mContext->IsContextLost());
47
0
48
0
    mContext->DeleteQuery(query);
49
0
}
50
51
bool
52
WebGLExtensionDisjointTimerQuery::IsQueryEXT(const WebGLQuery* query) const
53
0
{
54
0
    if (mIsLost)
55
0
        return false;
56
0
    const WebGLContext::FuncScope funcScope(*mContext, "isQueryEXT");
57
0
    MOZ_ASSERT(!mContext->IsContextLost());
58
0
59
0
    return mContext->IsQuery(query);
60
0
}
61
62
void
63
WebGLExtensionDisjointTimerQuery::BeginQueryEXT(GLenum target, WebGLQuery& query) const
64
0
{
65
0
    if (mIsLost)
66
0
        return;
67
0
    const WebGLContext::FuncScope funcScope(*mContext, "beginQueryEXT");
68
0
    MOZ_ASSERT(!mContext->IsContextLost());
69
0
70
0
    mContext->BeginQuery(target, query);
71
0
}
72
73
void
74
WebGLExtensionDisjointTimerQuery::EndQueryEXT(GLenum target) const
75
0
{
76
0
    if (mIsLost)
77
0
        return;
78
0
    const WebGLContext::FuncScope funcScope(*mContext, "endQueryEXT");
79
0
    MOZ_ASSERT(!mContext->IsContextLost());
80
0
81
0
    mContext->EndQuery(target);
82
0
}
83
84
void
85
WebGLExtensionDisjointTimerQuery::QueryCounterEXT(WebGLQuery& query, GLenum target) const
86
0
{
87
0
    if (mIsLost)
88
0
        return;
89
0
    const WebGLContext::FuncScope funcScope(*mContext, "queryCounterEXT");
90
0
    MOZ_ASSERT(!mContext->IsContextLost());
91
0
92
0
    if (!mContext->ValidateObject("query", query))
93
0
        return;
94
0
95
0
    query.QueryCounter(target);
96
0
}
97
98
void
99
WebGLExtensionDisjointTimerQuery::GetQueryEXT(JSContext* cx, GLenum target, GLenum pname,
100
                                              JS::MutableHandleValue retval) const
101
0
{
102
0
    retval.setNull();
103
0
    if (mIsLost)
104
0
        return;
105
0
    const WebGLContext::FuncScope funcScope(*mContext, "getQueryEXT");
106
0
    MOZ_ASSERT(!mContext->IsContextLost());
107
0
108
0
    mContext->GetQuery(cx, target, pname, retval);
109
0
}
110
111
void
112
WebGLExtensionDisjointTimerQuery::GetQueryObjectEXT(JSContext* cx,
113
                                                    const WebGLQuery& query, GLenum pname,
114
                                                    JS::MutableHandleValue retval) const
115
0
{
116
0
    retval.setNull();
117
0
    if (mIsLost)
118
0
        return;
119
0
    const WebGLContext::FuncScope funcScope(*mContext, "getQueryObjectEXT");
120
0
    MOZ_ASSERT(!mContext->IsContextLost());
121
0
122
0
    mContext->GetQueryParameter(cx, query, pname, retval);
123
0
}
124
125
bool
126
WebGLExtensionDisjointTimerQuery::IsSupported(const WebGLContext* webgl)
127
0
{
128
0
    gl::GLContext* gl = webgl->GL();
129
0
    return gl->IsSupported(gl::GLFeature::query_objects) &&
130
0
           gl->IsSupported(gl::GLFeature::get_query_object_i64v) &&
131
0
           gl->IsSupported(gl::GLFeature::query_counter); // provides GL_TIMESTAMP
132
0
}
133
134
IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionDisjointTimerQuery, EXT_disjoint_timer_query)
135
136
} // namespace mozilla