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_ACTIVEINFO_H
17 #define WEBGL_ACTIVEINFO_H
18 
19 #include <GLES2/gl2.h>
20 #include <GLES3/gl31.h>
21 #include <GLES2/gl2ext.h>
22 
23 #include "napi/n_exporter.h"
24 #include "webgl_object.h"
25 
26 #define WEBGL_ACTIVE_INFO_NAME_MAX_LENGTH 128
27 
28 namespace OHOS {
29 namespace Rosen {
30 class WebGLActiveInfo final : public NExporter, public WebGLObject {
31 public:
32     inline static const std::string className = "WebGLActiveInfo";
33     inline static const int objectType = WEBGL_OBJECT_ACTIVE_INFO;
34 
35     bool Export(napi_env env, napi_value exports) override;
36     std::string GetClassName() override;
37     static napi_value Constructor(napi_env env, napi_callback_info info);
38     static WebGLActiveInfo *GetWebGLActiveInfo(napi_env env, napi_callback_info info);
39     static napi_value GetActiveName(napi_env env, napi_callback_info info);
40     static napi_value GetActiveSize(napi_env env, napi_callback_info info);
41     static napi_value GetActiveType(napi_env env, napi_callback_info info);
CreateObjectInstance(napi_env env,WebGLActiveInfo ** instance)42     static NVal CreateObjectInstance(napi_env env, WebGLActiveInfo **instance)
43     {
44         return WebGLObject::CreateObjectInstance<WebGLActiveInfo>(env, instance);
45     }
46 
SetActiveName(const GLchar * activename,uint32_t activenameLength)47     void SetActiveName(const GLchar* activename, uint32_t activenameLength)
48     {
49         if (activenameLength > WEBGL_ACTIVE_INFO_NAME_MAX_LENGTH) {
50             return;
51         }
52         name_ = activename;
53     }
54 
SetActiveSize(int activesize)55     void SetActiveSize(int activesize)
56     {
57         size_ = activesize;
58     }
59 
SetActiveType(int activetype)60     void SetActiveType(int activetype)
61     {
62         type_ = activetype;
63     }
64 
GetActiveName()65     std::string GetActiveName() const
66     {
67         return name_;
68     }
69 
GetActiveSize()70     int GetActiveSize() const
71     {
72         return size_;
73     }
74 
GetActiveType()75     int GetActiveType() const
76     {
77         return type_;
78     }
79 
WebGLActiveInfo()80     explicit WebGLActiveInfo() : size_(0), type_(0) {};
81 
WebGLActiveInfo(napi_env env,napi_value exports)82     WebGLActiveInfo(napi_env env, napi_value exports) : NExporter(env, exports), size_(0), type_(0) {};
~WebGLActiveInfo()83     ~WebGLActiveInfo() {};
84 private:
85     std::string name_;
86     int size_;
87     int type_;
88 };
89 } // namespace Rosen
90 } // namespace OHOS
91 #endif // WEBGL_ACTIVEINFO_H
92