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_DISPLAY_H 17 #define OHOS_JS_DISPLAY_H 18 #include <js_runtime_utils.h> 19 #include <native_engine/native_engine.h> 20 #include <native_engine/native_value.h> 21 #include <refbase.h> 22 23 #include "cutout_info.h" 24 #include "display.h" 25 #include "dm_common.h" 26 27 namespace OHOS { 28 namespace Rosen { 29 enum class ColorSpace : uint32_t { 30 UNKNOWN = 0, 31 ADOBE_RGB = 1, 32 BT2020_HLG = 2, 33 BT2020_PQ = 3, 34 BT601_EBU = 4, 35 BT601_SMPTE_C = 5, 36 BT709 = 6, 37 P3_HLG = 7, 38 P3_PQ = 8, 39 DISPLAY_P3 = 9, 40 SRGB = 10, 41 LINEAR_SRGB = 11, 42 LINEAR_P3 = 12, 43 LINEAR_BT2020 = 13, 44 }; 45 46 enum class HDRFormat : uint32_t { 47 NONE = 0, 48 VIDEO_HLG = 1, 49 VIDEO_HDR10 = 2, 50 VIDEO_HDR_VIVID = 3, 51 IMAGE_HDR_VIVID_DUAL = 4, 52 IMAGE_HDR_VIVID_SINGLE = 5, 53 IMAGE_HDR_ISO_DUAL = 6, 54 IMAGE_HDR_ISO_SINGLE = 7, 55 }; 56 57 std::shared_ptr<NativeReference> FindJsDisplayObject(DisplayId displayId); 58 napi_value CreateJsDisplayObject(napi_env env, sptr<Display>& display); 59 napi_value CreateJsCutoutInfoObject(napi_env env, sptr<CutoutInfo> cutoutInfo); 60 napi_value CreateJsRectObject(napi_env env, DMRect rect); 61 napi_value CreateJsWaterfallDisplayAreaRectsObject(napi_env env, 62 WaterfallDisplayAreaRects waterfallDisplayAreaRects); 63 napi_value CreateJsBoundingRectsArrayObject(napi_env env, std::vector<DMRect> boundingRects); 64 napi_value NapiGetUndefined(napi_env env); 65 napi_valuetype GetType(napi_env env, napi_value value); 66 class JsDisplay final { 67 public: 68 explicit JsDisplay(const sptr<Display>& display); 69 ~JsDisplay(); 70 static void Finalizer(napi_env env, void* data, void* hint); 71 static napi_value GetCutoutInfo(napi_env env, napi_callback_info info); 72 static napi_value HasImmersiveWindow(napi_env env, napi_callback_info info); 73 static napi_value GetSupportedColorSpaces(napi_env env, napi_callback_info info); 74 static napi_value GetSupportedHDRFormats(napi_env env, napi_callback_info info); 75 static napi_value GetAvailableArea(napi_env env, napi_callback_info info); 76 77 private: 78 sptr<Display> display_ = nullptr; 79 napi_value OnGetCutoutInfo(napi_env env, napi_callback_info info); 80 napi_value OnHasImmersiveWindow(napi_env env, napi_callback_info info); 81 napi_value OnGetSupportedColorSpaces(napi_env env, napi_callback_info info); 82 napi_value OnGetSupportedHDRFormats(napi_env env, napi_callback_info info); 83 napi_value OnGetAvailableArea(napi_env env, napi_callback_info info); 84 }; 85 enum class DisplayStateMode : uint32_t { 86 STATE_UNKNOWN = 0, 87 STATE_OFF, 88 STATE_ON, 89 STATE_DOZE, 90 STATE_DOZE_SUSPEND, 91 STATE_VR, 92 STATE_ON_SUSPEND 93 }; 94 } // namespace Rosen 95 } // namespace OHOS 96 #endif