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 <cstdint> 20 21 #include <math/mat4.h> 22 #include <ui/FenceTime.h> 23 24 // TODO(b/129481165): remove the #pragma below and fix conversion issues 25 #pragma clang diagnostic push 26 #pragma clang diagnostic ignored "-Wconversion" 27 #pragma clang diagnostic ignored "-Wextra" 28 29 #include <ui/GraphicTypes.h> 30 31 // TODO(b/129481165): remove the #pragma below and fix conversion issues 32 #pragma clang diagnostic pop // ignored "-Wconversion -Wextra" 33 34 #include <compositionengine/ProjectionSpace.h> 35 #include <ui/Rect.h> 36 #include <ui/Region.h> 37 #include <ui/Transform.h> 38 39 namespace android { 40 41 namespace compositionengine::impl { 42 43 struct OutputCompositionState { 44 // If false, composition will not be performed for this display 45 bool isEnabled{false}; 46 47 // If false, this output is not considered secure 48 bool isSecure{false}; 49 50 // If true, the current frame on this output uses client composition 51 bool usesClientComposition{false}; 52 53 // If true, the current frame on this output uses device composition 54 bool usesDeviceComposition{false}; 55 56 // If true, the client target should be flipped when performing client composition 57 bool flipClientTarget{false}; 58 59 // If true, the current frame reused the buffer from a previous client composition 60 bool reusedClientComposition{false}; 61 62 // If true, this output displays layers that are internal-only 63 bool layerStackInternal{false}; 64 65 // The layer stack to display on this display 66 uint32_t layerStackId{~0u}; 67 68 // The common space for all layers in the layer stack. layerStackSpace.content is the Rect 69 // which gets projected on the display. The orientation of this space is always ROTATION_0. 70 ProjectionSpace layerStackSpace; 71 72 // Oriented physical display space. It will have the same size as displaySpace oriented to 73 // match the orientation of layerStackSpace. The orientation of this space is always ROTATION_0. 74 ProjectionSpace orientedDisplaySpace; 75 76 // The space of the framebuffer. Its bounds match the size of the framebuffer and its 77 // orientation matches the orientation of the display. Typically the framebuffer space will 78 // be identical to the physical display space. 79 ProjectionSpace framebufferSpace; 80 81 // The space of the physical display. It is as big as the currently active display mode. The 82 // content in this space can be rotated. 83 ProjectionSpace displaySpace; 84 85 // Transformation from layerStackSpace to displaySpace 86 ui::Transform transform; 87 88 // If true, RenderEngine filtering should be enabled 89 bool needsFiltering{false}; 90 91 // The logical coordinates for the dirty region for the display. 92 // dirtyRegion is semi-persistent state. Dirty rectangles are added to it 93 // by the FE until composition happens, at which point it is cleared. 94 Region dirtyRegion; 95 96 // The logical coordinates for the undefined region for the display. 97 // The undefined region is internal to the composition engine. It is 98 // updated every time the geometry changes. 99 Region undefinedRegion; 100 101 // True if the last composition frame had visible layers 102 bool lastCompositionHadVisibleLayers{false}; 103 104 // The color transform matrix to apply 105 mat4 colorTransformMatrix; 106 107 // Current active color mode 108 ui::ColorMode colorMode{ui::ColorMode::NATIVE}; 109 110 // Current active render intent 111 ui::RenderIntent renderIntent{ui::RenderIntent::COLORIMETRIC}; 112 113 // Current active dataspace 114 ui::Dataspace dataspace{ui::Dataspace::UNKNOWN}; 115 116 // Current target dataspace 117 ui::Dataspace targetDataspace{ui::Dataspace::UNKNOWN}; 118 119 // The earliest time to send the present command to the HAL 120 std::chrono::steady_clock::time_point earliestPresentTime; 121 122 // The previous present fence. Used together with earliestPresentTime 123 // to prevent an early presentation of a frame. 124 std::shared_ptr<FenceTime> previousPresentFence; 125 126 // Current display brightness 127 float displayBrightnessNits{-1.f}; 128 129 // SDR white point 130 float sdrWhitePointNits{-1.f}; 131 132 // Debugging 133 void dump(std::string& result) const; 134 }; 135 136 } // namespace compositionengine::impl 137 } // namespace android 138