1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef UI_DISPLAY_TYPES_DISPLAY_CONSTANTS_H_ 6 #define UI_DISPLAY_TYPES_DISPLAY_CONSTANTS_H_ 7 8 #include <stdint.h> 9 #include <array> 10 11 #include "ui/gfx/geometry/size_conversions.h" 12 13 namespace display { 14 15 // Display ID that represents an invalid display. Often used as a default value 16 // before display IDs are known. 17 constexpr int64_t kInvalidDisplayId = -1; 18 19 // Display ID that represents a valid display to be used when there's no actual 20 // display connected. 21 constexpr int64_t kDefaultDisplayId = 0xFF; 22 23 // Display ID for a virtual display assigned to a unified desktop. 24 constexpr int64_t kUnifiedDisplayId = -10; 25 26 // Invalid year of manufacture of the display. 27 constexpr int32_t kInvalidYearOfManufacture = -1; 28 29 // Used to describe the state of a multi-display configuration. 30 enum MultipleDisplayState { 31 MULTIPLE_DISPLAY_STATE_INVALID, 32 MULTIPLE_DISPLAY_STATE_HEADLESS, 33 MULTIPLE_DISPLAY_STATE_SINGLE, 34 MULTIPLE_DISPLAY_STATE_MULTI_MIRROR, // 2+ displays in mirror mode. 35 MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED, // 2+ displays in extended mode. 36 }; 37 38 // Video output types. 39 enum DisplayConnectionType { 40 DISPLAY_CONNECTION_TYPE_NONE = 0, 41 DISPLAY_CONNECTION_TYPE_UNKNOWN = 1 << 0, 42 DISPLAY_CONNECTION_TYPE_INTERNAL = 1 << 1, 43 DISPLAY_CONNECTION_TYPE_VGA = 1 << 2, 44 DISPLAY_CONNECTION_TYPE_HDMI = 1 << 3, 45 DISPLAY_CONNECTION_TYPE_DVI = 1 << 4, 46 DISPLAY_CONNECTION_TYPE_DISPLAYPORT = 1 << 5, 47 DISPLAY_CONNECTION_TYPE_NETWORK = 1 << 6, 48 49 // Update this when adding a new type. 50 DISPLAY_CONNECTION_TYPE_LAST = DISPLAY_CONNECTION_TYPE_NETWORK 51 }; 52 53 // Content protection methods applied on video output. 54 enum ContentProtectionMethod { 55 CONTENT_PROTECTION_METHOD_NONE = 0, 56 CONTENT_PROTECTION_METHOD_HDCP = 1 << 0, 57 // TYPE_0 for HDCP is the default, so make them equivalent. 58 CONTENT_PROTECTION_METHOD_HDCP_TYPE_0 = CONTENT_PROTECTION_METHOD_HDCP, 59 CONTENT_PROTECTION_METHOD_HDCP_TYPE_1 = 1 << 1, 60 }; 61 62 // Bitmask of all the different HDCP types. 63 constexpr uint32_t kContentProtectionMethodHdcpAll = 64 CONTENT_PROTECTION_METHOD_HDCP_TYPE_0 | 65 CONTENT_PROTECTION_METHOD_HDCP_TYPE_1; 66 67 // HDCP protection state. 68 enum HDCPState { 69 HDCP_STATE_UNDESIRED, 70 HDCP_STATE_DESIRED, 71 HDCP_STATE_ENABLED, 72 73 // Update this when adding a new type. 74 HDCP_STATE_LAST = HDCP_STATE_ENABLED 75 }; 76 77 // The orientation of the panel in respect to the natural device orientation. 78 enum PanelOrientation { 79 kNormal = 0, 80 kBottomUp = 1, 81 kLeftUp = 2, 82 kRightUp = 3, 83 kLast = kRightUp 84 }; 85 86 // The existence, or lack thereof, and state of an ePrivacy screen. 87 enum PrivacyScreenState { 88 kDisabled = 0, 89 kEnabled = 1, 90 kNotSupported = 2, 91 kPrivacyScreenStateLast = kNotSupported, 92 }; 93 94 // Defines the float values closest to repeating decimal scale factors. 95 constexpr float kDsf_1_777 = 1.77777779102325439453125f; 96 constexpr float kDsf_2_252 = 2.2522523403167724609375f; 97 constexpr float kDsf_2_666 = 2.6666667461395263671875f; 98 99 constexpr char kDsfStr_1_777[] = "1.77777779102325439453125"; 100 constexpr char kDsfStr_2_252[] = "2.2522523403167724609375"; 101 constexpr char kDsfStr_2_666[] = "2.6666667461395263671875"; 102 103 // The total number of display zoom factors to enumerate. 104 constexpr int kNumOfZoomFactors = 9; 105 106 // A pair representing the list of zoom values for a given minimum display 107 // resolution width. 108 using ZoomListBucket = std::pair<int, std::array<float, kNumOfZoomFactors>>; 109 110 // A pair representing the list of zoom values for a given minimum default dsf. 111 using ZoomListBucketDsf = 112 std::pair<float, std::array<float, kNumOfZoomFactors>>; 113 114 // For displays with a device scale factor of unity, we use a static list of 115 // initialized zoom values. For a given resolution width of a display, we can 116 // find its associated list of zoom values by simply finding the last bucket 117 // with a width less than the given resolution width. 118 // Ex. A resolution width of 1024, we will use the bucket with the width of 960. 119 constexpr std::array<ZoomListBucket, 8> kZoomListBuckets{{ 120 {0, {0.60f, 0.65f, 0.70f, 0.75f, 0.80f, 0.85f, 0.90f, 0.95f, 1.f}}, 121 {720, {0.70f, 0.75f, 0.80f, 0.85f, 0.90f, 0.95f, 1.f, 1.05f, 1.10f}}, 122 {800, {0.75f, 0.80f, 0.85f, 0.90f, 0.95f, 1.f, 1.05f, 1.10f, 1.15f}}, 123 {960, {0.90f, 0.95f, 1.f, 1.05f, 1.10f, 1.15f, 1.20f, 1.25f, 1.30f}}, 124 {1280, {0.90f, 1.f, 1.05f, 1.10f, 1.15f, 1.20f, 1.25f, 1.30f, 1.50f}}, 125 {1920, {1.f, 1.10f, 1.15f, 1.20f, 1.30f, 1.40f, 1.50f, 1.75f, 2.00f}}, 126 {3840, {1.f, 1.10f, 1.20f, 1.40f, 1.60f, 1.80f, 2.00f, 2.20f, 2.40f}}, 127 {5120, {1.f, 1.25f, 1.50f, 1.75f, 2.00f, 2.25f, 2.50f, 2.75f, 3.00f}}, 128 }}; 129 130 // Displays with a default device scale factor have a static list of initialized 131 // zoom values that includes a zoom level to go to the native resolution of the 132 // display. Ensure that the list of DSFs are in sync with the list of default 133 // device scale factors in display_change_observer.cc. 134 constexpr std::array<ZoomListBucketDsf, 7> kZoomListBucketsForDsf{{ 135 {1.25f, {0.7f, 1.f / 1.25f, 0.85f, 0.9f, 0.95f, 1.f, 1.1f, 1.2f, 1.3f}}, 136 {1.6f, {1.f / 1.6f, 0.7f, 0.75f, 0.8f, 0.85f, 0.9f, 1.f, 1.15f, 1.3f}}, 137 {kDsf_1_777, 138 {1.f / kDsf_1_777, 0.65f, 0.75f, 0.8f, 0.9f, 1.f, 1.1f, 1.2f, 1.3f}}, 139 {2.f, {1.f / 2.f, 0.6f, 0.7f, 0.8f, 0.9f, 1.f, 1.1f, 1.25f, 1.5f}}, 140 {kDsf_2_252, 141 {1.f / kDsf_2_252, 0.6f, 0.7f, 0.8f, 0.9f, 1.f, 1.15f, 1.3f, 1.5f}}, 142 {2.4f, {1.f / 2.4f, 0.5f, 0.6f, 0.8f, 0.9f, 1.f, 1.2f, 1.35f, 1.5f}}, 143 {kDsf_2_666, 144 {1.f / kDsf_2_666, 0.5f, 0.6f, 0.8f, 0.9f, 1.f, 1.2f, 1.35f, 1.5f}}, 145 }}; 146 147 // Valid Displays 148 constexpr gfx::Size kWXGA_768{1366, 768}; 149 constexpr gfx::Size kWXGA_800{1280, 800}; 150 constexpr gfx::Size kHD_PLUS{1600, 900}; 151 constexpr gfx::Size kFHD{1920, 1080}; 152 constexpr gfx::Size kWUXGA{1920, 1200}; 153 // Dru 154 constexpr gfx::Size kQXGA_P{1536, 2048}; 155 constexpr gfx::Size kQHD{2560, 1440}; 156 // Chell 157 constexpr gfx::Size kQHD_PLUS{3200, 1800}; 158 constexpr gfx::Size kUHD{3840, 2160}; 159 160 // Chromebook special panels 161 constexpr gfx::Size kLux{2160, 1440}; 162 constexpr gfx::Size kAkaliQHD{2256, 1504}; 163 constexpr gfx::Size kLink{2560, 1700}; 164 constexpr gfx::Size kEveDisplay{2400, 1600}; 165 constexpr gfx::Size kNocturne{3000, 2000}; 166 167 enum SizeErrorCheckType { 168 kExact, // Exact match. 169 kEpsilon, // Matches within epsilon. 170 kSkip, // Skip testing the error. 171 }; 172 173 constexpr struct Data { 174 const float diagonal_size; 175 const gfx::Size resolution; 176 const float expected_dsf; 177 const gfx::Size expected_dp_size; 178 const bool bad_range; 179 const SizeErrorCheckType screenshot_size_error; 180 } display_configs[] = { 181 // clang-format off 182 // inch, resolution, DSF, size in DP, Bad range, size error 183 {10.1f, kWXGA_800, 1.f, kWXGA_800, false, kExact}, 184 {12.1f, kWXGA_800, 1.f, kWXGA_800, true, kExact}, 185 {11.6f, kWXGA_768, 1.f, kWXGA_768, false, kExact}, 186 {13.3f, kWXGA_768, 1.f, kWXGA_768, true, kExact}, 187 {14.f, kWXGA_768, 1.f, kWXGA_768, true, kExact}, 188 {15.6f, kWXGA_768, 1.f, kWXGA_768, true, kExact}, 189 {9.7f, kQXGA_P, 2.0f, {768, 1024}, false, kExact}, 190 {11.6f, kFHD, 1.6f, {1200, 675}, false, kExact}, 191 {13.0f, kFHD, 1.25f, {1536, 864}, true, kExact}, 192 {13.3f, kFHD, 1.25f, {1536, 864}, true, kExact}, 193 {14.f, kFHD, 1.25f, {1536, 864}, false, kExact}, 194 {10.1f, kWUXGA, kDsf_1_777, {1080, 675}, false, kExact}, 195 {12.2f, kWUXGA, 1.6f, {1200, 750}, false, kExact}, 196 {15.6f, kWUXGA, 1.f, kWUXGA, false, kExact}, 197 {12.3f, kQHD, 2.f, {1280, 720}, false, kExact}, 198 199 // Non standard panels 200 {11.0f, kLux, 2.f, {1080, 720}, false, kExact}, 201 {12.02f, kLux, 1.6f, {1350, 900}, true, kExact}, 202 {13.3f, kQHD_PLUS, 2.f, {1600, 900}, false, kSkip}, 203 {13.3f, kAkaliQHD, 1.6f, {1410, 940}, false, kExact}, 204 {12.3f, kEveDisplay,2.0f, {1200, 800}, false, kExact}, 205 {12.85f, kLink, 2.0f, {1280, 850}, false, kExact}, 206 {12.3f, kNocturne, kDsf_2_252, {1332, 888}, false, kEpsilon}, 207 {13.1f, kUHD, kDsf_2_666, {1440, 810}, false, kExact}, 208 {15.6f, kUHD, 2.4f, {1600, 900}, false, kEpsilon}, 209 210 // Chromebase 211 {19.5, kHD_PLUS, 1.f, kHD_PLUS, true, kExact}, 212 {21.5f, kFHD, 1.f, kFHD, true, kExact}, 213 {23.8f, kFHD, 1.f, kFHD, true, kExact}, 214 215 // clang-format on 216 }; 217 218 } // namespace display 219 220 #endif // UI_DISPLAY_TYPES_DISPLAY_CONSTANTS_H_ 221