Path: blob/21.2-virgl/include/android_stub/apex/window.h
4547 views
/*1* Copyright 2019 The Android Open Source Project2*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 at6*7* http://www.apache.org/licenses/LICENSE-2.08*9* Unless required by applicable law or agreed to in writing, software10* 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 and13* limitations under the License.14*/1516#pragma once1718#include <nativebase/nativebase.h>19#include <stdarg.h>2021// apex is a superset of the NDK22#include <android/native_window.h>2324__BEGIN_DECLS2526/*27* perform bits that can be used with ANativeWindow_perform()28*29* This is only to support the intercepting methods below - these should notbe30* used directly otherwise.31*/32enum ANativeWindowPerform {33// clang-format off34ANATIVEWINDOW_PERFORM_SET_USAGE = 0,35ANATIVEWINDOW_PERFORM_SET_BUFFERS_GEOMETRY = 5,36ANATIVEWINDOW_PERFORM_SET_BUFFERS_FORMAT = 9,37ANATIVEWINDOW_PERFORM_SET_USAGE64 = 30,38// clang-format on39};4041/**42* Prototype of the function that an ANativeWindow implementation would call43* when ANativeWindow_cancelBuffer is called.44*/45typedef int (*ANativeWindow_cancelBufferFn)(ANativeWindow* window, ANativeWindowBuffer* buffer,46int fenceFd);4748/**49* Prototype of the function that intercepts an invocation of50* ANativeWindow_cancelBufferFn, along with a data pointer that's passed by the51* caller who set the interceptor, as well as arguments that would be52* passed to ANativeWindow_cancelBufferFn if it were to be called.53*/54typedef int (*ANativeWindow_cancelBufferInterceptor)(ANativeWindow* window,55ANativeWindow_cancelBufferFn cancelBuffer,56void* data, ANativeWindowBuffer* buffer,57int fenceFd);5859/**60* Prototype of the function that an ANativeWindow implementation would call61* when ANativeWindow_dequeueBuffer is called.62*/63typedef int (*ANativeWindow_dequeueBufferFn)(ANativeWindow* window, ANativeWindowBuffer** buffer,64int* fenceFd);6566/**67* Prototype of the function that intercepts an invocation of68* ANativeWindow_dequeueBufferFn, along with a data pointer that's passed by the69* caller who set the interceptor, as well as arguments that would be70* passed to ANativeWindow_dequeueBufferFn if it were to be called.71*/72typedef int (*ANativeWindow_dequeueBufferInterceptor)(ANativeWindow* window,73ANativeWindow_dequeueBufferFn dequeueBuffer,74void* data, ANativeWindowBuffer** buffer,75int* fenceFd);7677/**78* Prototype of the function that an ANativeWindow implementation would call79* when ANativeWindow_perform is called.80*/81typedef int (*ANativeWindow_performFn)(ANativeWindow* window, int operation, va_list args);8283/**84* Prototype of the function that intercepts an invocation of85* ANativeWindow_performFn, along with a data pointer that's passed by the86* caller who set the interceptor, as well as arguments that would be87* passed to ANativeWindow_performFn if it were to be called.88*/89typedef int (*ANativeWindow_performInterceptor)(ANativeWindow* window,90ANativeWindow_performFn perform, void* data,91int operation, va_list args);9293/**94* Prototype of the function that an ANativeWindow implementation would call95* when ANativeWindow_queueBuffer is called.96*/97typedef int (*ANativeWindow_queueBufferFn)(ANativeWindow* window, ANativeWindowBuffer* buffer,98int fenceFd);99100/**101* Prototype of the function that intercepts an invocation of102* ANativeWindow_queueBufferFn, along with a data pointer that's passed by the103* caller who set the interceptor, as well as arguments that would be104* passed to ANativeWindow_queueBufferFn if it were to be called.105*/106typedef int (*ANativeWindow_queueBufferInterceptor)(ANativeWindow* window,107ANativeWindow_queueBufferFn queueBuffer,108void* data, ANativeWindowBuffer* buffer,109int fenceFd);110111/**112* Registers an interceptor for ANativeWindow_cancelBuffer. Instead of calling113* the underlying cancelBuffer function, instead the provided interceptor is114* called, which may optionally call the underlying cancelBuffer function. An115* optional data pointer is also provided to side-channel additional arguments.116*117* Note that usage of this should only be used for specialized use-cases by118* either the system partition or to Mainline modules. This should never be119* exposed to NDK or LL-NDK.120*121* Returns NO_ERROR on success, -errno if registration failed.122*/123int ANativeWindow_setCancelBufferInterceptor(ANativeWindow* window,124ANativeWindow_cancelBufferInterceptor interceptor,125void* data);126127/**128* Registers an interceptor for ANativeWindow_dequeueBuffer. Instead of calling129* the underlying dequeueBuffer function, instead the provided interceptor is130* called, which may optionally call the underlying dequeueBuffer function. An131* optional data pointer is also provided to side-channel additional arguments.132*133* Note that usage of this should only be used for specialized use-cases by134* either the system partition or to Mainline modules. This should never be135* exposed to NDK or LL-NDK.136*137* Returns NO_ERROR on success, -errno if registration failed.138*/139int ANativeWindow_setDequeueBufferInterceptor(ANativeWindow* window,140ANativeWindow_dequeueBufferInterceptor interceptor,141void* data);142/**143* Registers an interceptor for ANativeWindow_perform. Instead of calling144* the underlying perform function, instead the provided interceptor is145* called, which may optionally call the underlying perform function. An146* optional data pointer is also provided to side-channel additional arguments.147*148* Note that usage of this should only be used for specialized use-cases by149* either the system partition or to Mainline modules. This should never be150* exposed to NDK or LL-NDK.151*152* Returns NO_ERROR on success, -errno if registration failed.153*/154int ANativeWindow_setPerformInterceptor(ANativeWindow* window,155ANativeWindow_performInterceptor interceptor, void* data);156/**157* Registers an interceptor for ANativeWindow_queueBuffer. Instead of calling158* the underlying queueBuffer function, instead the provided interceptor is159* called, which may optionally call the underlying queueBuffer function. An160* optional data pointer is also provided to side-channel additional arguments.161*162* Note that usage of this should only be used for specialized use-cases by163* either the system partition or to Mainline modules. This should never be164* exposed to NDK or LL-NDK.165*166* Returns NO_ERROR on success, -errno if registration failed.167*/168int ANativeWindow_setQueueBufferInterceptor(ANativeWindow* window,169ANativeWindow_queueBufferInterceptor interceptor,170void* data);171172/**173* Retrieves how long it took for the last time a buffer was dequeued.174*175* \return the dequeue duration in nanoseconds176*/177int64_t ANativeWindow_getLastDequeueDuration(ANativeWindow* window);178179/**180* Retrieves how long it took for the last time a buffer was queued.181*182* \return the queue duration in nanoseconds183*/184int64_t ANativeWindow_getLastQueueDuration(ANativeWindow* window);185186/**187* Retrieves the system time in nanoseconds when the last time a buffer188* started to be dequeued.189*190* \return the start time in nanoseconds191*/192int64_t ANativeWindow_getLastDequeueStartTime(ANativeWindow* window);193194/**195* Sets a timeout in nanoseconds for dequeue calls. All subsequent dequeue calls196* made by the window will return -ETIMEDOUT after the timeout if the dequeue197* takes too long.198*199* If the provided timeout is negative, hen this removes the previously configured200* timeout. The window then behaves as if ANativeWindow_setDequeueTimeout was201* never called.202*203* \return NO_ERROR on success204* \return BAD_VALUE if the dequeue timeout was unabled to be updated, as205* updating the dequeue timeout may change internals of the underlying window.206*/207int ANativeWindow_setDequeueTimeout(ANativeWindow* window, int64_t timeout);208209__END_DECLS210211212