Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2020 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 <android/hardware/graphics/common/1.1/types.h> |
| 20 | #include <android/hardware/graphics/composer/2.4/IComposer.h> |
| 21 | #include <android/hardware/graphics/composer/2.4/IComposerClient.h> |
| 22 | |
| 23 | #define ERROR_HAS_CHANGES 5 |
| 24 | |
| 25 | namespace android { |
| 26 | namespace hardware::graphics::composer::hal { |
| 27 | |
| 28 | namespace types = android::hardware::graphics::common; |
| 29 | namespace V2_1 = android::hardware::graphics::composer::V2_1; |
| 30 | namespace V2_2 = android::hardware::graphics::composer::V2_2; |
| 31 | namespace V2_3 = android::hardware::graphics::composer::V2_3; |
| 32 | namespace V2_4 = android::hardware::graphics::composer::V2_4; |
| 33 | |
| 34 | using types::V1_0::ColorTransform; |
| 35 | using types::V1_0::Transform; |
| 36 | using types::V1_1::RenderIntent; |
| 37 | using types::V1_2::ColorMode; |
| 38 | using types::V1_2::Dataspace; |
| 39 | using types::V1_2::Hdr; |
| 40 | using types::V1_2::PixelFormat; |
| 41 | |
| 42 | using V2_1::Error; |
| 43 | using V2_4::IComposer; |
| 44 | using V2_4::IComposerCallback; |
| 45 | using V2_4::IComposerClient; |
| 46 | using V2_4::VsyncPeriodChangeTimeline; |
| 47 | using V2_4::VsyncPeriodNanos; |
| 48 | |
| 49 | using Attribute = IComposerClient::Attribute; |
| 50 | using BlendMode = IComposerClient::BlendMode; |
| 51 | using Color = IComposerClient::Color; |
| 52 | using Composition = IComposerClient::Composition; |
| 53 | using Connection = IComposerCallback::Connection; |
| 54 | using ContentType = IComposerClient::ContentType; |
| 55 | using Capability = IComposer::Capability; |
| 56 | using DisplayCapability = IComposerClient::DisplayCapability; |
| 57 | using DisplayRequest = IComposerClient::DisplayRequest; |
| 58 | using DisplayType = IComposerClient::DisplayType; |
| 59 | using HWConfigId = V2_1::Config; |
| 60 | using HWDisplayId = V2_1::Display; |
| 61 | using HWError = V2_1::Error; |
| 62 | using HWLayerId = V2_1::Layer; |
| 63 | using LayerGenericMetadataKey = IComposerClient::LayerGenericMetadataKey; |
| 64 | using LayerRequest = IComposerClient::LayerRequest; |
| 65 | using PerFrameMetadata = IComposerClient::PerFrameMetadata; |
| 66 | using PerFrameMetadataKey = IComposerClient::PerFrameMetadataKey; |
| 67 | using PerFrameMetadataBlob = IComposerClient::PerFrameMetadataBlob; |
| 68 | using PowerMode = IComposerClient::PowerMode; |
| 69 | using Vsync = IComposerClient::Vsync; |
| 70 | using VsyncPeriodChangeConstraints = IComposerClient::VsyncPeriodChangeConstraints; |
| 71 | |
| 72 | } // namespace hardware::graphics::composer::hal |
| 73 | |
| 74 | inline bool hasChangesError(hardware::graphics::composer::hal::Error error) { |
| 75 | return ERROR_HAS_CHANGES == static_cast<int32_t>(error); |
| 76 | } |
| 77 | |
| 78 | inline std::string to_string(hardware::graphics::composer::hal::Attribute attribute) { |
| 79 | switch (attribute) { |
| 80 | case hardware::graphics::composer::hal::Attribute::INVALID: |
| 81 | return "Invalid"; |
| 82 | case hardware::graphics::composer::hal::Attribute::WIDTH: |
| 83 | return "Width"; |
| 84 | case hardware::graphics::composer::hal::Attribute::HEIGHT: |
| 85 | return "Height"; |
| 86 | case hardware::graphics::composer::hal::Attribute::VSYNC_PERIOD: |
| 87 | return "VsyncPeriod"; |
| 88 | case hardware::graphics::composer::hal::Attribute::DPI_X: |
| 89 | return "DpiX"; |
| 90 | case hardware::graphics::composer::hal::Attribute::DPI_Y: |
| 91 | return "DpiY"; |
| 92 | default: |
| 93 | return "Unknown"; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | inline std::string to_string(hardware::graphics::composer::hal::Composition composition) { |
| 98 | switch (composition) { |
| 99 | case hardware::graphics::composer::hal::Composition::INVALID: |
| 100 | return "Invalid"; |
| 101 | case hardware::graphics::composer::hal::Composition::CLIENT: |
| 102 | return "Client"; |
| 103 | case hardware::graphics::composer::hal::Composition::DEVICE: |
| 104 | return "Device"; |
| 105 | case hardware::graphics::composer::hal::Composition::SOLID_COLOR: |
| 106 | return "SolidColor"; |
| 107 | case hardware::graphics::composer::hal::Composition::CURSOR: |
| 108 | return "Cursor"; |
| 109 | case hardware::graphics::composer::hal::Composition::SIDEBAND: |
| 110 | return "Sideband"; |
| 111 | default: |
| 112 | return "Unknown"; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | inline std::string to_string(hardware::graphics::composer::hal::V2_4::Error error) { |
| 117 | // 5 is reserved for historical reason, during validation 5 means has changes. |
| 118 | if (ERROR_HAS_CHANGES == static_cast<int32_t>(error)) { |
| 119 | return "HasChanges"; |
| 120 | } |
| 121 | switch (error) { |
| 122 | case hardware::graphics::composer::hal::V2_4::Error::NONE: |
| 123 | return "None"; |
| 124 | case hardware::graphics::composer::hal::V2_4::Error::BAD_CONFIG: |
| 125 | return "BadConfig"; |
| 126 | case hardware::graphics::composer::hal::V2_4::Error::BAD_DISPLAY: |
| 127 | return "BadDisplay"; |
| 128 | case hardware::graphics::composer::hal::V2_4::Error::BAD_LAYER: |
| 129 | return "BadLayer"; |
| 130 | case hardware::graphics::composer::hal::V2_4::Error::BAD_PARAMETER: |
| 131 | return "BadParameter"; |
| 132 | case hardware::graphics::composer::hal::V2_4::Error::NO_RESOURCES: |
| 133 | return "NoResources"; |
| 134 | case hardware::graphics::composer::hal::V2_4::Error::NOT_VALIDATED: |
| 135 | return "NotValidated"; |
| 136 | case hardware::graphics::composer::hal::V2_4::Error::UNSUPPORTED: |
| 137 | return "Unsupported"; |
| 138 | case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_ALLOWED: |
| 139 | return "SeamlessNotAllowed"; |
| 140 | case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_POSSIBLE: |
| 141 | return "SeamlessNotPossible"; |
| 142 | default: |
| 143 | return "Unknown"; |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | inline std::string to_string(hardware::graphics::composer::hal::Error error) { |
| 148 | return to_string(static_cast<hardware::graphics::composer::hal::V2_4::Error>(error)); |
| 149 | } |
| 150 | |
| 151 | inline std::string to_string(hardware::graphics::composer::hal::PowerMode mode) { |
| 152 | switch (mode) { |
| 153 | case hardware::graphics::composer::hal::PowerMode::OFF: |
| 154 | return "Off"; |
| 155 | case hardware::graphics::composer::hal::PowerMode::DOZE_SUSPEND: |
| 156 | return "DozeSuspend"; |
| 157 | case hardware::graphics::composer::hal::PowerMode::DOZE: |
| 158 | return "Doze"; |
| 159 | case hardware::graphics::composer::hal::PowerMode::ON: |
| 160 | return "On"; |
| 161 | default: |
| 162 | return "Unknown"; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | } // namespace android |