blob: 7130fff40ccf876ca26cd94f0cfe22997f4c2046 [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 {
29 public:
30 DisplayConfig(int32_t configId) : mId(configId) {}
31
32 DisplayConfig(int32_t configId, int32_t width, int32_t height, int32_t dpiX,
33 int32_t dpiY, int32_t vsyncPeriodNanos)
34 : mId(configId),
35 mWidth(width),
36 mHeight(height),
37 mDpiX(dpiX),
38 mDpiY(dpiY),
39 mVsyncPeriodNanos(vsyncPeriodNanos) {}
40
41 DisplayConfig(const DisplayConfig& other) = default;
42 DisplayConfig& operator=(DisplayConfig& other) = default;
43
44 DisplayConfig(DisplayConfig&& other) = default;
45 DisplayConfig& operator=(DisplayConfig&& other) = default;
46
47 int32_t getId() const { return mId; }
48 void setId(int32_t id) { mId = id; }
49
50 int32_t getAttribute(DisplayAttribute attribute) const;
51 void setAttribute(DisplayAttribute attribute, int32_t value);
52
53 int32_t getWidth() const { return mWidth; }
54 void setWidth(int32_t width) { mWidth = width; }
55
56 int32_t getHeight() const { return mHeight; }
57 void getHeight(int32_t height) { mHeight = height; }
58
59 int32_t getDpiX() const { return mDpiX; }
60 void setDpiX(int32_t dpi) { mDpiX = dpi; }
61
62 int32_t getDpiY() const { return mDpiY; }
63 void setDpiY(int32_t dpi) { mDpiY = dpi; }
64
65 int32_t getDotsPerThousandInchesX() const { return mDpiX * 1000; }
66 int32_t getDotsPerThousandInchesY() const { return mDpiY * 1000; }
67
68 int32_t getVsyncPeriod() const { return mVsyncPeriodNanos; }
69 void setVsyncPeriod(int32_t vsync) { mVsyncPeriodNanos = vsync; }
70
71 int32_t getConfigGroup() const { return mConfigGroup; }
72 void setConfigGroup(int32_t group) { mConfigGroup = group; }
73
74 std::string toString() const;
75
76 static void addConfigGroups(std::vector<DisplayConfig>* configs);
77
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;
86};
87
88} // namespace aidl::android::hardware::graphics::composer3::impl
89
90#endif