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

Side by Side Diff: ash/display/display_info.cc

Issue 455443002: Remember the configured device scale factor for external displays. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <stdio.h> 5 #include <stdio.h>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/display/display_info.h" 9 #include "ash/display/display_info.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 case 'l': // rotate 90 degrees to 'left'. 121 case 'l': // rotate 90 degrees to 'left'.
122 rotation = gfx::Display::ROTATE_270; 122 rotation = gfx::Display::ROTATE_270;
123 break; 123 break;
124 } 124 }
125 } 125 }
126 } 126 }
127 } 127 }
128 128
129 int x = 0, y = 0, width, height; 129 int x = 0, y = 0, width, height;
130 float device_scale_factor = 1.0f; 130 float device_scale_factor = 1.0f;
131 if (sscanf(main_spec.c_str(), "%dx%d*%f", 131 if (sscanf(main_spec.c_str(), "%dx%d*%f",
oshima 2014/08/07 23:03:49 can you consolidate this?
Jun Mukai 2014/08/08 00:57:33 Done.
132 &width, &height, &device_scale_factor) >= 2 || 132 &width, &height, &device_scale_factor) >= 2 ||
133 sscanf(main_spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height, 133 sscanf(main_spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height,
134 &device_scale_factor) >= 4) { 134 &device_scale_factor) >= 4) {
135 bounds_in_native.SetRect(x, y, width, height); 135 bounds_in_native.SetRect(x, y, width, height);
136 } else { 136 } else {
137 #if defined(OS_WIN) 137 #if defined(OS_WIN)
138 if (gfx::IsHighDPIEnabled()) { 138 if (gfx::IsHighDPIEnabled()) {
139 device_scale_factor = gfx::GetDPIScale(); 139 device_scale_factor = gfx::GetDPIScale();
140 } 140 }
141 #endif 141 #endif
142 } 142 }
143 143
144 std::vector<DisplayMode> display_modes; 144 std::vector<DisplayMode> display_modes;
145 if (Tokenize(main_spec, "#", &parts) == 2) { 145 if (Tokenize(main_spec, "#", &parts) == 2) {
146 size_t native_mode = 0; 146 size_t native_mode = 0;
147 int largest_area = -1; 147 int largest_area = -1;
148 float highest_refresh_rate = -1.0f; 148 float highest_refresh_rate = -1.0f;
149 main_spec = parts[0]; 149 main_spec = parts[0];
150 std::string resolution_list = parts[1]; 150 std::string resolution_list = parts[1];
151 count = Tokenize(resolution_list, "|", &parts); 151 count = Tokenize(resolution_list, "|", &parts);
152 for (size_t i = 0; i < count; ++i) { 152 for (size_t i = 0; i < count; ++i) {
153 std::string resolution = parts[i]; 153 std::string resolution = parts[i];
154 int width, height; 154 int width, height;
155 float refresh_rate = 0.0f; 155 float refresh_rate = 0.0f;
156 float device_scale_factor = 1.0f;
157 size_t asterisk_pos = resolution.find("*");
158 if (asterisk_pos != std::string::npos) {
159 sscanf(resolution.substr(asterisk_pos + 1).c_str(),
160 "%f",
161 &device_scale_factor);
162 resolution = resolution.substr(0, asterisk_pos);
163 }
156 if (sscanf(resolution.c_str(), 164 if (sscanf(resolution.c_str(),
157 "%dx%d%%%f", 165 "%dx%d%%%f",
158 &width, 166 &width,
159 &height, 167 &height,
160 &refresh_rate) >= 2) { 168 &refresh_rate) >= 2) {
161 if (width * height >= largest_area && 169 if (width * height >= largest_area &&
162 refresh_rate > highest_refresh_rate) { 170 refresh_rate > highest_refresh_rate) {
163 // Use mode with largest area and highest refresh rate as native. 171 // Use mode with largest area and highest refresh rate as native.
164 largest_area = width * height; 172 largest_area = width * height;
165 highest_refresh_rate = refresh_rate; 173 highest_refresh_rate = refresh_rate;
166 native_mode = i; 174 native_mode = i;
167 } 175 }
168 display_modes.push_back( 176 DisplayMode mode(gfx::Size(width, height), refresh_rate, false, false);
169 DisplayMode(gfx::Size(width, height), refresh_rate, false, false)); 177 mode.device_scale_factor = device_scale_factor;
178 display_modes.push_back(mode);
170 } 179 }
171 } 180 }
172 display_modes[native_mode].native = true; 181 display_modes[native_mode].native = true;
173 } 182 }
174 183
175 if (id == gfx::Display::kInvalidDisplayID) 184 if (id == gfx::Display::kInvalidDisplayID)
176 id = synthesized_display_id++; 185 id = synthesized_display_id++;
177 DisplayInfo display_info( 186 DisplayInfo display_info(
178 id, base::StringPrintf("Display-%d", static_cast<int>(id)), has_overscan); 187 id, base::StringPrintf("Display-%d", static_cast<int>(id)), has_overscan);
179 display_info.set_device_scale_factor(device_scale_factor); 188 display_info.set_device_scale_factor(device_scale_factor);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 } 369 }
361 370
362 bool DisplayInfo::IsColorProfileAvailable( 371 bool DisplayInfo::IsColorProfileAvailable(
363 ui::ColorCalibrationProfile profile) const { 372 ui::ColorCalibrationProfile profile) const {
364 return std::find(available_color_profiles_.begin(), 373 return std::find(available_color_profiles_.begin(),
365 available_color_profiles_.end(), 374 available_color_profiles_.end(),
366 profile) != available_color_profiles_.end(); 375 profile) != available_color_profiles_.end();
367 } 376 }
368 377
369 } // namespace ash 378 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698