• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <chrono>
20 #include <optional>
21 #include <vector>
22 #include "utils/Timers.h"
23 
24 #include <compositionengine/Display.h>
25 #include <compositionengine/LayerFE.h>
26 #include <compositionengine/OutputColorSetting.h>
27 #include <math/mat4.h>
28 #include <scheduler/interface/ICompositor.h>
29 #include <ui/FenceTime.h>
30 #include <ui/Transform.h>
31 
32 namespace android::compositionengine {
33 
34 using Layers = std::vector<sp<compositionengine::LayerFE>>;
35 using Outputs = std::vector<std::shared_ptr<compositionengine::Output>>;
36 
37 // Interface of composition engine power hint callback.
38 struct ICEPowerCallback {
39     virtual void notifyCpuLoadUp() = 0;
40 
41 protected:
42     ~ICEPowerCallback() = default;
43 };
44 
45 /**
46  * A parameter object for refreshing a set of outputs
47  */
48 struct CompositionRefreshArgs {
49     // All the outputs being refreshed
50     Outputs outputs;
51 
52     // All the layers that are potentially visible in the outputs. The order of
53     // the layers is important, and should be in traversal order from back to
54     // front.
55     Layers layers;
56 
57     // All the layers that have queued updates.
58     Layers layersWithQueuedFrames;
59 
60     // All graphic buffers that will no longer be used and should be removed from caches.
61     std::vector<uint64_t> bufferIdsToUncache;
62 
63     // Controls how the color mode is chosen for an output
64     OutputColorSetting outputColorSetting{OutputColorSetting::kEnhanced};
65 
66     // Forces a color mode on the outputs being refreshed
67     ui::ColorMode forceOutputColorMode{ui::ColorMode::NATIVE};
68 
69     // Used to correctly apply an inverse-display buffer transform if applicable
70     ui::Transform::RotationFlags internalDisplayRotationFlags{ui::Transform::ROT_0};
71 
72     // If true, the complete output geometry needs to be recomputed this frame
73     bool updatingOutputGeometryThisFrame{false};
74 
75     // If true, there was a geometry update this frame
76     bool updatingGeometryThisFrame{false};
77 
78     // The color matrix to use for this
79     // frame. Only set if the color transform is changing this frame.
80     std::optional<mat4> colorTransformMatrix;
81 
82     // If true, client composition is always used.
83     bool devOptForceClientComposition{false};
84 
85     // If set, causes the dirty regions to flash with the delay
86     std::optional<std::chrono::microseconds> devOptFlashDirtyRegionsDelay;
87 
88     scheduler::FrameTargets frameTargets;
89 
90     // The frameInterval for the next present
91     // TODO (b/315371484): Calculate per display and store on `FrameTarget`.
92     Fps frameInterval;
93 
94     // If set, a frame has been scheduled for that time.
95     // TODO (b/255601557): Calculate per display.
96     std::optional<std::chrono::steady_clock::time_point> scheduledFrameTime;
97 
98     bool hasTrustedPresentationListener = false;
99 
100     ICEPowerCallback* powerCallback = nullptr;
101 
102     // System time for when frame refresh starts. Used for stats.
103     nsecs_t refreshStartTime = 0;
104 };
105 
106 } // namespace android::compositionengine
107