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

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell_gl.cc

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Fix nits Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/android/vr_shell/vr_shell_gl.h" 5 #include "chrome/browser/android/vr_shell/vr_shell_gl.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 quat.qz = 0.0f; 114 quat.qz = 0.0f;
115 vr_shell::NormalizeQuat(quat); 115 vr_shell::NormalizeQuat(quat);
116 } 116 }
117 return quat; 117 return quat;
118 } 118 }
119 119
120 std::unique_ptr<blink::WebMouseEvent> MakeMouseEvent(WebInputEvent::Type type, 120 std::unique_ptr<blink::WebMouseEvent> MakeMouseEvent(WebInputEvent::Type type,
121 double timestamp, 121 double timestamp,
122 float x, 122 float x,
123 float y) { 123 float y) {
124 std::unique_ptr<blink::WebMouseEvent> mouse_event(new blink::WebMouseEvent); 124 std::unique_ptr<blink::WebMouseEvent> mouse_event(new blink::WebMouseEvent(
125 mouse_event->type = type; 125 type, blink::WebInputEvent::NoModifiers, timestamp));
126 mouse_event->pointerType = blink::WebPointerProperties::PointerType::Mouse; 126 mouse_event->pointerType = blink::WebPointerProperties::PointerType::Mouse;
127 mouse_event->x = x; 127 mouse_event->x = x;
128 mouse_event->y = y; 128 mouse_event->y = y;
129 mouse_event->windowX = x; 129 mouse_event->windowX = x;
130 mouse_event->windowY = y; 130 mouse_event->windowY = y;
131 mouse_event->timeStampSeconds = timestamp;
132 mouse_event->clickCount = 1; 131 mouse_event->clickCount = 1;
133 mouse_event->modifiers = 0;
134 132
135 return mouse_event; 133 return mouse_event;
136 } 134 }
137 135
138 enum class ViewerType { 136 enum class ViewerType {
139 UNKNOWN_TYPE = 0, 137 UNKNOWN_TYPE = 0,
140 CARDBOARD = 1, 138 CARDBOARD = 1,
141 DAYDREAM = 2, 139 DAYDREAM = 2,
142 VIEWER_TYPE_MAX, 140 VIEWER_TYPE_MAX,
143 }; 141 };
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 main_thread_task_runner_->PostTask( 408 main_thread_task_runner_->PostTask(
411 FROM_HERE, base::Bind(&VrShell::AppButtonPressed, weak_vr_shell_)); 409 FROM_HERE, base::Bind(&VrShell::AppButtonPressed, weak_vr_shell_));
412 } 410 }
413 411
414 if (web_vr_mode_) { 412 if (web_vr_mode_) {
415 // Process screen touch events for Cardboard button compatibility. 413 // Process screen touch events for Cardboard button compatibility.
416 // Also send tap events for controller "touchpad click" events. 414 // Also send tap events for controller "touchpad click" events.
417 if (touch_pending_ || controller_->ButtonUpHappened( 415 if (touch_pending_ || controller_->ButtonUpHappened(
418 gvr::ControllerButton::GVR_CONTROLLER_BUTTON_CLICK)) { 416 gvr::ControllerButton::GVR_CONTROLLER_BUTTON_CLICK)) {
419 touch_pending_ = false; 417 touch_pending_ = false;
420 std::unique_ptr<WebGestureEvent> gesture(new WebGestureEvent()); 418 std::unique_ptr<WebGestureEvent> gesture(new WebGestureEvent(
419 WebInputEvent::GestureTapDown, WebInputEvent::NoModifiers,
420 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF()));
421 gesture->sourceDevice = blink::WebGestureDeviceTouchpad; 421 gesture->sourceDevice = blink::WebGestureDeviceTouchpad;
422 gesture->timeStampSeconds =
423 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
424 gesture->type = WebInputEvent::GestureTapDown;
425 gesture->x = 0; 422 gesture->x = 0;
426 gesture->y = 0; 423 gesture->y = 0;
427 SendGesture(InputTarget::CONTENT, std::move(gesture)); 424 SendGesture(InputTarget::CONTENT, std::move(gesture));
428 } 425 }
429 426
430 return; 427 return;
431 } 428 }
432 429
433 gvr::Vec3f ergo_neutral_pose; 430 gvr::Vec3f ergo_neutral_pose;
434 if (!controller_->IsConnected()) { 431 if (!controller_->IsConnected()) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 } 518 }
522 } 519 }
523 SendEventsToTarget(input_target, pixel_x, pixel_y); 520 SendEventsToTarget(input_target, pixel_x, pixel_y);
524 } 521 }
525 522
526 void VrShellGl::SendEventsToTarget(InputTarget input_target, 523 void VrShellGl::SendEventsToTarget(InputTarget input_target,
527 int pixel_x, 524 int pixel_x,
528 int pixel_y) { 525 int pixel_y) {
529 std::vector<std::unique_ptr<WebGestureEvent>> gesture_list = 526 std::vector<std::unique_ptr<WebGestureEvent>> gesture_list =
530 controller_->DetectGestures(); 527 controller_->DetectGestures();
531 double timestamp = gesture_list.front()->timeStampSeconds; 528 double timestamp = gesture_list.front()->timeStampSeconds();
532 529
533 if (touch_pending_) { 530 if (touch_pending_) {
534 touch_pending_ = false; 531 touch_pending_ = false;
535 std::unique_ptr<WebGestureEvent> event(new WebGestureEvent()); 532 std::unique_ptr<WebGestureEvent> event(new WebGestureEvent(
536 event->type = WebInputEvent::GestureTapDown; 533 WebInputEvent::GestureTapDown, WebInputEvent::NoModifiers, timestamp));
537 event->sourceDevice = blink::WebGestureDeviceTouchpad; 534 event->sourceDevice = blink::WebGestureDeviceTouchpad;
538 event->timeStampSeconds = timestamp;
539 event->x = pixel_x; 535 event->x = pixel_x;
540 event->y = pixel_y; 536 event->y = pixel_y;
541 gesture_list.push_back(std::move(event)); 537 gesture_list.push_back(std::move(event));
542 } 538 }
543 539
544 for (const auto& gesture : gesture_list) { 540 for (const auto& gesture : gesture_list) {
545 switch (gesture->type) { 541 switch (gesture->type()) {
546 case WebInputEvent::GestureScrollBegin: 542 case WebInputEvent::GestureScrollBegin:
547 case WebInputEvent::GestureScrollUpdate: 543 case WebInputEvent::GestureScrollUpdate:
548 case WebInputEvent::GestureScrollEnd: 544 case WebInputEvent::GestureScrollEnd:
549 case WebInputEvent::GestureFlingCancel: 545 case WebInputEvent::GestureFlingCancel:
550 case WebInputEvent::GestureFlingStart: 546 case WebInputEvent::GestureFlingStart:
551 SendGesture(InputTarget::CONTENT, 547 SendGesture(InputTarget::CONTENT,
552 base::WrapUnique(new WebGestureEvent(*gesture))); 548 base::WrapUnique(new WebGestureEvent(*gesture)));
553 break; 549 break;
554 case WebInputEvent::GestureTapDown: 550 case WebInputEvent::GestureTapDown:
555 gesture->x = pixel_x; 551 gesture->x = pixel_x;
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 void VrShellGl::ForceExitVr() { 992 void VrShellGl::ForceExitVr() {
997 main_thread_task_runner_->PostTask( 993 main_thread_task_runner_->PostTask(
998 FROM_HERE, base::Bind(&VrShell::ForceExitVr, weak_vr_shell_)); 994 FROM_HERE, base::Bind(&VrShell::ForceExitVr, weak_vr_shell_));
999 } 995 }
1000 996
1001 void VrShellGl::UpdateScene(std::unique_ptr<base::ListValue> commands) { 997 void VrShellGl::UpdateScene(std::unique_ptr<base::ListValue> commands) {
1002 scene_->HandleCommands(std::move(commands), TimeInMicroseconds()); 998 scene_->HandleCommands(std::move(commands), TimeInMicroseconds());
1003 } 999 }
1004 1000
1005 } // namespace vr_shell 1001 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_input_manager.cc ('k') | chrome/browser/chromeos/first_run/first_run_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698