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