blob: 0d9b114875083891dd245a6f36af03394688657c [file] [log] [blame]
Dominik Laskowski068173d2021-08-11 17:22:59 -07001/*
2 * Copyright 2021 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 <memory>
20#include <string>
21
22#include <scheduler/Features.h>
23
24namespace android::scheduler {
25
26// TODO(b/185535769): Rename classes, and remove aliases.
27class VSyncDispatch;
28class VSyncTracker;
29
30class VsyncController;
31using VsyncDispatch = VSyncDispatch;
32using VsyncTracker = VSyncTracker;
33
34// Schedule that synchronizes to hardware VSYNC of a physical display.
35class VsyncSchedule {
36public:
37 explicit VsyncSchedule(FeatureFlags);
38 VsyncSchedule(VsyncSchedule&&);
39 ~VsyncSchedule();
40
41 // TODO(b/185535769): Hide behind API.
42 const VsyncTracker& getTracker() const { return *mTracker; }
43 VsyncTracker& getTracker() { return *mTracker; }
44 VsyncController& getController() { return *mController; }
45
46 // TODO(b/185535769): Remove once VsyncSchedule owns all registrations.
47 VsyncDispatch& getDispatch() { return *mDispatch; }
48
49 void dump(std::string&) const;
50
51private:
52 friend class TestableScheduler;
53
54 using TrackerPtr = std::unique_ptr<VsyncTracker>;
55 using DispatchPtr = std::unique_ptr<VsyncDispatch>;
56 using ControllerPtr = std::unique_ptr<VsyncController>;
57
58 // For tests.
59 VsyncSchedule(TrackerPtr, DispatchPtr, ControllerPtr);
60
61 static TrackerPtr createTracker();
62 static DispatchPtr createDispatch(VsyncTracker&);
63 static ControllerPtr createController(VsyncTracker&, FeatureFlags);
64
65 class PredictedVsyncTracer;
66 using TracerPtr = std::unique_ptr<PredictedVsyncTracer>;
67
68 // Effectively const except in move constructor.
69 TrackerPtr mTracker;
70 DispatchPtr mDispatch;
71 ControllerPtr mController;
72 TracerPtr mTracer;
73};
74
75} // namespace android::scheduler