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_SHADER_PRECISION_FORMAT_H 17 #define WEBGL_SHADER_PRECISION_FORMAT_H 18 19 #include "napi/n_exporter.h" 20 #include "webgl_object.h" 21 22 namespace OHOS { 23 namespace Rosen { 24 class WebGLShaderPrecisionFormat final : public NExporter, public WebGLObject { 25 public: 26 inline static const std::string className = "WebGLShaderPrecisionFormat"; 27 inline static const int objectType = WEBGL_OBJECT_SHADER; 28 29 bool Export(napi_env env, napi_value exports) override; 30 31 std::string GetClassName() override; 32 33 static napi_value Constructor(napi_env env, napi_callback_info info); 34 static WebGLShaderPrecisionFormat *GetObjectFromArg(napi_env env, napi_callback_info info); 35 static napi_value GetShaderPrecisionFormatRangeMin(napi_env env, napi_callback_info info); 36 static napi_value GetShaderPrecisionFormatRangeMax(napi_env env, napi_callback_info info); 37 static napi_value GetShaderPrecisionFormatPrecision(napi_env env, napi_callback_info info); CreateObjectInstance(napi_env env,WebGLShaderPrecisionFormat ** instance)38 static NVal CreateObjectInstance(napi_env env, WebGLShaderPrecisionFormat **instance) 39 { 40 return WebGLObject::CreateObjectInstance<WebGLShaderPrecisionFormat>(env, instance); 41 } 42 SetShaderPrecisionFormatRangeMin(int rangeMin)43 void SetShaderPrecisionFormatRangeMin(int rangeMin) 44 { 45 rangeMin_ = rangeMin; 46 } 47 SetShaderPrecisionFormatRangeMax(int rangeMax)48 void SetShaderPrecisionFormatRangeMax(int rangeMax) 49 { 50 rangeMax_ = rangeMax; 51 } 52 SetShaderPrecisionFormatPrecision(int precision)53 void SetShaderPrecisionFormatPrecision(int precision) 54 { 55 precision_ = precision; 56 } 57 GetShaderPrecisionFormatRangeMin()58 int GetShaderPrecisionFormatRangeMin() const 59 { 60 return rangeMin_; 61 } 62 GetShaderPrecisionFormatRangeMax()63 int GetShaderPrecisionFormatRangeMax() const 64 { 65 return rangeMax_; 66 } 67 GetShaderPrecisionFormatPrecision()68 int GetShaderPrecisionFormatPrecision() const 69 { 70 return precision_; 71 } WebGLShaderPrecisionFormat()72 explicit WebGLShaderPrecisionFormat() : rangeMin_(0), rangeMax_(0), precision_(0) {}; 73 WebGLShaderPrecisionFormat(napi_env env,napi_value exports)74 WebGLShaderPrecisionFormat(napi_env env, napi_value exports) : NExporter(env, exports), 75 rangeMin_(0), rangeMax_(0), precision_(0) {}; 76 ~WebGLShaderPrecisionFormat()77 ~WebGLShaderPrecisionFormat() {}; 78 private: 79 int rangeMin_; 80 int rangeMax_; 81 int precision_; 82 }; 83 } // namespace Rosen 84 } // namespace OHOS 85 #endif // WEBGL_SHADER_PRECISION_FORMAT_H 86