diff --git a/arkui/display_manager/BUILD.gn b/arkui/display_manager/BUILD.gn index bfdc284acda20515b269782ea6ddcaebf769b548..ba052e0a375ab34f32e1e43c3952fcf931ad1bd3 100644 --- a/arkui/display_manager/BUILD.gn +++ b/arkui/display_manager/BUILD.gn @@ -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", ] diff --git a/arkui/display_manager/libdm.ndk.json b/arkui/display_manager/libdm.ndk.json index 5efd5356188e93a41c7d2873114918b8a8747932..4683811e51c5a2a1f4351182d42c9d9922c6d008 100644 --- a/arkui/display_manager/libdm.ndk.json +++ b/arkui/display_manager/libdm.ndk.json @@ -78,5 +78,29 @@ { "first_instroduced":"12", "name":"OH_NativeDisplayManager_UnregisterDisplayChangeListener" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_CreatePrimaryDisplay" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_CreateDisplayInfoById" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_DestroyDisplayInfo" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_CreateAllDisplays" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_DestroyAllDisplays" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_CreateScreenCapture" } ] \ No newline at end of file diff --git a/arkui/display_manager/oh_display_capture.h b/arkui/display_manager/oh_display_capture.h new file mode 100644 index 0000000000000000000000000000000000000000..a49c70b7cc052eb72509a51a0b42337270ab1289 --- /dev/null +++ b/arkui/display_manager/oh_display_capture.h @@ -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 Creates a screen capture 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_CreateScreenCapture(uint32_t displayId, + OH_PixelmapNative **pixelMap); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // OH_NATIVE_DISPLAY_CAPTURE_H diff --git a/arkui/display_manager/oh_display_info.h b/arkui/display_manager/oh_display_info.h index 3b61758845a8af4f163934a599c10274284c99c8..2a4bda3fb7643a3de473854eb0dc58f5c2674331 100644 --- a/arkui/display_manager/oh_display_info.h +++ b/arkui/display_manager/oh_display_info.h @@ -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 diff --git a/arkui/display_manager/oh_display_manager.h b/arkui/display_manager/oh_display_manager.h index a3b9f3444d7d260e3468ad680c15a941ebf3dc60..6145636dbe4c9140b028199872939b533efb54e6 100644 --- a/arkui/display_manager/oh_display_manager.h +++ b/arkui/display_manager/oh_display_manager.h @@ -311,6 +311,63 @@ 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 Destroys 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_CreateDisplayInfoById(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_DestroyDisplayInfo(NativeDisplayManager_DisplayInfo *displayInfo); + +/** + * @brief Creates 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