• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 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 <android/hardware/graphics/common/1.0/types.h>
21 
22 #include <vector>
23 
24 #include "Common.h"
25 
26 class DisplayConfig {
27  public:
DisplayConfig(hwc2_config_t configId)28   DisplayConfig(hwc2_config_t configId) : mId(configId) {}
29 
DisplayConfig(hwc2_config_t configId,int32_t width,int32_t height,int32_t dpiX,int32_t dpiY,int32_t vsyncPeriodNanos)30   DisplayConfig(hwc2_config_t configId, int32_t width, int32_t height,
31                 int32_t dpiX, int32_t dpiY, int32_t vsyncPeriodNanos)
32       : mId(configId),
33         mWidth(width),
34         mHeight(height),
35         mDpiX(dpiX),
36         mDpiY(dpiY),
37         mVsyncPeriodNanos(vsyncPeriodNanos) {}
38 
39   DisplayConfig(const DisplayConfig& other) = default;
40   DisplayConfig& operator=(DisplayConfig& other) = default;
41 
42   DisplayConfig(DisplayConfig&& other) = default;
43   DisplayConfig& operator=(DisplayConfig&& other) = default;
44 
getId()45   hwc2_config_t getId() const { return mId; }
setId(hwc2_config_t id)46   void setId(hwc2_config_t id) { mId = id; }
47 
48   int32_t getAttribute(HWC2::Attribute attribute) const;
49   void setAttribute(HWC2::Attribute attribute, int32_t value);
50 
getWidth()51   int32_t getWidth() const { return mWidth; }
setWidth(int32_t width)52   void setWidth(int32_t width) { mWidth = width; }
53 
getHeight()54   int32_t getHeight() const { return mHeight; }
getHeight(int32_t height)55   void getHeight(int32_t height) { mHeight = height; }
56 
getDpiX()57   int32_t getDpiX() const { return mDpiX; }
setDpiX(int32_t dpi)58   void setDpiX(int32_t dpi) { mDpiX = dpi; }
59 
getDpiY()60   int32_t getDpiY() const { return mDpiY; }
setDpiY(int32_t dpi)61   void setDpiY(int32_t dpi) { mDpiY = dpi; }
62 
getDotsPerThousandInchesX()63   int32_t getDotsPerThousandInchesX() const { return mDpiX * 1000; }
getDotsPerThousandInchesY()64   int32_t getDotsPerThousandInchesY() const { return mDpiY * 1000; }
65 
getVsyncPeriod()66   int32_t getVsyncPeriod() const { return mVsyncPeriodNanos; }
setVsyncPeriod(int32_t vsync)67   void setVsyncPeriod(int32_t vsync) { mVsyncPeriodNanos = vsync; }
68 
getConfigGroup()69   int32_t getConfigGroup() const { return mConfigGroup; }
setConfigGroup(int32_t group)70   void setConfigGroup(int32_t group) { mConfigGroup = group; }
71 
72   std::string toString() const;
73 
74   static void addConfigGroups(std::vector<DisplayConfig>* configs);
75 
76  private:
77   hwc2_config_t mId;
78 
79   int32_t mWidth;
80   int32_t mHeight;
81   int32_t mDpiX;
82   int32_t mDpiY;
83   int32_t mVsyncPeriodNanos;
84   int32_t mConfigGroup;
85 };
86 
87 #endif
88