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

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

Issue 1543183002: Switch to standard integer types in ui/gfx/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/gfx/display.h ('k') | ui/gfx/display_change_notifier.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/gfx/display.h" 5 #include "ui/gfx/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 "ui/gfx/geometry/insets.h" 14 #include "ui/gfx/geometry/insets.h"
14 #include "ui/gfx/geometry/point_conversions.h" 15 #include "ui/gfx/geometry/point_conversions.h"
15 #include "ui/gfx/geometry/point_f.h" 16 #include "ui/gfx/geometry/point_f.h"
16 #include "ui/gfx/geometry/size_conversions.h" 17 #include "ui/gfx/geometry/size_conversions.h"
17 #include "ui/gfx/switches.h" 18 #include "ui/gfx/switches.h"
18 19
19 namespace gfx { 20 namespace gfx {
20 namespace { 21 namespace {
21 22
22 // This variable tracks whether the forced device scale factor switch needs to 23 // This variable tracks whether the forced device scale factor switch needs to
(...skipping 18 matching lines...) Expand all
41 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 42 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
42 switches::kForceDeviceScaleFactor); 43 switches::kForceDeviceScaleFactor);
43 if (!base::StringToDouble(value, &scale_in_double)) { 44 if (!base::StringToDouble(value, &scale_in_double)) {
44 LOG(ERROR) << "Failed to parse the default device scale factor:" << value; 45 LOG(ERROR) << "Failed to parse the default device scale factor:" << value;
45 scale_in_double = 1.0; 46 scale_in_double = 1.0;
46 } 47 }
47 } 48 }
48 return static_cast<float>(scale_in_double); 49 return static_cast<float>(scale_in_double);
49 } 50 }
50 51
51 int64 internal_display_id_ = -1; 52 int64_t internal_display_id_ = -1;
52 53
53 } // namespace 54 } // namespace
54 55
55 // static 56 // static
56 float Display::GetForcedDeviceScaleFactor() { 57 float Display::GetForcedDeviceScaleFactor() {
57 if (g_forced_device_scale_factor < 0) 58 if (g_forced_device_scale_factor < 0)
58 g_forced_device_scale_factor = GetForcedDeviceScaleFactorImpl(); 59 g_forced_device_scale_factor = GetForcedDeviceScaleFactorImpl();
59 return g_forced_device_scale_factor; 60 return g_forced_device_scale_factor;
60 } 61 }
61 62
(...skipping 10 matching lines...) Expand all
72 g_forced_device_scale_factor = -1.0; 73 g_forced_device_scale_factor = -1.0;
73 } 74 }
74 75
75 Display::Display() 76 Display::Display()
76 : id_(kInvalidDisplayID), 77 : id_(kInvalidDisplayID),
77 device_scale_factor_(GetForcedDeviceScaleFactor()), 78 device_scale_factor_(GetForcedDeviceScaleFactor()),
78 rotation_(ROTATE_0), 79 rotation_(ROTATE_0),
79 touch_support_(TOUCH_SUPPORT_UNKNOWN) { 80 touch_support_(TOUCH_SUPPORT_UNKNOWN) {
80 } 81 }
81 82
82 Display::Display(int64 id) 83 Display::Display(int64_t id)
83 : id_(id), 84 : id_(id),
84 device_scale_factor_(GetForcedDeviceScaleFactor()), 85 device_scale_factor_(GetForcedDeviceScaleFactor()),
85 rotation_(ROTATE_0), 86 rotation_(ROTATE_0),
86 touch_support_(TOUCH_SUPPORT_UNKNOWN) { 87 touch_support_(TOUCH_SUPPORT_UNKNOWN) {}
87 }
88 88
89 Display::Display(int64 id, const gfx::Rect& bounds) 89 Display::Display(int64_t id, const gfx::Rect& bounds)
90 : id_(id), 90 : id_(id),
91 bounds_(bounds), 91 bounds_(bounds),
92 work_area_(bounds), 92 work_area_(bounds),
93 device_scale_factor_(GetForcedDeviceScaleFactor()), 93 device_scale_factor_(GetForcedDeviceScaleFactor()),
94 rotation_(ROTATE_0), 94 rotation_(ROTATE_0),
95 touch_support_(TOUCH_SUPPORT_UNKNOWN) { 95 touch_support_(TOUCH_SUPPORT_UNKNOWN) {
96 #if defined(USE_AURA) 96 #if defined(USE_AURA)
97 SetScaleAndBounds(device_scale_factor_, bounds); 97 SetScaleAndBounds(device_scale_factor_, bounds);
98 #endif 98 #endif
99 } 99 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 work_area_.ToString().c_str(), 189 work_area_.ToString().c_str(),
190 device_scale_factor_, 190 device_scale_factor_,
191 IsInternal() ? "internal" : "external"); 191 IsInternal() ? "internal" : "external");
192 } 192 }
193 193
194 bool Display::IsInternal() const { 194 bool Display::IsInternal() const {
195 return is_valid() && (id_ == internal_display_id_); 195 return is_valid() && (id_ == internal_display_id_);
196 } 196 }
197 197
198 // static 198 // static
199 int64 Display::InternalDisplayId() { 199 int64_t Display::InternalDisplayId() {
200 DCHECK_NE(kInvalidDisplayID, internal_display_id_); 200 DCHECK_NE(kInvalidDisplayID, internal_display_id_);
201 return internal_display_id_; 201 return internal_display_id_;
202 } 202 }
203 203
204 // static 204 // static
205 void Display::SetInternalDisplayId(int64 internal_display_id) { 205 void Display::SetInternalDisplayId(int64_t internal_display_id) {
206 internal_display_id_ = internal_display_id; 206 internal_display_id_ = internal_display_id;
207 } 207 }
208 208
209 // static 209 // static
210 bool Display::IsInternalDisplayId(int64 display_id) { 210 bool Display::IsInternalDisplayId(int64_t display_id) {
211 DCHECK_NE(kInvalidDisplayID, display_id); 211 DCHECK_NE(kInvalidDisplayID, display_id);
212 return HasInternalDisplay() && internal_display_id_ == display_id; 212 return HasInternalDisplay() && internal_display_id_ == display_id;
213 } 213 }
214 214
215 // static 215 // static
216 bool Display::HasInternalDisplay() { 216 bool Display::HasInternalDisplay() {
217 return internal_display_id_ != kInvalidDisplayID; 217 return internal_display_id_ != kInvalidDisplayID;
218 } 218 }
219 219
220 } // namespace gfx 220 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/display.h ('k') | ui/gfx/display_change_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698