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_SAMPLER_H
17 #define WEBGL_SAMPLER_H
18 
19 #include "napi/n_exporter.h"
20 #include "webgl_object.h"
21 
22 namespace OHOS {
23 namespace Rosen {
24 class WebGLSampler final : public NExporter, public WebGLObject {
25 public:
26     inline static const std::string className = "WebGLSampler";
27     inline static const int objectType = WEBGL_OBJECT_SAMPLE;
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);
CreateObjectInstance(napi_env env,WebGLSampler ** instance)32     static NVal CreateObjectInstance(napi_env env, WebGLSampler **instance)
33     {
34         return WebGLObject::CreateObjectInstance<WebGLSampler>(env, instance);
35     }
36 
SetSampler(GLuint sampler)37     void SetSampler(GLuint sampler)
38     {
39         samplerId_ = sampler;
40     }
41 
GetSampler()42     GLuint GetSampler() const
43     {
44         return samplerId_;
45     }
46 
WebGLSampler()47     explicit WebGLSampler() : samplerId_(0) {};
WebGLSampler(napi_env env,napi_value exports)48     WebGLSampler(napi_env env, napi_value exports) : NExporter(env, exports), samplerId_(0) {};
~WebGLSampler()49     ~WebGLSampler() {};
50 
SetSampleUnit(GLuint unit)51     void SetSampleUnit(GLuint unit)
52     {
53         unit_ = unit;
54     }
55 
GetSampleUnit()56     GLuint GetSampleUnit() const
57     {
58         return unit_;
59     }
60 private:
61     GLuint unit_ {};
62     GLuint samplerId_ {};
63 };
64 } // namespace Rosen
65 } // namespace OHOS
66 #endif // WEBGL_SAMPLER_H
67