Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2022 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 | #ifndef ANDROID_HWC_DISPLAYCONFIG_H |
| 18 | #define ANDROID_HWC_DISPLAYCONFIG_H |
| 19 | |
| 20 | #include <aidl/android/hardware/graphics/composer3/DisplayAttribute.h> |
| 21 | |
| 22 | #include <vector> |
| 23 | |
| 24 | #include "Common.h" |
| 25 | |
| 26 | namespace aidl::android::hardware::graphics::composer3::impl { |
| 27 | |
| 28 | class DisplayConfig { |
Kaiyi Li | 15765fe | 2024-01-24 09:16:05 -0800 | [diff] [blame] | 29 | public: |
| 30 | DisplayConfig(int32_t configId) : mId(configId) {} |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 31 | |
Kaiyi Li | 15765fe | 2024-01-24 09:16:05 -0800 | [diff] [blame] | 32 | DisplayConfig(int32_t configId, int32_t width, int32_t height, int32_t dpiX, int32_t dpiY, |
| 33 | int32_t vsyncPeriodNanos) |
| 34 | : mId(configId), |
| 35 | mWidth(width), |
| 36 | mHeight(height), |
| 37 | mDpiX(dpiX), |
| 38 | mDpiY(dpiY), |
| 39 | mVsyncPeriodNanos(vsyncPeriodNanos) {} |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 40 | |
Kaiyi Li | 15765fe | 2024-01-24 09:16:05 -0800 | [diff] [blame] | 41 | DisplayConfig(const DisplayConfig& other) = default; |
| 42 | DisplayConfig& operator=(DisplayConfig& other) = default; |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 43 | |
Kaiyi Li | 15765fe | 2024-01-24 09:16:05 -0800 | [diff] [blame] | 44 | DisplayConfig(DisplayConfig&& other) = default; |
| 45 | DisplayConfig& operator=(DisplayConfig&& other) = default; |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 46 | |
Kaiyi Li | 15765fe | 2024-01-24 09:16:05 -0800 | [diff] [blame] | 47 | int32_t getId() const { return mId; } |
| 48 | void setId(int32_t id) { mId = id; } |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 49 | |
Kaiyi Li | 15765fe | 2024-01-24 09:16:05 -0800 | [diff] [blame] | 50 | int32_t getAttribute(DisplayAttribute attribute) const; |
| 51 | void setAttribute(DisplayAttribute attribute, int32_t value); |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 52 | |
Kaiyi Li | 15765fe | 2024-01-24 09:16:05 -0800 | [diff] [blame] | 53 | int32_t getWidth() const { return mWidth; } |
| 54 | void setWidth(int32_t width) { mWidth = width; } |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 55 | |
Kaiyi Li | 15765fe | 2024-01-24 09:16:05 -0800 | [diff] [blame] | 56 | int32_t getHeight() const { return mHeight; } |
| 57 | void getHeight(int32_t height) { mHeight = height; } |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 58 | |
Kaiyi Li | 15765fe | 2024-01-24 09:16:05 -0800 | [diff] [blame] | 59 | int32_t getDpiX() const { return mDpiX; } |
| 60 | void setDpiX(int32_t dpi) { mDpiX = dpi; } |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 61 | |
Kaiyi Li | 15765fe | 2024-01-24 09:16:05 -0800 | [diff] [blame] | 62 | int32_t getDpiY() const { return mDpiY; } |
| 63 | void setDpiY(int32_t dpi) { mDpiY = dpi; } |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 64 | |
Kaiyi Li | 15765fe | 2024-01-24 09:16:05 -0800 | [diff] [blame] | 65 | int32_t getDotsPerThousandInchesX() const { return mDpiX * 1000; } |
| 66 | int32_t getDotsPerThousandInchesY() const { return mDpiY * 1000; } |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 67 | |
Kaiyi Li | 15765fe | 2024-01-24 09:16:05 -0800 | [diff] [blame] | 68 | int32_t getVsyncPeriod() const { return mVsyncPeriodNanos; } |
| 69 | void setVsyncPeriod(int32_t vsync) { mVsyncPeriodNanos = vsync; } |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 70 | |
Kaiyi Li | 15765fe | 2024-01-24 09:16:05 -0800 | [diff] [blame] | 71 | int32_t getConfigGroup() const { return mConfigGroup; } |
| 72 | void setConfigGroup(int32_t group) { mConfigGroup = group; } |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 73 | |
Kaiyi Li | 15765fe | 2024-01-24 09:16:05 -0800 | [diff] [blame] | 74 | std::string toString() const; |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 75 | |
Kaiyi Li | 15765fe | 2024-01-24 09:16:05 -0800 | [diff] [blame] | 76 | static void addConfigGroups(std::vector<DisplayConfig>* configs); |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 77 | |
Kaiyi Li | 15765fe | 2024-01-24 09:16:05 -0800 | [diff] [blame] | 78 | private: |
| 79 | int32_t mId; |
| 80 | int32_t mWidth; |
| 81 | int32_t mHeight; |
| 82 | int32_t mDpiX; |
| 83 | int32_t mDpiY; |
| 84 | int32_t mVsyncPeriodNanos; |
| 85 | int32_t mConfigGroup; |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | } // namespace aidl::android::hardware::graphics::composer3::impl |
| 89 | |
| 90 | #endif |