blob: 05fd0fdec37d3fd74137a3db32ec72c2be85e090 [file] [log] [blame]
Kevin DuBoisb2501ba2019-11-12 14:20:29 -08001/*
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-base/thread_annotations.h>
20#include <ui/FenceTime.h>
21#include <memory>
22#include <mutex>
23#include <vector>
24
25namespace android::scheduler {
26
27class VSyncDispatch;
28class VSyncTracker;
29
30// TODO (b/145217110): consider renaming.
31class VSyncReactor /* TODO (b/140201379): : public android::DispSync */ {
32public:
33 VSyncReactor(std::unique_ptr<VSyncDispatch> dispatch, std::unique_ptr<VSyncTracker> tracker,
34 size_t pendingFenceLimit);
35
36 bool addPresentFence(const std::shared_ptr<FenceTime>& fence);
37 void setIgnorePresentFences(bool ignoration);
38
39private:
40 std::unique_ptr<VSyncDispatch> const mDispatch;
41 std::unique_ptr<VSyncTracker> const mTracker;
42 size_t const mPendingLimit;
43
44 std::mutex mMutex;
45 bool mIgnorePresentFences GUARDED_BY(mMutex) = false;
46 std::vector<std::shared_ptr<FenceTime>> mUnfiredFences GUARDED_BY(mMutex);
47};
48
49} // namespace android::scheduler