MapLibre Native C API
Public C ABI for the MapLibre Native wrapper.
Loading...
Searching...
No Matches
ohos.h File Reference

Go to the source code of this file.

Data Structures

struct  mln_ohos_surface_descriptor
struct  mln_ohos_surface_replacement

Typedefs

typedef struct mln_ohos_surface_descriptor mln_ohos_surface_descriptor
typedef struct mln_ohos_surface_replacement mln_ohos_surface_replacement

Functions

mln_status mln_ohos_frame_pacer_create (const mln_frame_pacer_options *options, mln_frame_pacer *out_pacer, mln_diagnostic *out_diagnostic)
mln_status mln_map_attach_ohos_surface (mln_map map, const mln_ohos_surface_descriptor *descriptor, mln_vulkan_device device, const mln_render_session_attach_options *options, mln_render_session *out_session, const mln_completion *completion, mln_diagnostic *out_diagnostic)
mln_status mln_render_session_set_ohos_surface_target (mln_render_session session, const mln_ohos_surface_replacement *replacement, const mln_completion *completion, mln_diagnostic *out_diagnostic)

Detailed Description

Present the map to an OpenHarmony app's windows, and pace its frames to the display.

Typedef Documentation

◆ mln_ohos_surface_descriptor

typedef struct mln_ohos_surface_descriptor mln_ohos_surface_descriptor

An OpenHarmony window to present to, for mln_map_attach_ohos_surface().

Name the window by window or by surface_id. The session takes its own reference to the window, so you can release yours once the call returns.

◆ mln_ohos_surface_replacement

typedef struct mln_ohos_surface_replacement mln_ohos_surface_replacement

A new OpenHarmony window for mln_render_session_set_ohos_surface_target().

Name the window by window or by surface_id. The session takes its own reference to the window, so you can release yours once the call returns.

Function Documentation

◆ mln_map_attach_ohos_surface()

mln_status mln_map_attach_ohos_surface ( mln_map map,
const mln_ohos_surface_descriptor * descriptor,
mln_vulkan_device device,
const mln_render_session_attach_options * options,
mln_render_session * out_session,
const mln_completion * completion,
mln_diagnostic * out_diagnostic )

Creates a session that presents the map to an OpenHarmony window, with a graphics context that the library creates.

A Vulkan build presents with device, or, when device is null, with a device that the library creates. An OpenGL build uses an EGL context on the default display, and device must be null. Attach with MLN_RENDER_DRIVER_CORE_WORKER.

When the platform destroys the window, such as in an XComponent's onSurfaceDestroyed callback, release the target with mln_render_session_release_target(), or give the session a new window with mln_render_session_set_ohos_surface_target(), without waiting for that to complete. The session keeps its own reference to the window and stays usable for the next window. A frame to the destroyed window finishes with MLN_RENDER_RESULT_TARGET_NOT_READY, or with MLN_RENDER_RESULT_RENDERED if the window went away while the frame was presenting.

Returns:

Completes with:

  • MLN_STATUS_UNSUPPORTED when the GPU or the Vulkan loader can't present.
  • MLN_STATUS_NATIVE_ERROR when the library can't create the graphics context or the window's surface.

◆ mln_ohos_frame_pacer_create()

mln_status mln_ohos_frame_pacer_create ( const mln_frame_pacer_options * options,
mln_frame_pacer * out_pacer,
mln_diagnostic * out_diagnostic )

Creates a frame pacer that follows the display through OpenHarmony's OH_NativeVSync.

You can call it on any thread. The pacer needs no event loop of yours.

Returns:

  • MLN_STATUS_NATIVE_ERROR when the system can't report the display's refreshes to the process.

◆ mln_render_session_set_ohos_surface_target()

mln_status mln_render_session_set_ohos_surface_target ( mln_render_session session,
const mln_ohos_surface_replacement * replacement,
const mln_completion * completion,
mln_diagnostic * out_diagnostic )

Replaces the OpenHarmony window that the session presents to.

Use it to give the session a window again after mln_render_session_release_target(), to move it to another window, or to resize it. Once the replacement completes, the session no longer uses the old window.

Returns:

Completes with:

  • MLN_STATUS_UNSUPPORTED when, in a Vulkan build, the new window needs a different color format or pre-rotation support than the old one. Attach a new session instead.
  • MLN_STATUS_NATIVE_ERROR when the library can't create the window's surface.