Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.
HarmonyOS
This file declares the functions related to the surface in the drawing module, including creating, destroying, and using the surface.
File to include: <native_drawing/drawing_surface.h>
Library: libnative_drawing.so
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Related module: Drawing
| Name | Description |
|---|---|
| OH_Drawing_Surface* OH_Drawing_SurfaceCreateFromGpuContext(OH_Drawing_GpuContext* gpuContext, bool flag, OH_Drawing_Image_Info imageInfo) | Creates an OH_Drawing_Surface object using the GPU context to manage the content drawn on the canvas. This API may return an error code. For details, call OH_Drawing_ErrorCodeGet. If gpuContext is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned. |
| OH_Drawing_Surface* OH_Drawing_SurfaceCreateOnScreen(OH_Drawing_GpuContext* gpuContext, OH_Drawing_Image_Info imageInfo, void* window) | Creates an OH_Drawing_Surface object bound to the window using the GPU context to manage the content drawn on the canvas. This API may return an error code. For details, call OH_Drawing_ErrorCodeGet. OH_DRAWING_ERROR_INVALID_PARAMETER if gpuContext or window is NULL. |
| OH_Drawing_Canvas* OH_Drawing_SurfaceGetCanvas(OH_Drawing_Surface* surface) | Obtains a canvas from an OH_Drawing_Surface object. This API may return an error code. For details, call OH_Drawing_ErrorCodeGet. If surface is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned. |
| OH_Drawing_ErrorCode OH_Drawing_SurfaceFlush(OH_Drawing_Surface* surface) | Pushes the drawing content from an OH_Drawing_Surface object to the GPU for rendering. |
| void OH_Drawing_SurfaceDestroy(OH_Drawing_Surface* surface) | Destroys an OH_Drawing_Surface object and reclaims the memory occupied. |
- OH_Drawing_Surface* OH_Drawing_SurfaceCreateFromGpuContext(OH_Drawing_GpuContext* gpuContext, bool flag, OH_Drawing_Image_Info imageInfo)
Description
Creates an OH_Drawing_Surface object using the GPU context to manage the content drawn on the canvas.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If gpuContext is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_GpuContext* gpuContext | Pointer to an OH_Drawing_GpuContext object. |
| bool flag | Whether the memory allocation is counted in the cache budget. true means yes; false otherwise. |
| OH_Drawing_Image_Info imageInfo | Image information struct. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_Surface* | Returns a pointer to the created OH_Drawing_Surface object. |
- OH_Drawing_Surface* OH_Drawing_SurfaceCreateOnScreen(OH_Drawing_GpuContext* gpuContext, OH_Drawing_Image_Info imageInfo, void* window)
Description
Creates an OH_Drawing_Surface object bound to the window using the GPU context to manage the content drawn on the canvas.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
OH_DRAWING_ERROR_INVALID_PARAMETER if gpuContext or window is NULL.
The width and height of imageInfo must be the same as those of window.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 16
Parameters
| Name | Description |
|---|---|
| OH_Drawing_GpuContext* gpuContext | Pointer to an OH_Drawing_GpuContext object. This object must be created by OH_Drawing_GpuContextCreate. Otherwise, the OH_Drawing_Surface object fails to be created. |
| OH_Drawing_Image_Info imageInfo | Image information struct. |
| void* window | Pointer to the window object. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_Surface* | Returns a pointer to the created OH_Drawing_Surface object. |
- OH_Drawing_Canvas* OH_Drawing_SurfaceGetCanvas(OH_Drawing_Surface* surface)
Description
Obtains a canvas from an OH_Drawing_Surface object.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If surface is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Surface* surface | Pointer to an OH_Drawing_Surface object. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_Canvas* | Returns a pointer to the created OH_Drawing_Canvas object. The pointer returned does not need to be managed by the caller. |
- OH_Drawing_ErrorCode OH_Drawing_SurfaceFlush(OH_Drawing_Surface* surface)
Description
Pushes the drawing content from an OH_Drawing_Surface object to the GPU for rendering.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 16
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Surface* surface | Pointer to the created OH_Drawing_Surface object. This object must be created by calling OH_Drawing_SurfaceCreateOnScreen. Otherwise, calling the current API has no effect. |
Returns
| Type | Description |
|---|---|
| OH_Drawing_ErrorCode | Returns one of the following result codes: OH_DRAWING_SUCCESS if the operation is successful. OH_DRAWING_ERROR_INVALID_PARAMETER if surface is NULL. |
- void OH_Drawing_SurfaceDestroy(OH_Drawing_Surface* surface)
Description
Destroys an OH_Drawing_Surface object and reclaims the memory occupied.
System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_Drawing_Surface* surface | Pointer to an OH_Drawing_Surface object. |
Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Quick start
Helps you find desired resources with ease.