| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/display/display.h" | 5 #include "ui/display/display.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "ui/display/display_switches.h" | 14 #include "ui/display/display_switches.h" |
| 15 #include "ui/gfx/geometry/insets.h" | 15 #include "ui/gfx/geometry/insets.h" |
| 16 #include "ui/gfx/geometry/point_conversions.h" | 16 #include "ui/gfx/geometry/point_conversions.h" |
| 17 #include "ui/gfx/geometry/point_f.h" | 17 #include "ui/gfx/geometry/point_f.h" |
| 18 #include "ui/gfx/geometry/size_conversions.h" | 18 #include "ui/gfx/geometry/size_conversions.h" |
| 19 #include "ui/gfx/icc_profile.h" |
| 19 | 20 |
| 20 namespace display { | 21 namespace display { |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 constexpr int DEFAULT_BITS_PER_PIXEL = 24; | 24 constexpr int DEFAULT_BITS_PER_PIXEL = 24; |
| 24 constexpr int DEFAULT_BITS_PER_COMPONENT = 8; | 25 constexpr int DEFAULT_BITS_PER_COMPONENT = 8; |
| 25 | 26 |
| 26 constexpr int HDR_BITS_PER_PIXEL = 48; | 27 constexpr int HDR_BITS_PER_PIXEL = 48; |
| 27 constexpr int HDR_BITS_PER_COMPONENT = 16; | 28 constexpr int HDR_BITS_PER_COMPONENT = 16; |
| 28 | 29 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 50 if (!base::StringToDouble(value, &scale_in_double)) { | 51 if (!base::StringToDouble(value, &scale_in_double)) { |
| 51 LOG(ERROR) << "Failed to parse the default device scale factor:" << value; | 52 LOG(ERROR) << "Failed to parse the default device scale factor:" << value; |
| 52 scale_in_double = 1.0; | 53 scale_in_double = 1.0; |
| 53 } | 54 } |
| 54 } | 55 } |
| 55 return static_cast<float>(scale_in_double); | 56 return static_cast<float>(scale_in_double); |
| 56 } | 57 } |
| 57 | 58 |
| 58 int64_t internal_display_id_ = -1; | 59 int64_t internal_display_id_ = -1; |
| 59 | 60 |
| 61 gfx::ColorSpace GetForcedColorSpace() { |
| 62 if (gfx::ICCProfile::HasForcedProfile()) |
| 63 return gfx::ICCProfile::GetForcedProfile().GetColorSpace(); |
| 64 return gfx::ColorSpace::CreateSRGB(); |
| 65 } |
| 66 |
| 60 } // namespace | 67 } // namespace |
| 61 | 68 |
| 62 bool CompareDisplayIds(int64_t id1, int64_t id2) { | 69 bool CompareDisplayIds(int64_t id1, int64_t id2) { |
| 63 DCHECK_NE(id1, id2); | 70 DCHECK_NE(id1, id2); |
| 64 // Output index is stored in the first 8 bits. See GetDisplayIdFromEDID | 71 // Output index is stored in the first 8 bits. See GetDisplayIdFromEDID |
| 65 // in edid_parser.cc. | 72 // in edid_parser.cc. |
| 66 int index_1 = id1 & 0xFF; | 73 int index_1 = id1 & 0xFF; |
| 67 int index_2 = id2 & 0xFF; | 74 int index_2 = id2 & 0xFF; |
| 68 DCHECK_NE(index_1, index_2) << id1 << " and " << id2; | 75 DCHECK_NE(index_1, index_2) << id1 << " and " << id2; |
| 69 return Display::IsInternalDisplayId(id1) || | 76 return Display::IsInternalDisplayId(id1) || |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 108 |
| 102 Display::Display() : Display(kInvalidDisplayId) {} | 109 Display::Display() : Display(kInvalidDisplayId) {} |
| 103 | 110 |
| 104 Display::Display(int64_t id) : Display(id, gfx::Rect()) {} | 111 Display::Display(int64_t id) : Display(id, gfx::Rect()) {} |
| 105 | 112 |
| 106 Display::Display(int64_t id, const gfx::Rect& bounds) | 113 Display::Display(int64_t id, const gfx::Rect& bounds) |
| 107 : id_(id), | 114 : id_(id), |
| 108 bounds_(bounds), | 115 bounds_(bounds), |
| 109 work_area_(bounds), | 116 work_area_(bounds), |
| 110 device_scale_factor_(GetForcedDeviceScaleFactor()), | 117 device_scale_factor_(GetForcedDeviceScaleFactor()), |
| 118 color_space_(GetForcedColorSpace()), |
| 111 color_depth_(DEFAULT_BITS_PER_PIXEL), | 119 color_depth_(DEFAULT_BITS_PER_PIXEL), |
| 112 depth_per_component_(DEFAULT_BITS_PER_COMPONENT) { | 120 depth_per_component_(DEFAULT_BITS_PER_COMPONENT) { |
| 113 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHDR)) { | 121 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHDR)) { |
| 114 color_depth_ = HDR_BITS_PER_PIXEL; | 122 color_depth_ = HDR_BITS_PER_PIXEL; |
| 115 depth_per_component_ = HDR_BITS_PER_COMPONENT; | 123 depth_per_component_ = HDR_BITS_PER_COMPONENT; |
| 116 } | 124 } |
| 117 #if defined(USE_AURA) | 125 #if defined(USE_AURA) |
| 118 SetScaleAndBounds(device_scale_factor_, bounds); | 126 SetScaleAndBounds(device_scale_factor_, bounds); |
| 119 #endif | 127 #endif |
| 120 } | 128 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 DCHECK_NE(kInvalidDisplayId, display_id); | 242 DCHECK_NE(kInvalidDisplayId, display_id); |
| 235 return HasInternalDisplay() && internal_display_id_ == display_id; | 243 return HasInternalDisplay() && internal_display_id_ == display_id; |
| 236 } | 244 } |
| 237 | 245 |
| 238 // static | 246 // static |
| 239 bool Display::HasInternalDisplay() { | 247 bool Display::HasInternalDisplay() { |
| 240 return internal_display_id_ != kInvalidDisplayId; | 248 return internal_display_id_ != kInvalidDisplayId; |
| 241 } | 249 } |
| 242 | 250 |
| 243 } // namespace display | 251 } // namespace display |
| OLD | NEW |