1 /* 2 * Copyright (c) 2022 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 OHOS_JS_COLOR_SPACE_H 17 #define OHOS_JS_COLOR_SPACE_H 18 19 #include <memory> 20 21 #include "color_space.h" 22 #include "native_engine/native_engine.h" 23 #include "native_engine/native_value.h" 24 25 namespace OHOS { 26 namespace ColorManager { 27 void BindFunctions(NativeEngine& engine, NativeObject* object); 28 class JsColorSpace final { 29 public: JsColorSpace(const std::shared_ptr<ColorSpace> & colorSpace)30 explicit JsColorSpace(const std::shared_ptr<ColorSpace>& colorSpace) : colorSpaceToken_(colorSpace) {}; ~JsColorSpace()31 ~JsColorSpace() {}; 32 static void Finalizer(NativeEngine* engine, void* data, void* hint); 33 static NativeValue* GetColorSpaceName(NativeEngine* engine, NativeCallbackInfo* info); 34 static NativeValue* GetWhitePoint(NativeEngine* engine, NativeCallbackInfo* info); 35 static NativeValue* GetGamma(NativeEngine* engine, NativeCallbackInfo* info); GetColorSpaceToken()36 inline const std::shared_ptr<ColorSpace>& GetColorSpaceToken() const 37 { 38 return colorSpaceToken_; 39 } 40 41 private: 42 NativeValue* OnGetColorSpaceName(NativeEngine& engine, NativeCallbackInfo& info); 43 NativeValue* OnGetWhitePoint(NativeEngine& engine, NativeCallbackInfo& info); 44 NativeValue* OnGetGamma(NativeEngine& engine, NativeCallbackInfo& info); 45 46 std::shared_ptr<ColorSpace> colorSpaceToken_; 47 }; 48 } // namespace ColorManager 49 } // namespace OHOS 50 51 #endif // OHOS_JS_COLOR_SPACE_H 52