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 { 29 public: DisplayConfig(int32_t configId)30 DisplayConfig(int32_t configId) : mId(configId) {} 31 DisplayConfig(int32_t configId,int32_t width,int32_t height,int32_t dpiX,int32_t dpiY,int32_t vsyncPeriodNanos)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) {} 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 getId()47 int32_t getId() const { return mId; } setId(int32_t id)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 getWidth()53 int32_t getWidth() const { return mWidth; } setWidth(int32_t width)54 void setWidth(int32_t width) { mWidth = width; } 55 getHeight()56 int32_t getHeight() const { return mHeight; } getHeight(int32_t height)57 void getHeight(int32_t height) { mHeight = height; } 58 getDpiX()59 int32_t getDpiX() const { return mDpiX; } setDpiX(int32_t dpi)60 void setDpiX(int32_t dpi) { mDpiX = dpi; } 61 getDpiY()62 int32_t getDpiY() const { return mDpiY; } setDpiY(int32_t dpi)63 void setDpiY(int32_t dpi) { mDpiY = dpi; } 64 getDotsPerThousandInchesX()65 int32_t getDotsPerThousandInchesX() const { return mDpiX * 1000; } getDotsPerThousandInchesY()66 int32_t getDotsPerThousandInchesY() const { return mDpiY * 1000; } 67 getVsyncPeriod()68 int32_t getVsyncPeriod() const { return mVsyncPeriodNanos; } setVsyncPeriod(int32_t vsync)69 void setVsyncPeriod(int32_t vsync) { mVsyncPeriodNanos = vsync; } 70 getConfigGroup()71 int32_t getConfigGroup() const { return mConfigGroup; } setConfigGroup(int32_t group)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