blob: 1abd992ca2d0e9da5464f4efe181cbc21b5e2ae5 [file] [log] [blame]
Jason Macnakb53b7902022-01-12 15:59:56 -08001/*
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
26namespace aidl::android::hardware::graphics::composer3::impl {
27
28class DisplayConfig {
Kaiyi Li15765fe2024-01-24 09:16:05 -080029 public:
30 DisplayConfig(int32_t configId) : mId(configId) {}
Jason Macnakb53b7902022-01-12 15:59:56 -080031
Kaiyi Li15765fe2024-01-24 09:16:05 -080032 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 Macnakb53b7902022-01-12 15:59:56 -080040
Kaiyi Li15765fe2024-01-24 09:16:05 -080041 DisplayConfig(const DisplayConfig& other) = default;
42 DisplayConfig& operator=(DisplayConfig& other) = default;
Jason Macnakb53b7902022-01-12 15:59:56 -080043
Kaiyi Li15765fe2024-01-24 09:16:05 -080044 DisplayConfig(DisplayConfig&& other) = default;
45 DisplayConfig& operator=(DisplayConfig&& other) = default;
Jason Macnakb53b7902022-01-12 15:59:56 -080046
Kaiyi Li15765fe2024-01-24 09:16:05 -080047 int32_t getId() const { return mId; }
48 void setId(int32_t id) { mId = id; }
Jason Macnakb53b7902022-01-12 15:59:56 -080049
Kaiyi Li15765fe2024-01-24 09:16:05 -080050 int32_t getAttribute(DisplayAttribute attribute) const;
51 void setAttribute(DisplayAttribute attribute, int32_t value);
Jason Macnakb53b7902022-01-12 15:59:56 -080052
Kaiyi Li15765fe2024-01-24 09:16:05 -080053 int32_t getWidth() const { return mWidth; }
54 void setWidth(int32_t width) { mWidth = width; }
Jason Macnakb53b7902022-01-12 15:59:56 -080055
Kaiyi Li15765fe2024-01-24 09:16:05 -080056 int32_t getHeight() const { return mHeight; }
57 void getHeight(int32_t height) { mHeight = height; }
Jason Macnakb53b7902022-01-12 15:59:56 -080058
Kaiyi Li15765fe2024-01-24 09:16:05 -080059 int32_t getDpiX() const { return mDpiX; }
60 void setDpiX(int32_t dpi) { mDpiX = dpi; }
Jason Macnakb53b7902022-01-12 15:59:56 -080061
Kaiyi Li15765fe2024-01-24 09:16:05 -080062 int32_t getDpiY() const { return mDpiY; }
63 void setDpiY(int32_t dpi) { mDpiY = dpi; }
Jason Macnakb53b7902022-01-12 15:59:56 -080064
Kaiyi Li15765fe2024-01-24 09:16:05 -080065 int32_t getDotsPerThousandInchesX() const { return mDpiX * 1000; }
66 int32_t getDotsPerThousandInchesY() const { return mDpiY * 1000; }
Jason Macnakb53b7902022-01-12 15:59:56 -080067
Kaiyi Li15765fe2024-01-24 09:16:05 -080068 int32_t getVsyncPeriod() const { return mVsyncPeriodNanos; }
69 void setVsyncPeriod(int32_t vsync) { mVsyncPeriodNanos = vsync; }
Jason Macnakb53b7902022-01-12 15:59:56 -080070
Kaiyi Li15765fe2024-01-24 09:16:05 -080071 int32_t getConfigGroup() const { return mConfigGroup; }
72 void setConfigGroup(int32_t group) { mConfigGroup = group; }
Jason Macnakb53b7902022-01-12 15:59:56 -080073
Kaiyi Li15765fe2024-01-24 09:16:05 -080074 std::string toString() const;
Jason Macnakb53b7902022-01-12 15:59:56 -080075
Kaiyi Li15765fe2024-01-24 09:16:05 -080076 static void addConfigGroups(std::vector<DisplayConfig>* configs);
Jason Macnakb53b7902022-01-12 15:59:56 -080077
Kaiyi Li15765fe2024-01-24 09:16:05 -080078 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 Macnakb53b7902022-01-12 15:59:56 -080086};
87
88} // namespace aidl::android::hardware::graphics::composer3::impl
89
90#endif