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

Side by Side Diff: ui/ozone/platform/egltest/ozone_platform_egltest.cc

Issue 1357423009: gfx: Make conversions from Size to SizeF be explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sizefconvert-gfx: . Created 5 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 unified diff | Download patch
« no previous file with comments | « ui/ozone/demo/renderer_base.cc ('k') | ui/views/animation/ink_drop_animation.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/ozone/platform/egltest/ozone_platform_egltest.h" 5 #include "ui/ozone/platform/egltest/ozone_platform_egltest.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return library; 52 return library;
53 return kEglplatformShimDefault; 53 return kEglplatformShimDefault;
54 } 54 }
55 55
56 // Touch events are reported in device coordinates. This scales the event to the 56 // Touch events are reported in device coordinates. This scales the event to the
57 // window's coordinate space. 57 // window's coordinate space.
58 void ScaleTouchEvent(TouchEvent* event, const gfx::SizeF& size) { 58 void ScaleTouchEvent(TouchEvent* event, const gfx::SizeF& size) {
59 for (const auto& device : 59 for (const auto& device :
60 DeviceDataManager::GetInstance()->touchscreen_devices()) { 60 DeviceDataManager::GetInstance()->touchscreen_devices()) {
61 if (device.id == event->source_device_id()) { 61 if (device.id == event->source_device_id()) {
62 gfx::SizeF touchscreen_size = device.size; 62 gfx::SizeF touchscreen_size = gfx::SizeF(device.size);
63 gfx::PointF location = event->location_f(); 63 gfx::PointF location = event->location_f();
64 64
65 location.Scale(size.width() / touchscreen_size.width(), 65 location.Scale(size.width() / touchscreen_size.width(),
66 size.height() / touchscreen_size.height()); 66 size.height() / touchscreen_size.height());
67 double ratio = std::sqrt(size.GetArea() / touchscreen_size.GetArea()); 67 double ratio = std::sqrt(size.GetArea() / touchscreen_size.GetArea());
68 68
69 event->set_location(location); 69 event->set_location(location);
70 event->set_radius_x(event->pointer_details().radius_x() * ratio); 70 event->set_radius_x(event->pointer_details().radius_x() * ratio);
71 event->set_radius_y(event->pointer_details().radius_y() * ratio); 71 event->set_radius_y(event->pointer_details().radius_y() * ratio);
72 return; 72 return;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 return nullptr; 187 return nullptr;
188 } 188 }
189 189
190 bool EgltestWindow::CanDispatchEvent(const ui::PlatformEvent& ne) { 190 bool EgltestWindow::CanDispatchEvent(const ui::PlatformEvent& ne) {
191 return true; 191 return true;
192 } 192 }
193 193
194 uint32_t EgltestWindow::DispatchEvent(const ui::PlatformEvent& native_event) { 194 uint32_t EgltestWindow::DispatchEvent(const ui::PlatformEvent& native_event) {
195 DCHECK(native_event); 195 DCHECK(native_event);
196 Event* event = static_cast<Event*>(native_event); 196 Event* event = static_cast<Event*>(native_event);
197 if (event->IsTouchEvent()) 197 if (event->IsTouchEvent()) {
198 ScaleTouchEvent(static_cast<TouchEvent*>(event), bounds_.size()); 198 ScaleTouchEvent(static_cast<TouchEvent*>(event),
199 gfx::SizeF(bounds_.size()));
200 }
199 201
200 DispatchEventFromNativeUiEvent( 202 DispatchEventFromNativeUiEvent(
201 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, 203 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent,
202 base::Unretained(delegate_))); 204 base::Unretained(delegate_)));
203 205
204 return ui::POST_DISPATCH_STOP_PROPAGATION; 206 return ui::POST_DISPATCH_STOP_PROPAGATION;
205 } 207 }
206 208
207 // EGL surface wrapper for libeglplatform_shim. 209 // EGL surface wrapper for libeglplatform_shim.
208 // 210 //
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 417
416 } // namespace 418 } // namespace
417 419
418 OzonePlatform* CreateOzonePlatformEgltest() { 420 OzonePlatform* CreateOzonePlatformEgltest() {
419 OzonePlatformEgltest* platform = new OzonePlatformEgltest; 421 OzonePlatformEgltest* platform = new OzonePlatformEgltest;
420 platform->Initialize(); 422 platform->Initialize();
421 return platform; 423 return platform;
422 } 424 }
423 425
424 } // namespace ui 426 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/demo/renderer_base.cc ('k') | ui/views/animation/ink_drop_animation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698