Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: ui/display/display.cc

Issue 2742383006: Display: set color_depth and depth_per_component value based on kEnableHDROutput (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/compositor/compositor.cc ('k') | ui/display/display_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 19
20 namespace display { 20 namespace display {
21 namespace { 21 namespace {
22 22
23 constexpr int DEFAULT_BITS_PER_PIXEL = 24;
24 constexpr int DEFAULT_BITS_PER_COMPONENT = 8;
25
26 constexpr int HDR_BITS_PER_PIXEL = 48;
27 constexpr int HDR_BITS_PER_COMPONENT = 16;
28
23 // This variable tracks whether the forced device scale factor switch needs to 29 // This variable tracks whether the forced device scale factor switch needs to
24 // be read from the command line, i.e. if it is set to -1 then the command line 30 // be read from the command line, i.e. if it is set to -1 then the command line
25 // is checked. 31 // is checked.
26 int g_has_forced_device_scale_factor = -1; 32 int g_has_forced_device_scale_factor = -1;
27 33
28 // This variable caches the forced device scale factor value which is read off 34 // This variable caches the forced device scale factor value which is read off
29 // the command line. If the cache is invalidated by setting this variable to 35 // the command line. If the cache is invalidated by setting this variable to
30 // -1.0, we read the forced device scale factor again. 36 // -1.0, we read the forced device scale factor again.
31 float g_forced_device_scale_factor = -1.0; 37 float g_forced_device_scale_factor = -1.0;
32 38
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 g_has_forced_device_scale_factor = HasForceDeviceScaleFactorImpl(); 72 g_has_forced_device_scale_factor = HasForceDeviceScaleFactorImpl();
67 return !!g_has_forced_device_scale_factor; 73 return !!g_has_forced_device_scale_factor;
68 } 74 }
69 75
70 // static 76 // static
71 void Display::ResetForceDeviceScaleFactorForTesting() { 77 void Display::ResetForceDeviceScaleFactorForTesting() {
72 g_has_forced_device_scale_factor = -1; 78 g_has_forced_device_scale_factor = -1;
73 g_forced_device_scale_factor = -1.0; 79 g_forced_device_scale_factor = -1.0;
74 } 80 }
75 81
76 constexpr int DEFAULT_BITS_PER_PIXEL = 24;
77 constexpr int DEFAULT_BITS_PER_COMPONENT = 8;
78
79 Display::Display() : Display(kInvalidDisplayId) {} 82 Display::Display() : Display(kInvalidDisplayId) {}
80 83
81 Display::Display(int64_t id) : Display(id, gfx::Rect()) {} 84 Display::Display(int64_t id) : Display(id, gfx::Rect()) {}
82 85
83 Display::Display(int64_t id, const gfx::Rect& bounds) 86 Display::Display(int64_t id, const gfx::Rect& bounds)
84 : id_(id), 87 : id_(id),
85 bounds_(bounds), 88 bounds_(bounds),
86 work_area_(bounds), 89 work_area_(bounds),
87 device_scale_factor_(GetForcedDeviceScaleFactor()), 90 device_scale_factor_(GetForcedDeviceScaleFactor()),
88 color_depth_(DEFAULT_BITS_PER_PIXEL), 91 color_depth_(DEFAULT_BITS_PER_PIXEL),
89 depth_per_component_(DEFAULT_BITS_PER_COMPONENT) { 92 depth_per_component_(DEFAULT_BITS_PER_COMPONENT) {
93 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHDR)) {
94 color_depth_ = HDR_BITS_PER_PIXEL;
95 depth_per_component_ = HDR_BITS_PER_COMPONENT;
96 }
90 #if defined(USE_AURA) 97 #if defined(USE_AURA)
91 SetScaleAndBounds(device_scale_factor_, bounds); 98 SetScaleAndBounds(device_scale_factor_, bounds);
92 #endif 99 #endif
93 } 100 }
94 101
95 Display::Display(const Display& other) = default; 102 Display::Display(const Display& other) = default;
96 103
97 Display::~Display() {} 104 Display::~Display() {}
98 105
99 int Display::RotationAsDegree() const { 106 int Display::RotationAsDegree() const {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 DCHECK_NE(kInvalidDisplayId, display_id); 214 DCHECK_NE(kInvalidDisplayId, display_id);
208 return HasInternalDisplay() && internal_display_id_ == display_id; 215 return HasInternalDisplay() && internal_display_id_ == display_id;
209 } 216 }
210 217
211 // static 218 // static
212 bool Display::HasInternalDisplay() { 219 bool Display::HasInternalDisplay() {
213 return internal_display_id_ != kInvalidDisplayId; 220 return internal_display_id_ != kInvalidDisplayId;
214 } 221 }
215 222
216 } // namespace display 223 } // namespace display
OLDNEW
« no previous file with comments | « ui/compositor/compositor.cc ('k') | ui/display/display_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698