1 /*
2  * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef WEBGL_QUERY_H
17 #define WEBGL_QUERY_H
18 
19 #include "napi/n_exporter.h"
20 #include "webgl_object.h"
21 
22 namespace OHOS {
23 namespace Rosen {
24 class WebGLQuery final : public NExporter, public WebGLObject {
25 public:
26     inline static const std::string className = "WebGLQuery";
27     inline static const int objectType = WEBGL_OBJECT_QUERY;
28 
29     bool Export(napi_env env, napi_value exports) override;
30     std::string GetClassName() override;
31     static napi_value Constructor(napi_env env, napi_callback_info info);
WebGLQuery()32     explicit WebGLQuery() : query_(0) {};
WebGLQuery(napi_env env,napi_value exports)33     WebGLQuery(napi_env env, napi_value exports) : NExporter(env, exports), query_(0) {};
~WebGLQuery()34     ~WebGLQuery() {};
35 
CreateObjectInstance(napi_env env,WebGLQuery ** instance)36     static NVal CreateObjectInstance(napi_env env, WebGLQuery** instance)
37     {
38         return WebGLObject::CreateObjectInstance<WebGLQuery>(env, instance);
39     }
40 
SetQuery(unsigned int query)41     void SetQuery(unsigned int query)
42     {
43         query_ = query;
44     }
45 
GetQuery()46     unsigned int GetQuery() const
47     {
48         return query_;
49     }
50 
SetTarget(GLenum target)51     void SetTarget(GLenum target)
52     {
53         target_ = target;
54     }
55 
GetTarget()56     GLenum GetTarget() const
57     {
58         return target_;
59     }
60 private:
61     unsigned int query_;
62     GLenum target_ { 0 };
63 };
64 } // namespace Rosen
65 } // namespace OHOS
66 #endif // WEBGL_QUERY_H
67