aboutsummaryrefslogtreecommitdiff
path: root/system/hwc2/DisplayConfig.h
blob: 67e4c49e4cb4b5249b8142a1595cb86f54b54ad4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 * Copyright 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_HWC_DISPLAYCONFIG_H
#define ANDROID_HWC_DISPLAYCONFIG_H

#include <android/hardware/graphics/common/1.0/types.h>

#include <vector>

#include "Common.h"

class DisplayConfig {
 public:
  DisplayConfig(hwc2_config_t configId) : mId(configId) {}

  DisplayConfig(hwc2_config_t configId, int32_t width, int32_t height,
                int32_t dpiX, int32_t dpiY, int32_t vsyncPeriodNanos)
      : mId(configId),
        mWidth(width),
        mHeight(height),
        mDpiX(dpiX),
        mDpiY(dpiY),
        mVsyncPeriodNanos(vsyncPeriodNanos) {}

  DisplayConfig(const DisplayConfig& other) = default;
  DisplayConfig& operator=(DisplayConfig& other) = default;

  DisplayConfig(DisplayConfig&& other) = default;
  DisplayConfig& operator=(DisplayConfig&& other) = default;

  hwc2_config_t getId() const { return mId; }
  void setId(hwc2_config_t id) { mId = id; }

  int32_t getAttribute(HWC2::Attribute attribute) const;
  void setAttribute(HWC2::Attribute attribute, int32_t value);

  int32_t getWidth() const { return mWidth; }
  void setWidth(int32_t width) { mWidth = width; }

  int32_t getHeight() const { return mHeight; }
  void getHeight(int32_t height) { mHeight = height; }

  int32_t getDpiX() const { return mDpiX; }
  void setDpiX(int32_t dpi) { mDpiX = dpi; }

  int32_t getDpiY() const { return mDpiY; }
  void setDpiY(int32_t dpi) { mDpiY = dpi; }

  int32_t getDotsPerThousandInchesX() const { return mDpiX * 1000; }
  int32_t getDotsPerThousandInchesY() const { return mDpiY * 1000; }

  int32_t getVsyncPeriod() const { return mVsyncPeriodNanos; }
  void setVsyncPeriod(int32_t vsync) { mVsyncPeriodNanos = vsync; }

  int32_t getConfigGroup() const { return mConfigGroup; }
  void setConfigGroup(int32_t group) { mConfigGroup = group; }

  std::string toString() const;

  static void addConfigGroups(std::vector<DisplayConfig>* configs);

 private:
  hwc2_config_t mId;

  int32_t mWidth;
  int32_t mHeight;
  int32_t mDpiX;
  int32_t mDpiY;
  int32_t mVsyncPeriodNanos;
  int32_t mConfigGroup;
};

#endif