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

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

Issue 12217120: Add IsInternal property to gfx::Display (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Get rid of static initializer Created 7 years, 10 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/gfx/display.h ('k') | no next file » | 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 14 matching lines...) Expand all
25 double scale_in_double = 1.0; 25 double scale_in_double = 1.0;
26 if (HasForceDeviceScaleFactorImpl()) { 26 if (HasForceDeviceScaleFactorImpl()) {
27 std::string value = CommandLine::ForCurrentProcess()-> 27 std::string value = CommandLine::ForCurrentProcess()->
28 GetSwitchValueASCII(switches::kForceDeviceScaleFactor); 28 GetSwitchValueASCII(switches::kForceDeviceScaleFactor);
29 if (!base::StringToDouble(value, &scale_in_double)) 29 if (!base::StringToDouble(value, &scale_in_double))
30 LOG(ERROR) << "Failed to parse the default device scale factor:" << value; 30 LOG(ERROR) << "Failed to parse the default device scale factor:" << value;
31 } 31 }
32 return static_cast<float>(scale_in_double); 32 return static_cast<float>(scale_in_double);
33 } 33 }
34 34
35 } // namespace 35 const int64 kInvalidDisplayIDForCompileTimeInit = -1;
36 int64 internal_display_id_ = kInvalidDisplayIDForCompileTimeInit;
37 } // namespace
36 38
37 const int64 Display::kInvalidDisplayID = -1; 39 const int64 Display::kInvalidDisplayID = kInvalidDisplayIDForCompileTimeInit;
38 40
39 // static 41 // static
40 float Display::GetForcedDeviceScaleFactor() { 42 float Display::GetForcedDeviceScaleFactor() {
41 static const float kForcedDeviceScaleFactor = 43 static const float kForcedDeviceScaleFactor =
42 GetForcedDeviceScaleFactorImpl(); 44 GetForcedDeviceScaleFactorImpl();
43 return kForcedDeviceScaleFactor; 45 return kForcedDeviceScaleFactor;
44 } 46 }
45 47
46 //static 48 //static
47 bool Display::HasForceDeviceScaleFactor() { 49 bool Display::HasForceDeviceScaleFactor() {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) { 124 void Display::UpdateWorkAreaFromInsets(const gfx::Insets& insets) {
123 work_area_ = bounds_; 125 work_area_ = bounds_;
124 work_area_.Inset(insets); 126 work_area_.Inset(insets);
125 } 127 }
126 128
127 gfx::Size Display::GetSizeInPixel() const { 129 gfx::Size Display::GetSizeInPixel() const {
128 return gfx::ToFlooredSize(gfx::ScaleSize(size(), device_scale_factor_)); 130 return gfx::ToFlooredSize(gfx::ScaleSize(size(), device_scale_factor_));
129 } 131 }
130 132
131 std::string Display::ToString() const { 133 std::string Display::ToString() const {
132 return base::StringPrintf("Display[%lld] bounds=%s, workarea=%s, scale=%f", 134 return base::StringPrintf(
133 static_cast<long long int>(id_), 135 "Display[%lld] bounds=%s, workarea=%s, scale=%f, %s",
134 bounds_.ToString().c_str(), 136 static_cast<long long int>(id_),
135 work_area_.ToString().c_str(), 137 bounds_.ToString().c_str(),
136 device_scale_factor_); 138 work_area_.ToString().c_str(),
139 device_scale_factor_,
140 IsInternal() ? "internal" : "external");
141 }
142
143 bool Display::IsInternal() const {
144 return is_valid() && (id_ == internal_display_id_);
145 }
146
147 int64 Display::InternalDisplayId() {
148 return internal_display_id_;
149 }
150
151 void Display::SetInternalDisplayId(int64 internal_display_id) {
152 internal_display_id_ = internal_display_id;
137 } 153 }
138 154
139 } // namespace gfx 155 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/display.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698