diff --git a/OAT.xml b/OAT.xml index 03bcd02b..1f2feceb 100644 --- a/OAT.xml +++ b/OAT.xml @@ -62,6 +62,7 @@ Note:If the text contains special characters, please escape them according to th + diff --git a/README.md b/README.md deleted file mode 100644 index 622d01ba..00000000 --- a/README.md +++ /dev/null @@ -1,715 +0,0 @@ -# WidnowManager - -- [Introduction](#section1333751883213) -- [Directory Structure](#section1882912343) -- [Constraints](#section68982123611) -- [Compilation and Building](#section671864110372) -- [Available APIs](#section197399520386) - - [WindowManager](#section5851104093816) - - [Window](#section3483122273912) - - [SubWindow](#section96481249183913) - - [Surface](#section12366161544010) - - [SurfaceBuffer](#section12001640184711) - - [VsyncHelper](#section1392116294211) - -- [Usage](#section18359134910422) - - [Transferring a Producer Surface](#section193464304411) - - [Creating a Producer Surface](#section1276823075112) - - [Producing a SurfaceBuffer](#section614545716513) - - [Consuming a SurfaceBuffer](#section315285412535) - - [Adding Custom Data to a SurfaceBuffer](#section612412125616) - - [Registering a Vsync Callback Listener](#section1148115214576) - -- [\#EN-US\_TOPIC\_0000001105482134/section1939493174420](#section1939493174420) -- [Repositories Involved](#section6488145313) - -## Introduction - -The Graphics subsystem provides graphics and window management capabilities, which can be invoked by using Java or JS APIs. It can be used for UI development for all standard-system devices. - -The following figure shows the architecture of the Graphics subsystem. - -![](figures/graphic.png) - -- Surface - - Provides APIs for managing the graphics buffer and the efficient and convenient rotation buffer. - -- Vsync - - Provides APIs for managing registration and response of all vertical sync signals. - -- WindowManager - - Provides APIs for creating and managing windows. - -- WaylandProtocols - - Provides the communication protocols between the window manager and synthesizer. - -- Compositor - - Implements synthesis of layers. - -- Renderer - - Functions as the back-end rendering module of the synthesizer. - -- Wayland protocols - - Provides Wayland inter-process communication protocols. - -- Shell - - Provides multi-window capabilities. - -- Input Manger - - Functions as the multimodal input module that receives input events. - - -## Directory Structure - -``` -foundation/graphic/standard/ -├── frameworks # Framework code -│ ├── bootanimation # Boot Animation code -│ ├── surface # Surface code -│ ├── vsync # Vsync code -│ └── wm # WindowManager code -├── interfaces # External APIs -│ ├── innerkits # Native APIs -│ └── kits # JS APIs and NAPIs -└── utils # Utilities -``` - -## Constraints - -- Language version: C++ 11 or later - -## Compilation and Building - -The dependent APIs include the following: - -- graphic\_standard:libwms\_client -- graphic\_standard:libsurface -- graphic\_standard:libvsync\_client - -## Available APIs - -### WindowManager - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

API

-

Description

-

GetInstance

-

Obtains the pointer to a singleton WindowManager instance.

-

GetMaxWidth

-

Obtains the width of the screen.

-

GetMaxHeight

-

Obtains the height of the screen.

-

CreateWindow

-

Creates a standard window.

-

CreateSubWindow

-

Creates a child window.

-

StartShotScreen

-

Takes a screenshot.

-

StartShotWindow

-

Captures a window.

-

SwitchTop

-

Moves the specified window to the top.

-
- -### Window - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

API

-

Description

-

Show

-

Displays the current window.

-

Hide

-

Hides the current window.

-

Move

-

Moves the current window to a specified position.

-

SwitchTop

-

Moves the current window to the top.

-

ChangeWindowType

-

Changes the type of the current window.

-

ReSize

-

Resizes the current window.

-

Rotate

-

Rotates the current window.

-

RegistPointerButtonCb

-

Registers the callback for Button events of the mouse.

-

RegistPointerEnterCb

-

Registers the callback for Enter events of the mouse.

-

RegistPointerLeaveCb

-

Registers the callback for Leave events of the mouse.

-

RegistPointerMotionCb

-

Registers the callback for Motion events of the mouse.

-

RegistPointerAxisDiscreteCb

-

Registers the callback for AxisDiscrete events of the mouse.

-

RegistPointerAxisSourceCb

-

Registers the callback for AxisSource events of the mouse.

-

RegistPointerAxisStopCb

-

Registers the callback for AxisStop events of the mouse.

-

RegistPointerAxisCb

-

Registers the callback for Axis events of the mouse.

-

RegistTouchUpCb

-

Registers the callback for TouchUp events.

-

RegistTouchDownCb

-

Registers the callback for TouchDown events.

-

RegistTouchEmotionCb

-

Registers the callback for TouchEmotion events.

-

RegistTouchFrameCb

-

Registers the callback for TouchFrame events.

-

RegistTouchCancelCb

-

Registers the callback for TouchCancel events.

-

RegistTouchShapeCb

-

Registers the callback for TouchShape events.

-

RegistTouchOrientationCb

-

Registers the callback for TouchOrientation events.

-

RegistKeyboardKeyCb

-

Registers the callback for Key events of the keyboard.

-

RegistKeyboardKeyMapCb

-

Registers the callback for KeyMap events of the keyboard.

-

RegistKeyboardLeaveCb

-

Registers the callback for Leave events of the keyboard.

-

RegistKeyboardEnterCb

-

Registers the callback for Enter events of the keyboard.

-

RegistKeyboardRepeatInfoCb

-

Registers the callback for RepeatInfo events of the keyboard.

-
- -### SubWindow - - - - - - - - - - - - - -

API

-

Description

-

Move

-

Moves the current child window.

-

SetSubWindowSize

-

Sets the size of the current child window.

-
- -### Surface - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

API

-

Description

-

CreateSurfaceAsConsumer

-

Creates a surface for the buffer consumer.

-

CreateSurfaceAsProducer

-

Creates a surface for the buffer producer. Only production-related APIs can be used.

-

GetProducer

-

Obtains an internal IBufferProducer object of Surface.

-

RequestBuffer

-

Requests a SurfaceBuffer object to be produced.

-

CancelBuffer

-

Cancels a SurfaceBuffer object to be produced.

-

FlushBuffer

-

Flushes a produced SurfaceBuffer object with certain information.

-

AcquireBuffer

-

Requests a SurfaceBuffer object to be consumed.

-

ReleaseBuffer

-

Returns a consumed SurfaceBuffer object.

-

GetQueueSize

-

Obtains the number of concurrent buffers.

-

SetQueueSize

-

Sets the number of concurrent buffers.

-

SetDefaultWidthAndHeight

-

Sets the default width and height.

-

GetDefaultWidth

-

Obtains the default width.

-

GetDefaultHeight

-

Obtains the default height.

-

SetUserData

-

Stores string data, which will not be transferred through IPC.

-

GetUserData

-

Obtains string data.

-

RegisterConsumerListener

-

Registers a consumer listener to listen for buffer flush events.

-

UnregisterConsumerListener

-

Unregiseters a consumer listener.

-
- -### SurfaceBuffer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

API

-

Description

-

GetBufferHandle

-

Obtains the BufferHandle pointer to the SurfaceBuffer object.

-

GetWidth

-

Obtains the width of the SurfaceBuffer object.

-

GetHeight

-

Obtains the height of the SurfaceBuffer object.

-

GetFormat

-

Obtains the color format of the SurfaceBuffer object.

-

GetUsage

-

Obtains the usage of the SurfaceBuffer object.

-

GetPhyAddr

-

Obtains the physical address of the SurfaceBuffer object.

-

GetKey

-

Obtains the key of the SurfaceBuffer object.

-

GetVirAddr

-

Obtains the virtual address of the SurfaceBuffer object.

-

GetSize

-

Obtains the size of the SurfaceBuffer object.

-

SetInt32

-

Sets the 32-bit integer for the SurfaceBuffer object.

-

GetInt32

-

Obtains the 32-bit integer for the SurfaceBuffer object.

-

SetInt64

-

Sets the 64-bit integer for the SurfaceBuffer object.

-

GetInt64

-

Obtains the 64-bit integer for the SurfaceBuffer object.

-
- -### VsyncHelper - - - - - - - - - - - - - - - - -

API

-

Description

-

Current

-

Obtains the VsyncHelper object of the current runner.

-

VsyncHelper

-

Constructs a VsyncHelper object using an EventHandler object.

-

RequestFrameCallback

-

Registers a frame callback.

-
- -## Usage - -### Transferring a Producer Surface - -1. Named service - - Service registration: - - ``` - // Obtain a consumer surface. - sptr surface = Surface::CreateSurfaceAsConsumer(); - // Extract the producer object. - sptr producer = surface->GetProducer(); - // Register the service. - auto sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - sm->AddSystemAbility(IPC_SA_ID, producer->AsObject()); - ``` - - - Construction of a producer surface: - - ``` - // Obtain a producer object. - auto sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - sptr robj = sm->GetSystemAbility(IPC_SA_ID); - // Construct a surface. - sptr bp = iface_cast(robj); - sptr surface = Surface::CreateSurfaceAsProducer(bp); - ``` - - -2. Anonymous service - - Sending of a surface: - - ``` - // Obtain a consumer surface. - sptr surface = CreateSurfaceAsConsumer(); - // Extract the producer object. - sptr producer = surface->GetProducer(); - // Return the producer object to the client. - parcel.WriteRemoteObject(producer); - ``` - - - -### Creating a Producer Surface - -``` -// Obtain a producer object. -sptr remoteObject = parcel.ReadRemoteObject(); -// Construct a surface. -sptr bp = iface_cast(robj); -sptr surface = Surface::CreateSurfaceAsProducer(bp); -``` - -### Producing a SurfaceBuffer - -``` -// Prerequisite: a producer surface -BufferRequestConfig requestConfig = { - .width = 1920, // Screen width - .height = 1080, // Screen height - .strideAlignment = 8, // Stride alignment byte - .format = PIXEL_FMT_RGBA_8888, // Color format - .usage = HBM_USE_CPU_READ | HBM_USE_CPU_WRITE | HBM_USE_MEM_DMA, // Usage - .timeout = 0, // Delay -}; - -sptr buffer; -int32_t releaseFence; - -SurfaceError ret = surface->RequestBuffer(buffer, releaseFence, requestConfig); -if (ret != SURFACE_ERROR_OK) { - // failed -} - -BufferFlushConfig flushConfig = { - .damage = { // Redrawing buffer zone - .x = 0, // Horizontal coordinate of the start point - .y = 0, // Vertical coordinate of the start point - .w = buffer->GetWidth(), // Width of the buffer zone - .h = buffer->GetHeight(), // Height of the buffer zone - }, - .timestamp = 0 // Time displayed to consumers. Value 0 indicates the current time. -}; - -ret = surface->FlushBuffer(buffer, -1, flushConfig); -if (ret != SURFACE_ERROR_OK) { - // failed -} -``` - -### Consuming a SurfaceBuffer - -``` -// Prerequisite: a consumer surface -class TestConsumerListener : public IBufferConsumerListener { -public: - void OnBufferAvailable() override { - sptr buffer; - int32_t flushFence; - SurfaceError ret = surface->AcquireBuffer(buffer, flushFence, timestamp, damage); - if (ret != SURFACE_ERROR_OK) { - // failed - } - // ... - ret = surface->ReleaseBuffer(buffer, -1); - if (ret != SURFACE_ERROR_OK) { - // failed - } - } -}; - -sptr listener = new TestConsumerListener(); -SurfaceError ret = surface->RegisterConsumerListener(listener); -if (ret != SURFACE_ERROR_OK) { - // failed -} -``` - -### Adding Custom Data to a SurfaceBuffer - -``` -sptr buffer; -SurfaceError ret = buffer->SetInt32(1, 3); -if (ret != SURFACE_ERROR_OK) { -// failed -} - -int32_t val; -ret = buffer->GetInt32(1, val); -if (ret != SURFACE_ERROR_OK) { -// failed -} -``` - -### Registering a Vsync Callback Listener - -1. Construct a **VsyncHelper** object using **handler**. - - ``` - auto runner = AppExecFwk::EventRunner::Create(true); - auto handler = std::make_shared(runner); - auto helper = new VsyncHelper(handler); - runner->Run(); - - struct FrameCallback cb = { - .timestamp_ = 0, - .userdata_ = nullptr, - .callback_ = [](int64_t timestamp, void* userdata) { - }, - }; - - VsyncError ret = helper->RequestFrameCallback(cb); - if (ret != VSYNC_ERROR_OK) { - // failed - } - ``` - -2. Use **Current** in **handler**. - - ``` - auto runner = AppExecFwk::EventRunner::Create(true); - auto handler = std::make_shared(runner); - handler->PostTask([]() { - auto helper = VsyncHelper::Current(); - struct FrameCallback cb = { - .timestamp_ = 0, - .userdata_ = nullptr, - .callback_ = [](int64_t timestamp, void* userdata) { - }, - }; - VsyncError ret = helper->RequestFrameCallback(cb); - if (ret != VSYNC_ERROR_OK) { - // failed - } - }); - - runner->Run(); - ``` - - -## Repositories Involved - -Graphics subsystem - -**graphic\_standard** - -ace\_ace\_engine - -aafwk\_L2 - -multimedia\_media\_standard - -multimedia\_camera\_standard - diff --git a/README_zh.md b/README_zh.md index 87d4811f..77182df5 100644 --- a/README_zh.md +++ b/README_zh.md @@ -3,359 +3,60 @@ - [简介](#简介) - [目录](#目录) - [约束](#约束) -- [编译构建](#编译构建) - [接口说明](#接口说明) -- [使用说明](#使用说明) - [相关仓](#相关仓) ## 简介 -**Graphic子系统** 提供了图形接口能力和窗口管理接口能力, +**窗口子系统** 提供窗口管理和Display管理的基础能力,是系统图形界面显示所需的基础子系统 其主要的结构如下图所示: -![Graphic子系统架构图](./figures/graphic.png) +![窗口子系统架构图](./figures/WindowManager.png) -- **Surface** +- **Window Manager Client** - 图形缓冲区管理接口,负责管理图形缓冲区和高效便捷的轮转缓冲区。 + 应用进程窗口管理接口层,提供窗口对对象抽象和窗口管理接口,对接原能力和UI框架。 -- **Vsync** +- **Display Manager Client** - 垂直同步信号管理接口,负责管理所有垂直同步信号注册和响应。 + 应用进程Display管理接口层,提供Display信息抽象和Display管理接口。 -- **WindowManager** +- **Window Manager Server** - 窗口管理器接口,负责创建和管理窗口。 + 窗口管理服务,提供窗口布局、Z序控制、窗口树结构、窗口拖拽、窗口快照等能力,并提供窗口布局和焦点窗口给多模输入 -- **WaylandProtocols** - - 窗口管理器和合成器的通信协议。 - -- **Compositor** - - 合成器,负责合成各个图层。 - -- **Renderer** - - 合成器的后端渲染模块。 - -- **Wayland protocols** - - Wayland 进程间通信协议 - -- **Shell** - - 提供多窗口能力 - -- **Input Manger** - - 多模输入模块,负责接收事件输入 +- **Display Manager Server** + Display管理服务,提供Display信息、屏幕截图、屏幕亮灭和亮度处理控制,并处理Display与Screen映射关系 ## 目录 ``` -foundation/graphic/standard/ -├── frameworks # 框架代码目录 -│ ├── bootanimation # 开机动画目录 -│   ├── surface # Surface代码 -│   ├── vsync # Vsync代码 -│   └── wm # WindowManager代码 +foundation/windowmanager/ +├── dm # Dislplay Manager Client实现代码 +├── dmserver # Dislplay Manager Service实现代码 ├── interfaces # 对外接口存放目录 │   ├── innerkits # native接口存放目录 │   └── kits # js/napi接口存放目录 -└── utils # 小部件存放目录 +├── resources # 框架使用资源文件存放目录 +├── sa_profile # 系统服务配置文件 +├── snapshot # 截屏命令行工具实现代码 +├── utils # 工具类存放目录 +├── wm # Window Manager Client实现代码 +├── wmserver # Window Manager Service实现代码 ``` ## 约束 - 语言版本 - C++11或以上 -## 编译构建 -可以依赖的接口有: -- graphic_standard:libwms_client -- graphic_standard:libsurface -- graphic_standard:libvsync_client - ## 接口说明 -### WindowManager - -| 接口名 | 职责 | -|-----------------|-----------------------------| -| GetInstance | 获取WindowManager的单例指针 | -| GetMaxWidth | 获取当前屏幕宽度 | -| GetMaxHeight | 获取当前屏幕高度 | -| CreateWindow | 创建一个标准窗口 | -| CreateSubWindow | 创建一个子窗口 | -| StartShotScreen | 截屏操作 | -| StartShotWindow | 截取窗口操作 | -| SwitchTop | 将指定窗口调整至最上层显示 | - -### Window -| 接口名 | 职责 | -|-----------------------------|------------------------------| -| Show | 显示当前窗口 | -| Hide | 隐藏当前窗口 | -| Move | 移动当前窗口至指定位置 | -| SwitchTop | 将当前窗口调整到最上层显示 | -| ChangeWindowType | 更改当前窗口类型 | -| ReSize | 调整当前窗口至指定大小 | -| Rotate | 旋转当前窗口 | -| RegistPointerButtonCb | 注册鼠标Button事件回调 | -| RegistPointerEnterCb | 注册鼠标Enter事件回调 | -| RegistPointerLeaveCb | 注册鼠标Leave事件回调 | -| RegistPointerMotionCb | 注册鼠标Motion事件回调 | -| RegistPointerAxisDiscreteCb | 注册鼠标AxisDiscrete事件回调 | -| RegistPointerAxisSourceCb | 注册鼠标AxisSource事件回调 | -| RegistPointerAxisStopCb | 注册鼠标AxisStop事件回调 | -| RegistPointerAxisCb | 注册鼠标Axis事件回调 | -| RegistTouchUpCb | 注册TouchUp事件回调 | -| RegistTouchDownCb | 注册TouchDown事件回调 | -| RegistTouchEmotionCb | 注册TouchEmotion事件回调 | -| RegistTouchFrameCb | 注册TouchFrame事件回调 | -| RegistTouchCancelCb | 注册TouchCancel事件回调 | -| RegistTouchShapeCb | 注册TouchShape事件回调 | -| RegistTouchOrientationCb | 注册TouchOrientation事件回调 | -| RegistKeyboardKeyCb | 注册键盘Key事件回调 | -| RegistKeyboardKeyMapCb | 注册键盘KeyMap事件回调 | -| RegistKeyboardLeaveCb | 注册键盘Leave事件回调 | -| RegistKeyboardEnterCb | 注册键盘Enter事件回调 | -| RegistKeyboardRepeatInfoCb | 注册键盘RepeatInfo事件回调 | - -### SubWindow -| 接口名 | 职责 | -|------------------|--------------------| -| Move | 移动当前子窗口 | -| SetSubWindowSize | 调整当前子窗口位置 | - -### Surface -| 接口名 | 职责 | -|----------------------------|-------------------------------------------------------------------| -| CreateSurfaceAsConsumer | Buffer的消费者来使用该函数创建一个Surface | -| CreateSurfaceAsProducer | Buffer的生产者使用该函数创建一个Surface,只能使用与生产相关的接口 | -| GetProducer | 获得一个Surface内部的IBufferProducer对象 | -| RequestBuffer | 请求一个待生产的SurfaceBuffer对象 | -| CancelBuffer | 取消、归还一个待生产的SurfaceBuffer对象 | -| FlushBuffer | 归还一个生产好的SurfaceBuffer对象并携带一些信息 | -| AcquireBuffer | 请求一个待消费的SurfaceBuffer对象 | -| ReleaseBuffer | 归还一个已消费的SurfaceBuffer对象 | -| GetQueueSize | 获得当前同时能并存buffer的数量 | -| SetQueueSize | 设置当前同时能并存buffer的数量 | -| SetDefaultWidthAndHeight | 设置默认宽和高 | -| GetDefaultWidth | 获得默认宽度 | -| GetDefaultHeight | 获得默认高度 | -| SetUserData | 存贮字符串数据,不随着IPC传递 | -| GetUserData | 取出字符串数据 | -| RegisterConsumerListener | 注册一个消费监听器,监听Buffer的Flush事件 | -| UnregisterConsumerListener | 取消监听 | - -### SurfaceBuffer -| 接口名 | 职责 | -|-----------------|-------------------------------------| -| GetBufferHandle | 获得SurfaceBuffer的BufferHandle指针 | -| GetWidth | 获得SurfaceBuffer的宽度 | -| GetHeight | 获得SurfaceBuffer的高度 | -| GetFormat | 获得SurfaceBuffer的颜色格式 | -| GetUsage | 获得SurfaceBuffer的用途 | -| GetPhyAddr | 获得SurfaceBuffer的物理地址 | -| GetKey | 获得SurfaceBuffer的key | -| GetVirAddr | 获得SurfaceBuffer的虚拟地址 | -| GetSize | 获得SurfaceBuffer的文件句柄 | -| SetInt32 | 获得SurfaceBuffer的缓冲区大小 | -| GetInt32 | 设置SurfaceBuffer的32位整数 | -| SetInt64 | 获得SurfaceBuffer的32位整数 | -| GetInt64 | 设置SurfaceBuffer的64位整数 | - -### VsyncHelper -| 接口名 | 职责 | -|----------------------|-----------------------------------| -| Current | 获取当前runner对应的VsyncHelper | -| VsyncHelper | 用EventHandler对象构造VsyncHelper | -| RequestFrameCallback | 注册一个帧回调 | - -## 使用说明 - -### 具名服务-传递一个生产型Surface - -#### 注册 -```cpp -// 拿到一个消费型Surface -sptr surface = Surface::CreateSurfaceAsConsumer(); - -// 拿出里面的生产者对象 -sptr producer = surface->GetProducer(); - -// 注册服务 -auto sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); -sm->AddSystemAbility(IPC_SA_ID, producer->AsObject()); -``` - -#### 客户端获得生产型Surface -```cpp -// 获得远程对象 -auto sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); -sptr robj = sm->GetSystemAbility(IPC_SA_ID); - -// 构造Surface -sptr bp = iface_cast(robj); -sptr surface = Surface::CreateSurfaceAsProducer(bp); -``` - -### 匿名服务-传递一个生产型Surface -场景: 在一次IPC过程中 - -#### 发送 -```cpp -// 拿到一个消费型Surface -sptr surface = CreateSurfaceAsConsumer(); - -// 拿出里面的生产者对象 -sptr producer = surface->GetProducer(); - -// 返回给客户端 -parcel.WriteRemoteObject(producer); -``` - -#### 接受并获得生产型Surface -```cpp -// 获得远程对象 -sptr remoteObject = parcel.ReadRemoteObject(); - -// 构造Surface -sptr bp = iface_cast(robj); -sptr surface = Surface::CreateSurfaceAsProducer(bp); -``` - -### 生产一个SurfaceBuffer -条件: 一个生产型Surface - -```cpp -BufferRequestConfig requestConfig = { - .width = 1920, // 屏幕宽度 - .height = 1080, // 屏幕高度 - .strideAlignment = 8, // stride对齐字节 - .format = PIXEL_FMT_RGBA_8888, // 颜色格式 - .usage = HBM_USE_CPU_READ | HBM_USE_CPU_WRITE | HBM_USE_MEM_DMA, // 用法 - .timeout = 0, // 时延 -}; - -sptr buffer; -int32_t releaseFence; - -SurfaceError ret = surface->RequestBuffer(buffer, releaseFence, requestConfig); -if (ret != SURFACE_ERROR_OK) { - // failed -} - -BufferFlushConfig flushConfig = { - .damage = { // 重绘区域 - .x = 0, // 起点横坐标 - .y = 0, // 起点纵坐标 - .w = buffer->GetWidth(), // 区域宽度 - .h = buffer->GetHeight(), // 区域高度 - }, - .timestamp = 0 // 给消费者看的时间,0为使用当前时间 -}; - -ret = surface->FlushBuffer(buffer, -1, flushConfig); -if (ret != SURFACE_ERROR_OK) { - // failed -} -``` - -### 消费一个SurfaceBuffer -条件: 一个消费型Surface - -```cpp -class TestConsumerListener : public IBufferConsumerListener { -public: - void OnBufferAvailable() override { - sptr buffer; - int32_t flushFence; - - SurfaceError ret = surface->AcquireBuffer(buffer, flushFence, timestamp, damage); - if (ret != SURFACE_ERROR_OK) { - // failed - } - - // ... - - ret = surface->ReleaseBuffer(buffer, -1); - if (ret != SURFACE_ERROR_OK) { - // failed - } - } -}; - -sptr listener = new TestConsumerListener(); -SurfaceError ret = surface->RegisterConsumerListener(listener); -if (ret != SURFACE_ERROR_OK) { - // failed -} -``` - -### 给SurfaceBuffer带上自定义数据 -```cpp -sptr buffer; -SurfaceError ret = buffer->SetInt32(1, 3); -if (ret != SURFACE_ERROR_OK) { - // failed -} - -int32_t val; -ret = buffer->GetInt32(1, val); -if (ret != SURFACE_ERROR_OK) { - // failed -} -``` - -### 注册一个Vsync回调事件 -#### 用handler构造VsyncHelper -```cpp -auto runner = AppExecFwk::EventRunner::Create(true); -auto handler = std::make_shared(runner); -auto helper = new VsyncHelper(handler); -runner->Run(); - -struct FrameCallback cb = { - .timestamp_ = 0, - .userdata_ = nullptr, - .callback_ = [](int64_t timestamp, void* userdata) { - }, -}; - -VsyncError ret = helper->RequestFrameCallback(cb); -if (ret != VSYNC_ERROR_OK) { - // failed -} -``` - -#### 在handler里用Current -```cpp -auto runner = AppExecFwk::EventRunner::Create(true); -auto handler = std::make_shared(runner); -handler->PostTask([]() { - auto helper = VsyncHelper::Current(); - struct FrameCallback cb = { - .timestamp_ = 0, - .userdata_ = nullptr, - .callback_ = [](int64_t timestamp, void* userdata) { - }, - }; - - VsyncError ret = helper->RequestFrameCallback(cb); - if (ret != VSYNC_ERROR_OK) { - // failed - } -}); - -runner->Run(); -``` +- [Window](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-window.md) +- [Display](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-display.md) ## 相关仓 -- **graphic_standard** +- graphic_standard - ace_ace_engine - aafwk_standard -- multimedia_media_standard -- multimedia_camera_standard +- multimodalinput_input \ No newline at end of file diff --git a/figures/WindowManager.png b/figures/WindowManager.png new file mode 100644 index 00000000..f4f96ea5 Binary files /dev/null and b/figures/WindowManager.png differ diff --git a/figures/graphic.png b/figures/graphic.png deleted file mode 100644 index b72003f5..00000000 Binary files a/figures/graphic.png and /dev/null differ