• 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
16import screen from '@ohos.screen'
17import Logger from '../model/Logger'
18
19const TAG: string = '[DisplayModel]'
20
21export class DisplayModel {
22  async createVirtualScreen(id: number) {
23    let result = await screen.createVirtualScreen({
24      name: `screen_${id}`,
25      width: 480,
26      height: 360,
27      density: 60,
28      surfaceId: `${id}`
29    })
30    Logger.info(TAG, `createVirtualScreen screen.id = ${result.id}`)
31    let info = await screen.makeExpand([{ screenId: result.id, startX: 0, startY: 0 }])
32    Logger.info(TAG, `makeExpand number = ${info}`)
33    return result
34  }
35
36  async destroyVirtualScreen(id: number) {
37    await screen.destroyVirtualScreen(id)
38    Logger.info(TAG, `destroyVirtualScreen is success`)
39  }
40}