/* * Copyright 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace android { class CallbackHandle : public RefBase { public: CallbackHandle(const sp& transactionListener, const std::vector& ids, const sp& sc); sp listener; std::vector callbackIds; wp surfaceControl; bool releasePreviousBuffer = false; std::string name; sp previousReleaseFence; std::vector> previousReleaseFences; std::vector> previousSharedReleaseFences; std::variant> acquireTimeOrFence = -1; nsecs_t latchTime = -1; std::optional transformHint = std::nullopt; uint32_t currentMaxAcquiredBufferCount = 0; std::shared_ptr gpuCompositionDoneFence{FenceTime::NO_FENCE}; CompositorTiming compositorTiming; nsecs_t refreshStartTime = 0; nsecs_t dequeueReadyTime = 0; uint64_t frameNumber = 0; uint64_t previousFrameNumber = 0; ReleaseCallbackId previousReleaseCallbackId = ReleaseCallbackId::INVALID_ID; }; class TransactionCallbackInvoker { public: status_t addCallbackHandles(const std::deque>& handles, const std::vector& jankData); status_t addOnCommitCallbackHandles(const std::deque>& handles, std::deque>& outRemainingHandles); void addEmptyTransaction(const ListenerCallbacks& listenerCallbacks); void addPresentFence(sp); void sendCallbacks(bool onCommitOnly); void clearCompletedTransactions() { mCompletedTransactions.clear(); } status_t addCallbackHandle(const sp& handle, const std::vector& jankData); private: status_t findOrCreateTransactionStats(const sp& listener, const std::vector& callbackIds, TransactionStats** outTransactionStats); std::unordered_map, std::deque, IListenerHash> mCompletedTransactions; sp mPresentFence; }; } // namespace android