1 /* 2 * Copyright 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <android/choreographer.h> 20 #include <inttypes.h> 21 22 __BEGIN_DECLS 23 24 /** 25 * Creates an instance of AChoreographer. 26 * 27 * The key differences between this method and AChoreographer_getInstance are: 28 * 1. The returned AChoreographer instance is not a thread-local, and 29 * 2. This method does not require an existing ALooper attached to the thread. 30 */ 31 AChoreographer* AChoreographer_create(); 32 33 /** 34 * Destroys a choreographer instance created from AChoreographer_create. 35 */ 36 void AChoreographer_destroy(AChoreographer* choreographer); 37 38 /** 39 * Returns the underlying file descriptor associated with this choreographer 40 * instance. 41 * 42 * The caller can listen to the file descriptor to respond to any AChoreographer 43 * events. One such way is registering the file descriptor to a Looper instance, 44 * although this is not a requirement. 45 */ 46 int AChoreographer_getFd(const AChoreographer* choreographer); 47 48 /** 49 * Provides a callback to handle all pending events emitted by this 50 * choreographer instance. Specifically, this delegates to the callbacks 51 * previously registered to choreographer. 52 * 53 * If the associated file descriptor is attached to a Looper instance, then the 54 * callback attached to that Looper is expected to handle exceptional Looper 55 * events. 56 */ 57 void AChoreographer_handlePendingEvents(AChoreographer* choreographer, void* data); 58 59 __END_DECLS 60