1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit ArkGraphics2D 19 */ 20 21import type { Callback } from './@ohos.base'; 22 23/** 24 * Provides functions of applying an independent draw frame rate used for drawing the UI. 25 * 26 * @namespace displaySync 27 * @syscap SystemCapability.ArkUI.ArkUI.Full 28 * @since 11 29 */ 30declare namespace displaySync { 31 /** 32 * Provides the IntervalInfo interface, which includes timestamp and targetTimestamp. 33 * @interface IntervalInfo 34 * @syscap SystemCapability.ArkUI.ArkUI.Full 35 * @since 11 36 */ 37 interface IntervalInfo { 38 /** 39 * The timestamp means the current drawing frame time. 40 * @type { number } 41 * @syscap SystemCapability.ArkUI.ArkUI.Full 42 * @since 11 43 */ 44 timestamp: number; 45 46 /** 47 * The timestamp means the next drawing frame time. 48 * @type { number } 49 * @syscap SystemCapability.ArkUI.ArkUI.Full 50 * @since 11 51 */ 52 targetTimestamp: number; 53 } 54 55 /** 56 * Provides the DisplaySync interface, which can be used to control 57 * the frequency of triggering callback function. 58 * @interface DisplaySync 59 * @syscap SystemCapability.ArkUI.ArkUI.Full 60 * @since 11 61 */ 62 interface DisplaySync { 63 /** 64 * The expected frame rate of dynamical rate range. 65 * If the function isn't be called. The DisplaySync's 66 * minimum/maximum/expected rate default value is 60. 67 * @param { ExpectedFrameRateRange } rateRange - Indicates ExpectedFrameRateRange. 68 * @throws { BusinessError } 401 - Parameter error. Possible causes: 69 * <br> 1. Mandatory parameters are left unspecified. 70 * <br> 2. Incorrect parameters types. 71 * <br> 3. Parameter verification failed. 72 * or check ExpectedFrameRateRange if valid. 73 * @syscap SystemCapability.ArkUI.ArkUI.Full 74 * @since 11 75 */ 76 setExpectedFrameRateRange(rateRange: ExpectedFrameRateRange) : void; 77 78 /** 79 * Registers a callback with the corresponding query condition by using the handle. 80 * This callback is triggered when DisplaySync dispatching. 81 * @param { 'frame' } type - The type of event to remove the listener for. Must be 'frame'. 82 * @param { Callback<IntervalInfo> } callback - The callback function to be called when DisplaySync dispatching. 83 * @syscap SystemCapability.ArkUI.ArkUI.Full 84 * @since 11 85 */ 86 on(type: 'frame', callback: Callback<IntervalInfo>): void; 87 88 /** 89 * Deregisters a callback with the corresponding query condition by using the handle. 90 * This callback is triggered when DisplaySync dispatching. 91 * @param { 'frame' } type - The type of event to remove the listener for. Must be 'frame'. 92 * @param { Callback<IntervalInfo> } [callback] - The callback function to remove. If not provided, all callbacks for the given event type 93 * will be removed. 94 * @syscap SystemCapability.ArkUI.ArkUI.Full 95 * @since 11 96 */ 97 off(type: 'frame', callback?: Callback<IntervalInfo>): void; 98 99 /** 100 * Add DisplaySync to Pipeline. It means that 101 * the callback function be enabled. 102 * @syscap SystemCapability.ArkUI.ArkUI.Full 103 * @since 11 104 */ 105 start(): void; 106 107 /** 108 * Delete DisplaySync from Pipeline. It means that 109 * the callback function be disabled. 110 * @syscap SystemCapability.ArkUI.ArkUI.Full 111 * @since 11 112 */ 113 stop(): void; 114 } 115 116 /** 117 * Create a new DisplaySync object. 118 * @returns { DisplaySync } DisplaySync 119 * @syscap SystemCapability.ArkUI.ArkUI.Full 120 * @since 11 121 */ 122 function create(): DisplaySync; 123} 124 125export default displaySync; 126