• 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 NativeValue* CreateJsScreenObject(NativeEngine& engine, sptr<Screen>& screen);
28 NativeValue* CreateJsScreenModeArrayObject(NativeEngine& engine, std::vector<sptr<SupportedScreenModes>> screenModes);
29 NativeValue* CreateJsScreenModeObject(NativeEngine &engine, const sptr<SupportedScreenModes>& mode);
30 class JsScreen final {
31 public:
32     explicit JsScreen(const sptr<Screen>& screen);
33     ~JsScreen();
34     static void Finalizer(NativeEngine* engine, void* data, void* hint);
35     static NativeValue* SetScreenActiveMode(NativeEngine* engine, NativeCallbackInfo* info);
36     static NativeValue* SetOrientation(NativeEngine* engine, NativeCallbackInfo* info);
37     static NativeValue* SetDensityDpi(NativeEngine* engine, NativeCallbackInfo* info);
38 
39 private:
40     sptr<Screen> screen_ = nullptr;
41     NativeValue* OnSetOrientation(NativeEngine& engine, NativeCallbackInfo& info);
42     NativeValue* OnSetScreenActiveMode(NativeEngine& engine, NativeCallbackInfo& info);
43     NativeValue* OnSetDensityDpi(NativeEngine& engine, NativeCallbackInfo& info);
44 };
45 }  // namespace Rosen
46 }  // namespace OHOS
47 #endif