blob: 4777f1359863fcd598f013e26c9e5b924d602bd2 [file] [log] [blame]
Lloyd Piqueab039b52019-02-13 14:22:42 -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
Lloyd Piquef8cf14d2019-02-28 16:03:12 -080019#include <chrono>
20#include <optional>
Lloyd Piquec29e4c62019-03-07 21:48:19 -080021#include <vector>
Lloyd Piquef8cf14d2019-02-28 16:03:12 -080022
Lloyd Piqueab039b52019-02-13 14:22:42 -080023#include <compositionengine/Display.h>
Lloyd Piquede196652020-01-22 17:29:58 -080024#include <compositionengine/LayerFE.h>
Lloyd Pique6a3b4462019-03-07 20:58:12 -080025#include <compositionengine/OutputColorSetting.h>
Lloyd Pique3eb1b212019-03-07 21:15:40 -080026#include <math/mat4.h>
Ady Abrahamec7aa8a2021-06-28 12:37:09 -070027#include <ui/FenceTime.h>
Snild Dolkow9e217d62020-04-22 15:53:42 +020028#include <ui/Transform.h>
Lloyd Piqueab039b52019-02-13 14:22:42 -080029
30namespace android::compositionengine {
31
Lloyd Piquede196652020-01-22 17:29:58 -080032using Layers = std::vector<sp<compositionengine::LayerFE>>;
Lloyd Piqueab039b52019-02-13 14:22:42 -080033using Outputs = std::vector<std::shared_ptr<compositionengine::Output>>;
34
Tianhao Yao67dd7122022-02-22 17:48:33 +000035struct BorderRenderInfo {
Tianhao Yao10cea3c2022-03-30 01:37:22 +000036 float width = 0;
37 half4 color;
Tianhao Yao67dd7122022-02-22 17:48:33 +000038 std::vector<int32_t> layerIds;
39};
Lloyd Piqueab039b52019-02-13 14:22:42 -080040/**
41 * A parameter object for refreshing a set of outputs
42 */
43struct CompositionRefreshArgs {
44 // All the outputs being refreshed
45 Outputs outputs;
46
47 // All the layers that are potentially visible in the outputs. The order of
48 // the layers is important, and should be in traversal order from back to
49 // front.
50 Layers layers;
Lloyd Piquef8cf14d2019-02-28 16:03:12 -080051
Lloyd Piquec29e4c62019-03-07 21:48:19 -080052 // All the layers that have queued updates.
Lloyd Piquede196652020-01-22 17:29:58 -080053 Layers layersWithQueuedFrames;
Lloyd Piquec29e4c62019-03-07 21:48:19 -080054
Brian Lindahl439afad2022-11-14 11:16:55 -070055 // All graphic buffers that will no longer be used and should be removed from caches.
56 std::vector<uint64_t> bufferIdsToUncache;
57
Lloyd Pique6a3b4462019-03-07 20:58:12 -080058 // Controls how the color mode is chosen for an output
59 OutputColorSetting outputColorSetting{OutputColorSetting::kEnhanced};
60
61 // If not Dataspace::UNKNOWN, overrides the dataspace on each output
62 ui::Dataspace colorSpaceAgnosticDataspace{ui::Dataspace::UNKNOWN};
63
64 // Forces a color mode on the outputs being refreshed
65 ui::ColorMode forceOutputColorMode{ui::ColorMode::NATIVE};
66
Snild Dolkow9e217d62020-04-22 15:53:42 +020067 // Used to correctly apply an inverse-display buffer transform if applicable
68 ui::Transform::RotationFlags internalDisplayRotationFlags{ui::Transform::ROT_0};
69
Lloyd Piquec29e4c62019-03-07 21:48:19 -080070 // If true, the complete output geometry needs to be recomputed this frame
71 bool updatingOutputGeometryThisFrame{false};
72
Lloyd Pique3eb1b212019-03-07 21:15:40 -080073 // If true, there was a geometry update this frame
74 bool updatingGeometryThisFrame{false};
75
76 // The color matrix to use for this
77 // frame. Only set if the color transform is changing this frame.
78 std::optional<mat4> colorTransformMatrix;
79
80 // If true, client composition is always used.
81 bool devOptForceClientComposition{false};
82
Lloyd Piquef8cf14d2019-02-28 16:03:12 -080083 // If set, causes the dirty regions to flash with the delay
84 std::optional<std::chrono::microseconds> devOptFlashDirtyRegionsDelay;
Ady Abraham3645e642021-04-20 18:39:00 -070085
86 // The earliest time to send the present command to the HAL
87 std::chrono::steady_clock::time_point earliestPresentTime;
Alec Mouriaa831582021-06-07 16:23:01 -070088
Ady Abrahamec7aa8a2021-06-28 12:37:09 -070089 // The previous present fence. Used together with earliestPresentTime
90 // to prevent an early presentation of a frame.
91 std::shared_ptr<FenceTime> previousPresentFence;
92
Ady Abraham43065bd2021-12-10 17:22:15 -080093 // The expected time for the next present
94 nsecs_t expectedPresentTime{0};
95
Dominik Laskowskie0e0cde2021-07-30 10:42:05 -070096 // If set, a frame has been scheduled for that time.
97 std::optional<std::chrono::steady_clock::time_point> scheduledFrameTime;
Tianhao Yao67dd7122022-02-22 17:48:33 +000098
99 std::vector<BorderRenderInfo> borderInfoList;
Lloyd Piqueab039b52019-02-13 14:22:42 -0800100};
101
102} // namespace android::compositionengine