Signed-off-by: huangji731 <huangji731@huawei.com>
This commit is contained in:
huangji731 2024-11-02 17:03:23 +08:00
parent 8ec3018a9f
commit 4b7a102b3c
5 changed files with 298 additions and 0 deletions

View File

@ -17,6 +17,7 @@ import("//build/ohos/ndk/ndk.gni")
ohos_ndk_headers("display_manager_header") {
dest_dir = "$ndk_headers_out_dir/window_manager"
sources = [
"oh_display_capture.h",
"oh_display_info.h",
"oh_display_manager.h",
]
@ -28,6 +29,7 @@ ohos_ndk_library("native_display_manager") {
ndk_description_file = "./libdm.ndk.json"
system_capability = "SystemCapability.Window.SessionManager"
system_capability_headers = [
"oh_display_capture.h",
"oh_display_info.h",
"oh_display_manager.h",
]

View File

@ -78,5 +78,29 @@
{
"first_instroduced":"12",
"name":"OH_NativeDisplayManager_UnregisterDisplayChangeListener"
},
{
"first_instroduced":"14",
"name":"OH_NativeDisplayManager_CreatePrimaryDisplay"
},
{
"first_instroduced":"14",
"name":"OH_NativeDisplayManager_CreateDisplayById"
},
{
"first_instroduced":"14",
"name":"OH_NativeDisplayManager_DestroyDisplay"
},
{
"first_instroduced":"14",
"name":"OH_NativeDisplayManager_CreateAllDisplays"
},
{
"first_instroduced":"14",
"name":"OH_NativeDisplayManager_DestroyAllDisplays"
},
{
"first_instroduced":"14",
"name":"OH_NativeDisplayManager_CaptureScreenPixelmap"
}
]

View File

@ -0,0 +1,69 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @addtogroup OH_DisplayCapture
* @{
*
* @brief Defines the data structures for the C APIs of the display module.
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @since 14
* @version 1.0
*/
/**
* @file oh_display_capture.h
*
* @brief Defines the data structures for the C APIs of the display capture.
*
* @kit ArkUI
* @library libnative_display_manager.so
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @since 14
* @version 1.0
*/
#ifndef OH_NATIVE_DISPLAY_CAPTURE_H
#define OH_NATIVE_DISPLAY_CAPTURE_H
#include "multimedia/image_framework/image/pixelmap_native.h"
#include "oh_display_info.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Capture a screen pixelmap of the specified display.
*
* @param displayId The ID of the display to be captured.
* @param pixelMap The output pixel map of the captured display.
* @return { @link DISPLAY_MANAGER_OK } If the operation is successful.
* { @link DISPLAY_MANAGER_ERROR_NO_PERMISSION } If no permission.
* { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
* { @link DISPLAY_MANAGER_ERROR_DEVICE_NOT_SUPPORTED } If device not support.
* { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
* @syscap SystemCapability.Window.SessionManager.Core
* @since 14
*/
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CaptureScreenPixelmap(uint32_t displayId,
OH_PixelmapNative **pixelMap);
#ifdef __cplusplus
}
#endif
/** @} */
#endif // OH_NATIVE_DISPLAY_CAPTURE_H

View File

@ -45,6 +45,12 @@
extern "C" {
#endif
/**
* @brief display name length
* @since 14
*/
#define OH_DISPLAY_NAME_LENGTH 32
/**
* @brief Enumerates rotations.
*
@ -197,6 +203,145 @@ typedef struct {
NativeDisplayManager_WaterfallDisplayAreaRects waterfallDisplayAreaRects;
} NativeDisplayManager_CutoutInfo;
/**
* @brief Enumerates of the display state.
*
* @since 14
* @version 1.0
*/
typedef enum {
/** display state unknown */
DISPLAY_MANAGER_DISPLAY_STATE_UNKNOWN = 0,
/** display state off */
DISPLAY_MANAGER_DISPLAY_STATE_OFF = 1,
/** display state on */
DISPLAY_MANAGER_DISPLAY_STATE_ON = 2,
/** display state doze */
DISPLAY_MANAGER_DISPLAY_STATE_DOZE = 3,
/** display state doze suspend */
DISPLAY_MANAGER_DISPLAY_STATE_DOZE_SUSPEND = 4,
/** display state vr */
DISPLAY_MANAGER_DISPLAY_STATE_VR = 5,
/** display state on suspend */
DISPLAY_MANAGER_DISPLAY_STATE_ON_SUSPEND = 6,
} NativeDisplayManager_DisplayState;
/**
* @brief Defines the display hdr structure.
*
* @since 14
* @version 1.0
*/
typedef struct {
/** hdrFormat length */
uint32_t hdrFormatLength;
/** hdrFormat pointer */
uint32_t *hdrFormats;
} NativeDisplayManager_DisplayHdrFormat;
/**
* @brief Defines the display color space structure.
*
* @since 14
* @version 1.0
*/
typedef struct {
/** color space length */
uint32_t colorSpaceLength;
/** color space pointer */
uint32_t *colorSpaces;
} NativeDisplayManager_DisplayColorSpace;
/**
* @brief Defines the display structure.
*
* @since 14
* @version 1.0
*/
typedef struct {
/** display id */
uint32_t id;
/** display name */
char name[OH_DISPLAY_NAME_LENGTH + 1];
/** display is alive */
bool isAlive;
/** display width */
int32_t width;
/** display height */
int32_t height;
/** display physical width */
int32_t physicalWidth;
/** display physical height */
int32_t physicalHeight;
/** display refresh rate */
uint32_t refreshRate;
/** display available width */
uint32_t availableWidth;
/** display available height */
uint32_t availableHeight;
/** display density dpi */
float densityDPI;
/** display density pixels */
float densityPixels;
/** display scale density */
float scaledDensity;
/** display xdpi*/
float xDPI;
/** display ydpi */
float yDPI;
/** display rotation */
NativeDisplayManager_Rotation rotation;
/** display state */
NativeDisplayManager_DisplayState state;
/** display orientation */
NativeDisplayManager_Orientation orientation;
/** display hdr format */
NativeDisplayManager_DisplayHdrFormat *hdrFormat;
/** display color space */
NativeDisplayManager_DisplayColorSpace *colorSpace;
} NativeDisplayManager_DisplayInfo;
/**
* @brief Defines the displays structure.
*
* @since 14
* @version 1.0
*/
typedef struct {
/** displays length */
uint32_t displaysLength;
/** displays pointer */
NativeDisplayManager_DisplayInfo *displaysInfo;
} NativeDisplayManager_DisplaysInfo;
#ifdef __cplusplus
}
#endif

View File

@ -311,6 +311,64 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterFoldDisplayModeCh
*/
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener(uint32_t listenerIndex);
/**
* @brief Create all displays.
*
* @param allDisplays Output parameter for all displays information.
* @return { @link DISPLAY_MANAGER_OK } If the operation is successful.
* { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
* { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
* @syscap SystemCapability.Window.SessionManager.Core
* @since 14
*/
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAllDisplays(
NativeDisplayManager_DisplaysInfo **allDisplays);
/**
* @brief Destroy all displays.
*
* @param allDisplays all displays to be free.
* @syscap SystemCapability.Window.SessionManager.Core
* @since 14
*/
void OH_NativeDisplayManager_DestroyAllDisplays(NativeDisplayManager_DisplaysInfo *allDisplays);
/**
* @brief Create display information by display id.
*
* @param displayId The display id.
* @param displayInfo The pointer to the display information.
* @return { @link DISPLAY_MANAGER_OK } If the operation is successful.
* { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
* { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
* @syscap SystemCapability.Window.SessionManager.Core
* @since 14
*/
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDisplayById(uint32_t displayId,
NativeDisplayManager_DisplayInfo **displayInfo);
/**
* @brief Destroy the display information.
*
* @param displayInfo the target display to be free.
* @syscap SystemCapability.Window.SessionManager.Core
* @since 14
*/
void OH_NativeDisplayManager_DestroyDisplay(NativeDisplayManager_DisplayInfo *displayInfo);
/**
* @brief Create a primary display.
*
* @param displayInfo The information of the created display.
* @return { @link DISPLAY_MANAGER_OK } If the operation is successful.
* { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
* { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
* @syscap SystemCapability.Window.SessionManager.Core
* @since 14
*/
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreatePrimaryDisplay(
NativeDisplayManager_DisplayInfo **displayInfo);
#ifdef __cplusplus
}
#endif