1 /*
2  * Copyright 2023 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 <ui/DisplayId.h>
20 #include <ui/DisplayMap.h>
21 
22 #include <scheduler/Time.h>
23 #include <scheduler/VsyncId.h>
24 #include <scheduler/interface/CompositeResult.h>
25 
26 namespace android {
27 namespace scheduler {
28 
29 class FrameTarget;
30 class FrameTargeter;
31 
32 using FrameTargets = ui::PhysicalDisplayMap<PhysicalDisplayId, const scheduler::FrameTarget*>;
33 using FrameTargeters = ui::PhysicalDisplayMap<PhysicalDisplayId, scheduler::FrameTargeter*>;
34 
35 } // namespace scheduler
36 
37 struct ICompositor {
38     // Configures physical displays, processing hotplug and/or mode setting via the Composer HAL.
39     virtual void configure() = 0;
40 
41     // Commits transactions for layers and displays. Returns whether any state has been invalidated,
42     // i.e. whether a frame should be composited for each display.
43     virtual bool commit(PhysicalDisplayId pacesetterId, const scheduler::FrameTargets&) = 0;
44 
45     // Composites a frame for each display. CompositionEngine performs GPU and/or HAL composition
46     // via RenderEngine and the Composer HAL, respectively.
47     virtual CompositeResultsPerDisplay composite(PhysicalDisplayId pacesetterId,
48                                                  const scheduler::FrameTargeters&) = 0;
49 
50     // Sends a hint about the expected present time
51     virtual void sendNotifyExpectedPresentHint(PhysicalDisplayId) = 0;
52 
53     // Samples the composited frame via RegionSamplingThread.
54     virtual void sample() = 0;
55 
56 protected:
57     ~ICompositor() = default;
58 };
59 
60 } // namespace android
61