summaryrefslogtreecommitdiffstats
path: root/ash/display
diff options
context:
space:
mode:
authormiletus@chromium.org <miletus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-24 03:00:21 +0000
committermiletus@chromium.org <miletus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-24 03:00:21 +0000
commit7355993465b3cc0f0395ce5144c1a824af1346a0 (patch)
treecdde21b0687136cfccc690b10037db1b9fb2b99d /ash/display
parent102b81cdfa43709db2b05af452415ccea48fb92f (diff)
downloadchromium_src-7355993465b3cc0f0395ce5144c1a824af1346a0.zip
chromium_src-7355993465b3cc0f0395ce5144c1a824af1346a0.tar.gz
chromium_src-7355993465b3cc0f0395ce5144c1a824af1346a0.tar.bz2
Scale touch event radius
Touch event's position resolution could be quite different than the display's resolution, e.g. the display could be set as 1920x1080 while the touchscreen is reporting touch position range at 32767x32767. Touch event's radius is reported in the units the same as touch position. While we are doing touch position scaling, we should also do the same for touch radius. BUG=392172, 233245 TEST=touch radius is scaled to be reasonable value for HP 23TM touch monitor. Review URL: https://codereview.chromium.org/412553005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285132 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/display')
-rw-r--r--ash/display/event_transformation_handler.cc93
-rw-r--r--ash/display/event_transformation_handler.h3
2 files changed, 0 insertions, 96 deletions
diff --git a/ash/display/event_transformation_handler.cc b/ash/display/event_transformation_handler.cc
index cd9961a..62a6fa1 100644
--- a/ash/display/event_transformation_handler.cc
+++ b/ash/display/event_transformation_handler.cc
@@ -18,71 +18,12 @@
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
-#if defined(OS_CHROMEOS)
-#include "ui/display/chromeos/display_configurator.h"
-#endif // defined(OS_CHROMEOS)
-
namespace ash {
namespace {
// Boost factor for non-integrated displays.
const float kBoostForNonIntegrated = 1.20f;
-#if defined(OS_CHROMEOS)
-gfx::Size GetNativeModeSize(const DisplayInfo& info) {
- const std::vector<DisplayMode>& modes = info.display_modes();
- for (size_t i = 0; i < modes.size(); ++i) {
- if (modes[i].native)
- return modes[i].size;
- }
-
- return gfx::Size();
-}
-
-float GetMirroredDisplayAreaRatio(const gfx::Size& current_size,
- const gfx::Size& native_size) {
- float area_ratio = 1.0f;
-
- if (current_size.IsEmpty() || native_size.IsEmpty())
- return area_ratio;
-
- float width_ratio = static_cast<float>(current_size.width()) /
- static_cast<float>(native_size.width());
- float height_ratio = static_cast<float>(current_size.height()) /
- static_cast<float>(native_size.height());
-
- area_ratio = width_ratio * height_ratio;
- return area_ratio;
-}
-
-// 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> GetMirroredDisplayAreaRatioMap() {
- std::map<int, float> area_ratios;
- DisplayManager* display_manager =
- ash::Shell::GetInstance()->display_manager();
- const std::vector<gfx::Display>& displays = display_manager->displays();
- for (size_t i = 0; i < displays.size(); ++i) {
- const DisplayInfo& info = display_manager->GetDisplayInfo(
- displays[i].id());
- const gfx::Size current_size = info.size_in_pixel();
- const gfx::Size native_size = GetNativeModeSize(info);
-
- if (info.touch_support() == gfx::Display::TOUCH_SUPPORT_AVAILABLE &&
- current_size != native_size &&
- info.is_aspect_preserving_scaling()) {
- area_ratios[info.touch_device_id()] = GetMirroredDisplayAreaRatio(
- current_size, native_size);
- }
- }
-
- return area_ratios;
-}
-#endif // defined(OS_CHROMEOS)
-
} // namespace
EventTransformationHandler::EventTransformationHandler()
@@ -109,38 +50,4 @@ void EventTransformationHandler::OnScrollEvent(ui::ScrollEvent* event) {
event->Scale(kBoostForNonIntegrated);
}
-#if defined(OS_CHROMEOS)
-// This is to scale the TouchEvent's radius when the touch display is in
-// mirror mode. TouchEvent's radius is often reported in the touchscreen's
-// native resolution. In mirror mode, the touch display could be configured
-// at a lower resolution. We scale down the radius using the ratio defined as
-// the sqrt of
-// (mirror_width * mirror_height) / (native_width * native_height)
-void EventTransformationHandler::OnTouchEvent(ui::TouchEvent* event) {
- // Check display_configurator's output_state instead of checking
- // DisplayManager::IsMirrored() because the compositor based mirroring
- // won't cause the scaling issue.
- if (ash::Shell::GetInstance()->display_configurator()->display_state() !=
- ui::MULTIPLE_DISPLAY_STATE_DUAL_MIRROR)
- return;
-
- const std::map<int, float> area_ratio_map = GetMirroredDisplayAreaRatioMap();
-
- // TODO(miletus): When there are more than 1 touchscreen (e.g. Link connected
- // to an external touchscreen), the correct way to do is to have a way
- // to find out which touchscreen is the event originating from and use the
- // area ratio of that touchscreen to scale the event's radius.
- // Tracked here crbug.com/233245
- if (area_ratio_map.size() != 1) {
- LOG(ERROR) << "Mirroring mode with " << area_ratio_map.size()
- << " touch display found";
- return;
- }
-
- float area_ratio_sqrt = std::sqrt(area_ratio_map.begin()->second);
- event->set_radius_x(event->radius_x() * area_ratio_sqrt);
- event->set_radius_y(event->radius_y() * area_ratio_sqrt);
-}
-#endif // defined(OS_CHROMEOS)
-
} // namespace ash
diff --git a/ash/display/event_transformation_handler.h b/ash/display/event_transformation_handler.h
index 0d3c7e0..cd38b95 100644
--- a/ash/display/event_transformation_handler.h
+++ b/ash/display/event_transformation_handler.h
@@ -31,9 +31,6 @@ class ASH_EXPORT EventTransformationHandler : public ui::EventHandler {
// Overridden from ui::EventHandler.
virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
-#if defined(OS_CHROMEOS)
- virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
-#endif // defined(OS_CHROMEOS)
private:
TransformationMode transformation_mode_;