• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SCREEN_H
17 #define OHOS_JS_SCREEN_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 "screen.h"
24 
25 namespace OHOS {
26 namespace Rosen {
27 napi_value CreateJsScreenObject(napi_env env, sptr<Screen>& screen);
28 napi_value CreateJsScreenModeArrayObject(napi_env env, std::vector<sptr<SupportedScreenModes>> screenModes);
29 napi_value CreateJsScreenModeObject(napi_env env, const sptr<SupportedScreenModes>& mode);
30 napi_value NapiGetUndefined(napi_env env);
31 napi_valuetype GetType(napi_env env, napi_value value);
32 class JsScreen final {
33 public:
34     explicit JsScreen(const sptr<Screen>& screen);
35     ~JsScreen();
36     static void Finalizer(napi_env env, void* data, void* hint);
37     static napi_value SetScreenActiveMode(napi_env env, napi_callback_info info);
38     static napi_value SetOrientation(napi_env env, napi_callback_info info);
39     static napi_value SetDensityDpi(napi_env env, napi_callback_info info);
40 
41 private:
42     sptr<Screen> screen_ = nullptr;
43     napi_value OnSetOrientation(napi_env env, napi_callback_info info);
44     napi_value OnSetScreenActiveMode(napi_env env, napi_callback_info info);
45     napi_value OnSetDensityDpi(napi_env env, napi_callback_info info);
46     void NapiSendDmsEvent(napi_env env, std::function<void()> asyncTask,
47         std::unique_ptr<AbilityRuntime::NapiAsyncTask>& napiAsyncTask);
48 };
49 }  // namespace Rosen
50 }  // namespace OHOS
51 #endif