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_UNIFORM_LOCATION_H 17 #define WEBGL_UNIFORM_LOCATION_H 18 19 #include "napi/n_exporter.h" 20 #include "webgl_object.h" 21 22 namespace OHOS { 23 namespace Rosen { 24 class WebGLUniformLocation final : public NExporter, public WebGLObject { 25 public: 26 inline static const std::string className = "WebGLUniformLocation"; 27 inline static const int objectType = WEBGL_OBJECT_UNIFORM_LOCATION; 28 inline static const int DEFAULT_ID = 0; 29 30 bool Export(napi_env env, napi_value exports) override; 31 std::string GetClassName() override; 32 static napi_value Constructor(napi_env env, napi_callback_info info); CreateObjectInstance(napi_env env,WebGLUniformLocation ** instance)33 static NVal CreateObjectInstance(napi_env env, WebGLUniformLocation** instance) 34 { 35 return WebGLObject::CreateObjectInstance<WebGLUniformLocation>(env, instance); 36 } 37 SetUniformLocationId(int location)38 void SetUniformLocationId(int location) 39 { 40 location_ = location; 41 } 42 GetUniformLocationId()43 int GetUniformLocationId() const 44 { 45 return location_; 46 } 47 WebGLUniformLocation()48 explicit WebGLUniformLocation() : location_(0) {}; WebGLUniformLocation(napi_env env,napi_value exports)49 WebGLUniformLocation(napi_env env, napi_value exports) : NExporter(env, exports), location_(0) {}; ~WebGLUniformLocation()50 ~WebGLUniformLocation() {}; 51 GetObjectInstance(napi_env env,napi_value obj)52 static WebGLUniformLocation* GetObjectInstance(napi_env env, napi_value obj) 53 { 54 return WebGLObject::GetObjectInstance<WebGLUniformLocation>(env, obj); 55 } 56 GetUniformLocationName()57 const std::string &GetUniformLocationName() const 58 { 59 return name_; 60 } 61 SetUniformLocationName(const std::string & name)62 void SetUniformLocationName(const std::string &name) 63 { 64 name_ = std::move(name); 65 } 66 private: 67 std::string name_ {}; 68 int location_; 69 }; 70 } // namespace Rosen 71 } // namespace OHOS 72 #endif // WEBGL_UNIFORM_LOCATION_H 73