summaryrefslogtreecommitdiffstats
path: root/chromeos/display
diff options
context:
space:
mode:
authormiletus@chromium.org <miletus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-19 03:39:34 +0000
committermiletus@chromium.org <miletus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-19 03:39:34 +0000
commita1c0601dc65636bb6dca44dceef36b8823791fa0 (patch)
tree1e9b0febb49f34390a294762307253afd98cfe30 /chromeos/display
parent69cdc4e9c6f58514a6088dbf307be9f66341a5bf (diff)
downloadchromium_src-a1c0601dc65636bb6dca44dceef36b8823791fa0.zip
chromium_src-a1c0601dc65636bb6dca44dceef36b8823791fa0.tar.gz
chromium_src-a1c0601dc65636bb6dca44dceef36b8823791fa0.tar.bz2
Scale TouchEvent's radius when touchscreen is in mirror mode
TouchEvent's radius on Pixel is reported in the touchscreen's native resolution. When Pixel is connected to an external screen and running in mirror mode, the radius value is too large for the external screen's low display resolution. The radius value needs to be scaled properly in this case. BUG=229932 TEST=Switching to mirror mode when connecting Pixel to a low resolution external display, following the test in the issue and make sure the radius has a sensible value. Review URL: https://chromiumcodereview.appspot.com/14279002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195075 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/display')
-rw-r--r--chromeos/display/output_configurator.cc26
-rw-r--r--chromeos/display/output_configurator.h18
2 files changed, 44 insertions, 0 deletions
diff --git a/chromeos/display/output_configurator.cc b/chromeos/display/output_configurator.cc
index 94b603f..903f49b 100644
--- a/chromeos/display/output_configurator.cc
+++ b/chromeos/display/output_configurator.cc
@@ -428,6 +428,8 @@ bool OutputConfigurator::EnterState(
if (outputs[i].mirror_mode != outputs[i].native_mode &&
outputs[i].is_aspect_preserving_scaling) {
ctm = GetMirrorModeCTM(&outputs[i]);
+ mirrored_display_area_ratio_map_[outputs[i].touch_device_id] =
+ GetMirroredDisplayAreaRatio(&outputs[i]);
}
delegate_->ConfigureCTM(outputs[i].touch_device_id, ctm);
}
@@ -562,4 +564,28 @@ OutputConfigurator::GetMirrorModeCTM(
return ctm; // Same aspect ratio - return identity
}
+float OutputConfigurator::GetMirroredDisplayAreaRatio(
+ const OutputConfigurator::OutputSnapshot* output) {
+ float area_ratio = 1.0f;
+ int native_mode_width = 0, native_mode_height = 0;
+ int mirror_mode_width = 0, mirror_mode_height = 0;
+ if (!delegate_->GetModeDetails(output->native_mode,
+ &native_mode_width, &native_mode_height, NULL) ||
+ !delegate_->GetModeDetails(output->mirror_mode,
+ &mirror_mode_width, &mirror_mode_height, NULL))
+ return area_ratio;
+
+ if (native_mode_height == 0 || mirror_mode_height == 0 ||
+ native_mode_width == 0 || mirror_mode_width == 0)
+ return area_ratio;
+
+ float width_ratio = static_cast<float>(mirror_mode_width) /
+ static_cast<float>(native_mode_width);
+ float height_ratio = static_cast<float>(mirror_mode_height) /
+ static_cast<float>(native_mode_height);
+
+ area_ratio = width_ratio * height_ratio;
+ return area_ratio;
+}
+
} // namespace chromeos
diff --git a/chromeos/display/output_configurator.h b/chromeos/display/output_configurator.h
index 34e9384..faef729 100644
--- a/chromeos/display/output_configurator.h
+++ b/chromeos/display/output_configurator.h
@@ -5,6 +5,7 @@
#ifndef CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_
#define CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_
+#include <map>
#include <vector>
#include "base/basictypes.h"
@@ -283,6 +284,10 @@ class CHROMEOS_EXPORT OutputConfigurator : public MessageLoop::Dispatcher {
// suspended.
void ResumeDisplays();
+ const std::map<int, float>& GetMirroredDisplayAreaRatioMap() {
+ return mirrored_display_area_ratio_map_;
+ }
+
private:
// Configure outputs.
void ConfigureOutputs();
@@ -307,9 +312,22 @@ class CHROMEOS_EXPORT OutputConfigurator : public MessageLoop::Dispatcher {
CoordinateTransformation GetMirrorModeCTM(
const OutputConfigurator::OutputSnapshot* output);
+ // Returns the ratio between mirrored mode area and native mode area:
+ // (mirror_mode_width * mirrow_mode_height) / (native_width * native_height)
+ float GetMirroredDisplayAreaRatio(
+ const OutputConfigurator::OutputSnapshot* output);
+
StateController* state_controller_;
scoped_ptr<Delegate> delegate_;
+ // Key of the map is the touch display's id, and the value of the map is the
+ // touch display's area ratio in mirror mode defined as :
+ // mirror_mode_area / native_mode_area.
+ // This is used for scaling touch event's radius when the touch display is in
+ // mirror mode :
+ // new_touch_radius = sqrt(area_ratio) * old_touch_radius
+ std::map<int, float> mirrored_display_area_ratio_map_;
+
// This is detected by the constructor to determine whether or not we should
// be enabled. If we aren't running on ChromeOS, we can't assume that the
// Xrandr X11 extension is supported.