diff --git a/en/application-dev/napi/native-buffer-guidelines.md b/en/application-dev/napi/native-buffer-guidelines.md index b45c43f77e6d63aac676327bc971d9eeb0609259..fae8927caa9563c9fd459906d9fb9ecf2e166297 100644 --- a/en/application-dev/napi/native-buffer-guidelines.md +++ b/en/application-dev/napi/native-buffer-guidelines.md @@ -26,6 +26,13 @@ For details about the APIs, see [native_buffer](../reference/native-apis/_o_h___ The following describes how to use the native APIs provided by **NativeBuffer** to create an **OH_NativeBuffer** instance, obtain memory properties, and map the corresponding ION memory to the process address space. +**Adding Dynamic Link Libraries** + +Add the following library to **CMakeLists.txt**: +```txt +libnative_buffer.so +``` + **Header File** ```c++ #include @@ -51,14 +58,14 @@ The following describes how to use the native APIs provided by **NativeBuffer** if (ret != 0) { std::cout << "OH_NativeBuffer_Map Failed" << std::endl; } - - // Unmap the ION memory from the process address space when it is no longer needed. + +// Unmap the ION memory from the process address space when it is no longer needed. ret = OH_NativeBuffer_Unmap(buffer); if (ret != 0) { std::cout << "OH_NativeBuffer_Unmap Failed" << std::endl; } ``` - + 3. Obtain the memory properties. ```c++ // Obtain the properties of the OH_NativeBuffer instance. diff --git a/en/application-dev/napi/native-image-guidelines.md b/en/application-dev/napi/native-image-guidelines.md index 10142f438059908cef4320b5d01e2029cf6cfe16..46518e0985b2b8ab8403456fced4d16f69b1fcb9 100644 --- a/en/application-dev/napi/native-image-guidelines.md +++ b/en/application-dev/napi/native-image-guidelines.md @@ -27,6 +27,17 @@ For details about the APIs, see [native_image](../reference/native-apis/_o_h___n The following steps describe how to use the native APIs provided by **NativeImage** to create an **OH_NativeImage** instance as the consumer and update the data to a OpenGL external texture. +**Adding Dynamic Link Libraries** + +Add the following libraries to **CMakeLists.txt**: +```txt +libEGL.so +libGLESv3.so +libnative_image.so +libnative_window.so +libnative_buffer.so +``` + **Header File** ```c++ #include @@ -159,41 +170,48 @@ The following steps describe how to use the native APIs provided by **NativeImag 4. Write the produced content to a **NativeWindowBuffer** instance. 1. Obtain a NativeWindowBuffer instance from the NativeWindow instance. - ```c++ - OHNativeWindowBuffer* buffer = nullptr; - int fenceFd; - // Obtain a NativeWindowBuffer instance by calling OH_NativeWindow_NativeWindowRequestBuffer. - OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &buffer, &fenceFd); - BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer); - int code = SET_BUFFER_GEOMETRY; - int32_t width = 0x100; - int32_t height = 0x100; - ret = OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, width, height); - ``` - 3. Write the produced content to the **NativeWindowBuffer** instance. - ```c++ - static uint32_t value = 0x00; - value++; - uint32_t *pixel = static_cast(handle->virAddr); - for (uint32_t x = 0; x < width; x++) { - for (uint32_t y = 0; y < height; y++) { - *pixel++ = value; - } - } - ``` - 4. Flush the **NativeWindowBuffer** to the **NativeWindow**. - ```c++ - // Set the refresh region. If Rect in Region is a null pointer or rectNumber is 0, all contents in the NativeWindowBuffer are changed. - Region region{nullptr, 0}; - // Flush the buffer to the consumer through OH_NativeWindow_NativeWindowFlushBuffer, for example, by displaying it on the screen. - OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow, buffer, fenceFd, region); - ``` - 5. Destroy the **NativeWindow** instance when it is no longer needed. - ```c++ - OH_NativeWindow_DestroyNativeWindow(nativeWindow); - ``` - + ```c++ + OHNativeWindowBuffer* buffer = nullptr; + int fenceFd; + // Obtain a NativeWindowBuffer instance by calling OH_NativeWindow_NativeWindowRequestBuffer. + OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &buffer, &fenceFd); + + BufferHandle *handle = OH_NativeWindow_GetBufferHandleFromNative(buffer); + int code = SET_BUFFER_GEOMETRY; + int32_t width = 0x100; + int32_t height = 0x100; + ret = OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, width, height); + ``` + + 2. Write the produced content to the **NativeWindowBuffer** instance. + + ```c++ + static uint32_t value = 0x00; + value++; + uint32_t *pixel = static_cast(handle->virAddr); + for (uint32_t x = 0; x < width; x++) { + for (uint32_t y = 0; y < height; y++) { + *pixel++ = value; + } + } + ``` + + 3. Flush the **NativeWindowBuffer** to the **NativeWindow**. + + ```c++ + // Set the refresh region. If Rect in Region is a null pointer or rectNumber is 0, all contents in the NativeWindowBuffer are changed. + Region region{nullptr, 0}; + // Flush the buffer to the consumer through OH_NativeWindow_NativeWindowFlushBuffer, for example, by displaying it on the screen. + OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow, buffer, fenceFd, region); + ``` + + 4. Destroy the **NativeWindow** instance when it is no longer needed. + + ```c++ + OH_NativeWindow_DestroyNativeWindow(nativeWindow); + ``` + 5. Update the content to the OpenGL texture. ```c++ // Update the content to the OpenGL texture. diff --git a/en/application-dev/napi/native-vsync-guidelines.md b/en/application-dev/napi/native-vsync-guidelines.md index 548a791e97ee75a1ee4ad83123893c5495181b59..f43495857483fc529ce03b565011a59e98fc07a7 100644 --- a/en/application-dev/napi/native-vsync-guidelines.md +++ b/en/application-dev/napi/native-vsync-guidelines.md @@ -6,12 +6,12 @@ The **NativeVSync** module is used to obtain virtual synchronization (VSync) sig ## Available APIs -| API| Description:| +| API| Description| | -------- | -------- | -| OH_NativeVSync_Create (const char \*name, unsigned int length) | Creates an **OH_NativeVSync** instance. A new **OH_NativeVSync** instance is created each time this function is called.| -| OH_NativeVSync_Destroy (OH_NativeVSync \*nativeVsync) | Destroys an **OH_NativeVSync** instance.| -| OH_NativeVSync_FrameCallback (long long timestamp, void \*data) | Sets a callback function. **timestamp** indicates the timestamp, and **data** indicates the input parameter of the callback function. | -| OH_NativeVSync_RequestFrame (OH_NativeVSync \*nativeVsync, OH_NativeVSync_FrameCallback callback, void \*data) | Requests the next VSync signal. When the signal arrives, a callback function is invoked.| +| OH_NativeVSync_Create (const char \*name, unsigned int length) | Creates an **OH_NativeVSync** instance. A new **OH_NativeVSync** instance is created each time this function is called.| +| OH_NativeVSync_Destroy (OH_NativeVSync \*nativeVsync) | Destroys an **OH_NativeVSync** instance.| +| OH_NativeVSync_FrameCallback (long long timestamp, void \*data) | Sets a callback function. **timestamp** indicates the timestamp, and **data** indicates the input parameter of the callback function.| +| OH_NativeVSync_RequestFrame (OH_NativeVSync \*nativeVsync, OH_NativeVSync_FrameCallback callback, void \*data) | Requests the next VSync signal. When the signal arrives, a callback function is invoked.| For details about the APIs, see [native_vsync](../reference/native-apis/_native_vsync.md). @@ -19,6 +19,13 @@ For details about the APIs, see [native_vsync](../reference/native-apis/_native_ The following steps describe how to use the native APIs provided by **NativeVSync** to create and destroy an **OH_NativeVSync** instance and set the VSync callback function. +**Adding Dynamic Link Libraries** + +Add the following library to **CMakeLists.txt**: +```txt +libnative_vsync.so +``` + **Header File** ```c++ #include @@ -33,12 +40,12 @@ The following steps describe how to use the native APIs provided by **NativeVSyn std::cout << "OnVSync: " << timestamp << std::endl; } OH_NativeVSync_FrameCallback callback = OnVSync; // The callback function must be of the OH_NativeVSync_FrameCallback type. - ``` + ``` 2. Create an **OH_NativeVSync** instance. ```c++ char name[] = "hello_vsync"; OH_NativeVSync* nativeVSync = OH_NativeVSync_Create(name, strlen(name)); - ``` + ``` 3. Set the VSync callback function through the **OH_NativeVSync** instance. ```c++ diff --git a/en/application-dev/napi/native-window-guidelines.md b/en/application-dev/napi/native-window-guidelines.md index f6f4e44b5edd8f40757105b4c050d4c9b2b0363d..5c5a62ab3d256689d1d467595797e3f2c605b679 100644 --- a/en/application-dev/napi/native-window-guidelines.md +++ b/en/application-dev/napi/native-window-guidelines.md @@ -11,11 +11,11 @@ The following scenarios are common for NativeWindow development: ## Available APIs -| API| Description| +| API| Description| | -------- | -------- | -| OH_NativeWindow_NativeWindowRequestBuffer (OHNativeWindow \*window, OHNativeWindowBuffer \*\*buffer, int \*fenceFd) | Requests an **OHNativeWindowBuffer** through an **OHNativeWindow** instance for content production.| -| OH_NativeWindow_NativeWindowFlushBuffer (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer, int fenceFd, Region region) | Flushes the **OHNativeWindowBuffer** filled with the content to the buffer queue through an **OHNativeWindow** instance for content consumption.| -| OH_NativeWindow_NativeWindowHandleOpt (OHNativeWindow \*window, int code,...) | Sets or obtains the attributes of an **OHNativeWindow**, including the width, height, and content format.| +| OH_NativeWindow_NativeWindowRequestBuffer (OHNativeWindow \*window, OHNativeWindowBuffer \*\*buffer, int \*fenceFd) | Requests an **OHNativeWindowBuffer** through an **OHNativeWindow** instance for content production.| +| OH_NativeWindow_NativeWindowFlushBuffer (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer, int fenceFd, Region region) | Flushes the **OHNativeWindowBuffer** filled with the content to the buffer queue through an **OHNativeWindow** instance for content consumption.| +| OH_NativeWindow_NativeWindowHandleOpt (OHNativeWindow \*window, int code,...) | Sets or obtains the attributes of an **OHNativeWindow**, including the width, height, and content format.| For details about the APIs, see [native_window](../reference/native-apis/_native_window.md). @@ -37,7 +37,7 @@ libnative_window.so #include ``` -1. Obtain an **OHNativeWindow** instance. +1. Obtain an **OHNativeWindow** instance. You can call the APIs provided by [OH_NativeXComponent_Callback](../reference/native-apis/_o_h___native_x_component___callback.md) to obtain an **OHNativeWindow** instance. An example code snippet is provided below. For details about how to use the **\**, see [XComponent Development](xcomponent-guidelines.md). 1. Add an **\** to the .ets file. @@ -159,5 +159,3 @@ libnative_window.so // munmap failed } ``` - - \ No newline at end of file diff --git a/en/application-dev/napi/vulkan-guidelines.md b/en/application-dev/napi/vulkan-guidelines.md index e55b53cd38d44fb5d5a893cdbc21d175b9b0c8df..6ce31b8e1339633bcaa45f47637204f3b4ecef84 100644 --- a/en/application-dev/napi/vulkan-guidelines.md +++ b/en/application-dev/napi/vulkan-guidelines.md @@ -18,6 +18,15 @@ For details about the APIs, see [Vulkan](../reference/native-lib/third_party_vul The following steps illustrate how to create a **VkSurfaceKHR** instance. +**Adding Dynamic Link Libraries** + +Add the following libraries to **CMakeLists.txt**: +```txt +libace_ndk.z.so +libnative_window.so +libvulkan.so +``` + **Header File** ```c++ #include