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

Side by Side Diff: chromeos/display/output_configurator.cc

Issue 14279002: Scale TouchEvent's radius when touchscreen is in mirror mode (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: header file order fix Created 7 years, 8 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
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 "chromeos/display/output_configurator.h" 5 #include "chromeos/display/output_configurator.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #include <X11/extensions/Xrandr.h> 8 #include <X11/extensions/Xrandr.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 421
422 for (size_t i = 0; i < outputs.size(); ++i) { 422 for (size_t i = 0; i < outputs.size(); ++i) {
423 delegate_->ConfigureCrtc(&configs[i]); 423 delegate_->ConfigureCrtc(&configs[i]);
424 if (outputs[i].touch_device_id) { 424 if (outputs[i].touch_device_id) {
425 CoordinateTransformation ctm; 425 CoordinateTransformation ctm;
426 // CTM needs to be calculated if aspect preserving scaling is used. 426 // CTM needs to be calculated if aspect preserving scaling is used.
427 // Otherwise, assume it is full screen, and use identity CTM. 427 // Otherwise, assume it is full screen, and use identity CTM.
428 if (outputs[i].mirror_mode != outputs[i].native_mode && 428 if (outputs[i].mirror_mode != outputs[i].native_mode &&
429 outputs[i].is_aspect_preserving_scaling) { 429 outputs[i].is_aspect_preserving_scaling) {
430 ctm = GetMirrorModeCTM(&outputs[i]); 430 ctm = GetMirrorModeCTM(&outputs[i]);
431 mirrored_display_area_ratio_map_[outputs[i].touch_device_id] =
432 GetMirroredDisplayAreaRatio(&outputs[i]);
431 } 433 }
432 delegate_->ConfigureCTM(outputs[i].touch_device_id, ctm); 434 delegate_->ConfigureCTM(outputs[i].touch_device_id, ctm);
433 } 435 }
434 } 436 }
435 break; 437 break;
436 } 438 }
437 case STATE_DUAL_EXTENDED: { 439 case STATE_DUAL_EXTENDED: {
438 if (outputs.size() != 2 || (num_on_outputs != 0 && num_on_outputs != 2)) { 440 if (outputs.size() != 2 || (num_on_outputs != 0 && num_on_outputs != 2)) {
439 LOG(WARNING) << "Ignoring request to enter extended mode with " 441 LOG(WARNING) << "Ignoring request to enter extended mode with "
440 << outputs.size() << " connected output(s) and " 442 << outputs.size() << " connected output(s) and "
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 ctm.y_scale = 1.0; 557 ctm.y_scale = 1.0;
556 ctm.y_offset = 0.0; 558 ctm.y_offset = 0.0;
557 ctm.x_scale = native_mode_ar / mirror_mode_ar; 559 ctm.x_scale = native_mode_ar / mirror_mode_ar;
558 ctm.x_offset = (mirror_mode_ar / native_mode_ar - 1.0) * 0.5; 560 ctm.x_offset = (mirror_mode_ar / native_mode_ar - 1.0) * 0.5;
559 return ctm; 561 return ctm;
560 } 562 }
561 563
562 return ctm; // Same aspect ratio - return identity 564 return ctm; // Same aspect ratio - return identity
563 } 565 }
564 566
567 float OutputConfigurator::GetMirroredDisplayAreaRatio(
568 const OutputConfigurator::OutputSnapshot* output) {
569 float area_ratio = 1.0;
oshima 2013/04/18 08:38:12 1.0f;
Yufeng Shen (Slow to review) 2013/04/18 16:22:56 Done.
570 int native_mode_width = 0, native_mode_height = 0;
571 int mirror_mode_width = 0, mirror_mode_height = 0;
572 if (!delegate_->GetModeDetails(output->native_mode,
573 &native_mode_width, &native_mode_height, NULL) ||
574 !delegate_->GetModeDetails(output->mirror_mode,
575 &mirror_mode_width, &mirror_mode_height, NULL))
576 return area_ratio;
577
578 if (native_mode_height == 0 || mirror_mode_height == 0 ||
579 native_mode_width == 0 || mirror_mode_width == 0)
580 return area_ratio;
581
582 float width_ratio = static_cast<float>(mirror_mode_width) /
583 static_cast<float>(native_mode_width);
584 float height_ratio = static_cast<float>(mirror_mode_height) /
585 static_cast<float>(native_mode_height);
586
587 area_ratio = width_ratio * height_ratio;
588 return area_ratio;
589 }
590
565 } // namespace chromeos 591 } // namespace chromeos
OLDNEW
« chromeos/display/output_configurator.h ('K') | « chromeos/display/output_configurator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698