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

Unified Diff: ash/touch/touch_transformer_controller.cc

Issue 635403002: Preserve the native mode when parsing external display modes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-hotplug-in-mirror-mode
Patch Set: . Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/display/display_change_observer_chromeos_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/touch/touch_transformer_controller.cc
diff --git a/ash/touch/touch_transformer_controller.cc b/ash/touch/touch_transformer_controller.cc
index d05cc62de7e826baa71b4294cc72b9276570b7d2..8ff8ad5c3ea4afc931b2a3a412d7a4e81e6e4667 100644
--- a/ash/touch/touch_transformer_controller.cc
+++ b/ash/touch/touch_transformer_controller.cc
@@ -95,22 +95,11 @@ bool TouchTransformerController::ShouldComputeMirrorModeTouchTransformer(
if (touch_display.touch_device_id() == 0)
return false;
- DisplayManager* display_manager = Shell::GetInstance()->display_manager();
- const std::vector<gfx::Display>& displays = display_manager->displays();
- const DisplayInfo* info = NULL;
- for (size_t i = 0; i < displays.size(); i++) {
- const DisplayInfo& current_info =
- display_manager->GetDisplayInfo(displays[i].id());
- if (current_info.touch_device_id() == touch_display.touch_device_id()) {
- info = &current_info;
- break;
- }
- }
-
- if (!info || info->size_in_pixel() == info->GetNativeModeSize() ||
- !info->is_aspect_preserving_scaling()) {
+ if (touch_display.size_in_pixel() == touch_display.GetNativeModeSize() ||
+ !touch_display.is_aspect_preserving_scaling()) {
return false;
}
+
return true;
}
@@ -129,26 +118,16 @@ gfx::Transform TouchTransformerController::GetMirrorModeTouchTransformer(
float mirror_width = touch_display.bounds_in_native().width();
float mirror_height = touch_display.bounds_in_native().height();
- float native_width = 0;
- float native_height = 0;
-
- std::vector<DisplayMode> modes = touch_display.display_modes();
- for (size_t i = 0; i < modes.size(); i++) {
- if (modes[i].native) {
- native_width = modes[i].size.width();
- native_height = modes[i].size.height();
- break;
- }
- }
+ gfx::Size native_mode_size = touch_display.GetNativeModeSize();
+ float native_width = native_mode_size.width();
+ float native_height = native_mode_size.height();
if (native_height == 0.0 || mirror_height == 0.0 ||
native_width == 0.0 || mirror_width == 0.0)
return ctm;
- float native_ar = static_cast<float>(native_width) /
- static_cast<float>(native_height);
- float mirror_ar = static_cast<float>(mirror_width) /
- static_cast<float>(mirror_height);
+ float native_ar = native_width / native_height;
+ float mirror_ar = mirror_width / mirror_height;
if (mirror_ar > native_ar) { // Letterboxing
// Translate before scale.
« no previous file with comments | « ash/display/display_change_observer_chromeos_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698