161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit ArkGraphics2D 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ciimport type { Callback } from './@ohos.base'; 2261847f8eSopenharmony_ci 2361847f8eSopenharmony_ci/** 2461847f8eSopenharmony_ci * Provides functions of applying an independent draw frame rate used for drawing the UI. 2561847f8eSopenharmony_ci * 2661847f8eSopenharmony_ci * @namespace displaySync 2761847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 2861847f8eSopenharmony_ci * @since 11 2961847f8eSopenharmony_ci */ 3061847f8eSopenharmony_cideclare namespace displaySync { 3161847f8eSopenharmony_ci /** 3261847f8eSopenharmony_ci * Provides the IntervalInfo interface, which includes timestamp and targetTimestamp. 3361847f8eSopenharmony_ci * @interface IntervalInfo 3461847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 3561847f8eSopenharmony_ci * @since 11 3661847f8eSopenharmony_ci */ 3761847f8eSopenharmony_ci interface IntervalInfo { 3861847f8eSopenharmony_ci /** 3961847f8eSopenharmony_ci * The timestamp means the current drawing frame time. 4061847f8eSopenharmony_ci * @type { number } 4161847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 4261847f8eSopenharmony_ci * @since 11 4361847f8eSopenharmony_ci */ 4461847f8eSopenharmony_ci timestamp: number; 4561847f8eSopenharmony_ci 4661847f8eSopenharmony_ci /** 4761847f8eSopenharmony_ci * The timestamp means the next drawing frame time. 4861847f8eSopenharmony_ci * @type { number } 4961847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 5061847f8eSopenharmony_ci * @since 11 5161847f8eSopenharmony_ci */ 5261847f8eSopenharmony_ci targetTimestamp: number; 5361847f8eSopenharmony_ci } 5461847f8eSopenharmony_ci 5561847f8eSopenharmony_ci /** 5661847f8eSopenharmony_ci * Provides the DisplaySync interface, which can be used to control 5761847f8eSopenharmony_ci * the frequency of triggering callback function. 5861847f8eSopenharmony_ci * @interface DisplaySync 5961847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 6061847f8eSopenharmony_ci * @since 11 6161847f8eSopenharmony_ci */ 6261847f8eSopenharmony_ci interface DisplaySync { 6361847f8eSopenharmony_ci /** 6461847f8eSopenharmony_ci * The expected frame rate of dynamical rate range. 6561847f8eSopenharmony_ci * If the function isn't be called. The DisplaySync's 6661847f8eSopenharmony_ci * minimum/maximum/expected rate default value is 60. 6761847f8eSopenharmony_ci * @param { ExpectedFrameRateRange } rateRange - Indicates ExpectedFrameRateRange. 6861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 6961847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 7061847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 7161847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 7261847f8eSopenharmony_ci * or check ExpectedFrameRateRange if valid. 7361847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 7461847f8eSopenharmony_ci * @since 11 7561847f8eSopenharmony_ci */ 7661847f8eSopenharmony_ci setExpectedFrameRateRange(rateRange: ExpectedFrameRateRange) : void; 7761847f8eSopenharmony_ci 7861847f8eSopenharmony_ci /** 7961847f8eSopenharmony_ci * Registers a callback with the corresponding query condition by using the handle. 8061847f8eSopenharmony_ci * This callback is triggered when DisplaySync dispatching. 8161847f8eSopenharmony_ci * @param { 'frame' } type - The type of event to remove the listener for. Must be 'frame'. 8261847f8eSopenharmony_ci * @param { Callback<IntervalInfo> } callback - The callback function to be called when DisplaySync dispatching. 8361847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 8461847f8eSopenharmony_ci * @since 11 8561847f8eSopenharmony_ci */ 8661847f8eSopenharmony_ci on(type: 'frame', callback: Callback<IntervalInfo>): void; 8761847f8eSopenharmony_ci 8861847f8eSopenharmony_ci /** 8961847f8eSopenharmony_ci * Deregisters a callback with the corresponding query condition by using the handle. 9061847f8eSopenharmony_ci * This callback is triggered when DisplaySync dispatching. 9161847f8eSopenharmony_ci * @param { 'frame' } type - The type of event to remove the listener for. Must be 'frame'. 9261847f8eSopenharmony_ci * @param { Callback<IntervalInfo> } [callback] - The callback function to remove. If not provided, all callbacks for the given event type 9361847f8eSopenharmony_ci * will be removed. 9461847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 9561847f8eSopenharmony_ci * @since 11 9661847f8eSopenharmony_ci */ 9761847f8eSopenharmony_ci off(type: 'frame', callback?: Callback<IntervalInfo>): void; 9861847f8eSopenharmony_ci 9961847f8eSopenharmony_ci /** 10061847f8eSopenharmony_ci * Add DisplaySync to Pipeline. It means that 10161847f8eSopenharmony_ci * the callback function be enabled. 10261847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 10361847f8eSopenharmony_ci * @since 11 10461847f8eSopenharmony_ci */ 10561847f8eSopenharmony_ci start(): void; 10661847f8eSopenharmony_ci 10761847f8eSopenharmony_ci /** 10861847f8eSopenharmony_ci * Delete DisplaySync from Pipeline. It means that 10961847f8eSopenharmony_ci * the callback function be disabled. 11061847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 11161847f8eSopenharmony_ci * @since 11 11261847f8eSopenharmony_ci */ 11361847f8eSopenharmony_ci stop(): void; 11461847f8eSopenharmony_ci } 11561847f8eSopenharmony_ci 11661847f8eSopenharmony_ci /** 11761847f8eSopenharmony_ci * Create a new DisplaySync object. 11861847f8eSopenharmony_ci * @returns { DisplaySync } DisplaySync 11961847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 12061847f8eSopenharmony_ci * @since 11 12161847f8eSopenharmony_ci */ 12261847f8eSopenharmony_ci function create(): DisplaySync; 12361847f8eSopenharmony_ci} 12461847f8eSopenharmony_ci 12561847f8eSopenharmony_ciexport default displaySync; 126