17777dab0Sopenharmony_ci/* 27777dab0Sopenharmony_ci * Copyright (c) 2022-2022 Huawei Device Co., Ltd. 37777dab0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 47777dab0Sopenharmony_ci * you may not use this file except in compliance with the License. 57777dab0Sopenharmony_ci * You may obtain a copy of the License at 67777dab0Sopenharmony_ci * 77777dab0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 87777dab0Sopenharmony_ci * 97777dab0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 107777dab0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 117777dab0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 127777dab0Sopenharmony_ci * See the License for the specific language governing permissions and 137777dab0Sopenharmony_ci * limitations under the License. 147777dab0Sopenharmony_ci */ 157777dab0Sopenharmony_ci 167777dab0Sopenharmony_ci#ifndef NDK_INCLUDE_NATIVE_VSYNC_H_ 177777dab0Sopenharmony_ci#define NDK_INCLUDE_NATIVE_VSYNC_H_ 187777dab0Sopenharmony_ci 197777dab0Sopenharmony_ci/** 207777dab0Sopenharmony_ci * @addtogroup NativeVsync 217777dab0Sopenharmony_ci * @{ 227777dab0Sopenharmony_ci * 237777dab0Sopenharmony_ci * @brief Provides the native vsync capability. 247777dab0Sopenharmony_ci * 257777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync 267777dab0Sopenharmony_ci * @since 9 277777dab0Sopenharmony_ci * @version 1.0 287777dab0Sopenharmony_ci */ 297777dab0Sopenharmony_ci 307777dab0Sopenharmony_ci/** 317777dab0Sopenharmony_ci * @file native_vsync.h 327777dab0Sopenharmony_ci * 337777dab0Sopenharmony_ci * @brief Defines the functions for obtaining and using a native vsync. 347777dab0Sopenharmony_ci * 357777dab0Sopenharmony_ci * @kit ArkGraphics2D 367777dab0Sopenharmony_ci * @library libnative_vsync.so 377777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync 387777dab0Sopenharmony_ci * @since 9 397777dab0Sopenharmony_ci * @version 1.0 407777dab0Sopenharmony_ci */ 417777dab0Sopenharmony_ci 427777dab0Sopenharmony_ci#ifdef __cplusplus 437777dab0Sopenharmony_ciextern "C" { 447777dab0Sopenharmony_ci#endif 457777dab0Sopenharmony_ci 467777dab0Sopenharmony_cistruct OH_NativeVSync; 477777dab0Sopenharmony_citypedef struct OH_NativeVSync OH_NativeVSync; 487777dab0Sopenharmony_citypedef void (*OH_NativeVSync_FrameCallback)(long long timestamp, void *data); 497777dab0Sopenharmony_ci 507777dab0Sopenharmony_ci/** 517777dab0Sopenharmony_ci * @brief Creates a <b>NativeVsync</b> instance.\n 527777dab0Sopenharmony_ci * A new <b>NativeVsync</b> instance is created each time this function is called. 537777dab0Sopenharmony_ci * 547777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync 557777dab0Sopenharmony_ci * @param name Indicates the vsync connection name. 567777dab0Sopenharmony_ci * @param length Indicates the name's length. 577777dab0Sopenharmony_ci * @return Returns the pointer to the <b>NativeVsync</b> instance created. 587777dab0Sopenharmony_ci * @since 9 597777dab0Sopenharmony_ci * @version 1.0 607777dab0Sopenharmony_ci */ 617777dab0Sopenharmony_ciOH_NativeVSync* OH_NativeVSync_Create(const char* name, unsigned int length); 627777dab0Sopenharmony_ci 637777dab0Sopenharmony_ci/** 647777dab0Sopenharmony_ci * @brief Delete the NativeVsync instance. 657777dab0Sopenharmony_ci * 667777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync 677777dab0Sopenharmony_ci * @param window Indicates the pointer to a <b>NativeVsync</b> instance. 687777dab0Sopenharmony_ci * @since 9 697777dab0Sopenharmony_ci * @version 1.0 707777dab0Sopenharmony_ci */ 717777dab0Sopenharmony_civoid OH_NativeVSync_Destroy(OH_NativeVSync* nativeVsync); 727777dab0Sopenharmony_ci 737777dab0Sopenharmony_ci/** 747777dab0Sopenharmony_ci * @brief Request next vsync with callback. 757777dab0Sopenharmony_ci * If you call this interface multiple times in one frame, it will only call the last callback. 767777dab0Sopenharmony_ci * 777777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync 787777dab0Sopenharmony_ci * @param nativeVsync Indicates the pointer to a NativeVsync. 797777dab0Sopenharmony_ci * @param callback Indicates the OH_NativeVSync_FrameCallback which will be called when next vsync coming. 807777dab0Sopenharmony_ci * @param data Indicates data which will be used in callback. 817777dab0Sopenharmony_ci * @return {@link NATIVE_ERROR_OK} 0 - Success. 827777dab0Sopenharmony_ci * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter nativeVsync is NULL or callback is NULL. 837777dab0Sopenharmony_ci * {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed. 847777dab0Sopenharmony_ci * @since 9 857777dab0Sopenharmony_ci * @version 1.0 867777dab0Sopenharmony_ci */ 877777dab0Sopenharmony_ciint OH_NativeVSync_RequestFrame(OH_NativeVSync* nativeVsync, OH_NativeVSync_FrameCallback callback, void* data); 887777dab0Sopenharmony_ci 897777dab0Sopenharmony_ci/** 907777dab0Sopenharmony_ci * @brief Request next vsync with callback. 917777dab0Sopenharmony_ci * If this function is called multiple times in one vsync period, all these callbacks and dataset will be called. 927777dab0Sopenharmony_ci * 937777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync 947777dab0Sopenharmony_ci * @param nativeVsync Indicates the pointer to a NativeVsync. 957777dab0Sopenharmony_ci * @param callback Indicates the OH_NativeVSync_FrameCallback which will be called when next vsync coming. 967777dab0Sopenharmony_ci * @param data Indicates data which will be used in callback. 977777dab0Sopenharmony_ci * @return {@link NATIVE_ERROR_OK} 0 - Success. 987777dab0Sopenharmony_ci * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter nativeVsync is NULL or callback is NULL. 997777dab0Sopenharmony_ci * {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed. 1007777dab0Sopenharmony_ci * @since 12 1017777dab0Sopenharmony_ci * @version 1.0 1027777dab0Sopenharmony_ci */ 1037777dab0Sopenharmony_ciint OH_NativeVSync_RequestFrameWithMultiCallback( 1047777dab0Sopenharmony_ci OH_NativeVSync* nativeVsync, OH_NativeVSync_FrameCallback callback, void* data); 1057777dab0Sopenharmony_ci 1067777dab0Sopenharmony_ci/** 1077777dab0Sopenharmony_ci * @brief Get vsync period. 1087777dab0Sopenharmony_ci * 1097777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync 1107777dab0Sopenharmony_ci * @param nativeVsync Indicates the pointer to a NativeVsync. 1117777dab0Sopenharmony_ci * @param period Indicates the vsync period. 1127777dab0Sopenharmony_ci * @return Returns int32_t, return value == 0, success, otherwise, failed. 1137777dab0Sopenharmony_ci * @since 10 1147777dab0Sopenharmony_ci * @version 1.0 1157777dab0Sopenharmony_ci */ 1167777dab0Sopenharmony_ciint OH_NativeVSync_GetPeriod(OH_NativeVSync* nativeVsync, long long* period); 1177777dab0Sopenharmony_ci#ifdef __cplusplus 1187777dab0Sopenharmony_ci} 1197777dab0Sopenharmony_ci#endif 1207777dab0Sopenharmony_ci 1217777dab0Sopenharmony_ci#endif