Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 521 pixel_rect = {0, 0, content_tex_css_width_, content_tex_css_height_}; | 521 pixel_rect = {0, 0, content_tex_css_width_, content_tex_css_height_}; |
| 522 } else { | 522 } else { |
| 523 pixel_rect = {plane->copy_rect.x, plane->copy_rect.y, | 523 pixel_rect = {plane->copy_rect.x, plane->copy_rect.y, |
| 524 plane->copy_rect.width, plane->copy_rect.height}; | 524 plane->copy_rect.width, plane->copy_rect.height}; |
| 525 } | 525 } |
| 526 pixel_x = pixel_rect.width * x + pixel_rect.x; | 526 pixel_x = pixel_rect.width * x + pixel_rect.x; |
| 527 pixel_y = pixel_rect.height * y + pixel_rect.y; | 527 pixel_y = pixel_rect.height * y + pixel_rect.y; |
| 528 | 528 |
| 529 target_point_ = plane_intersection_point; | 529 target_point_ = plane_intersection_point; |
| 530 target_element_ = plane.get(); | 530 target_element_ = plane.get(); |
| 531 input_target = (plane->fill == Fill::CONTENT) ? InputTarget::CONTENT | 531 // For now treat UI elements, which do not show web content, as NONE input |
| 532 : InputTarget::UI; | 532 // targets since they cannot make use of the input anyway. |
| 533 switch (plane->fill) { | |
| 534 case Fill::CONTENT: | |
| 535 input_target = InputTarget::CONTENT; | |
| 536 break; | |
| 537 case Fill::SPRITE: | |
| 538 input_target = InputTarget::UI; | |
| 539 break; | |
| 540 default: | |
| 541 input_target = InputTarget::NONE; | |
| 542 break; | |
| 543 } | |
| 533 } | 544 } |
| 534 } | 545 } |
| 535 SendEventsToTarget(input_target, pixel_x, pixel_y); | 546 SendEventsToTarget(input_target, pixel_x, pixel_y); |
| 536 } | 547 } |
| 537 | 548 |
| 538 void VrShellGl::SendEventsToTarget(InputTarget input_target, | 549 void VrShellGl::SendEventsToTarget(InputTarget input_target, |
| 539 int pixel_x, | 550 int pixel_x, |
| 540 int pixel_y) { | 551 int pixel_y) { |
| 541 std::vector<std::unique_ptr<WebGestureEvent>> gesture_list = | 552 std::vector<std::unique_ptr<WebGestureEvent>> gesture_list = |
| 542 controller_->DetectGestures(); | 553 controller_->DetectGestures(); |
| 543 double timestamp = gesture_list.front()->timeStampSeconds(); | 554 double timestamp = gesture_list.front()->timeStampSeconds(); |
| 544 | 555 |
| 545 if (touch_pending_) { | 556 if (touch_pending_) { |
| 546 touch_pending_ = false; | 557 touch_pending_ = false; |
| 547 std::unique_ptr<WebGestureEvent> event(new WebGestureEvent( | 558 std::unique_ptr<WebGestureEvent> event(new WebGestureEvent( |
| 548 WebInputEvent::GestureTapDown, WebInputEvent::NoModifiers, timestamp)); | 559 WebInputEvent::GestureTapDown, WebInputEvent::NoModifiers, timestamp)); |
| 549 event->sourceDevice = blink::WebGestureDeviceTouchpad; | 560 event->sourceDevice = blink::WebGestureDeviceTouchpad; |
| 550 event->x = pixel_x; | 561 event->x = pixel_x; |
| 551 event->y = pixel_y; | 562 event->y = pixel_y; |
| 552 gesture_list.push_back(std::move(event)); | 563 gesture_list.push_back(std::move(event)); |
| 553 } | 564 } |
| 554 | 565 |
| 566 // Make sure the user can switch to another input target while scrolling. To | |
| 567 // make this switch work we have to send an artificial scroll end event to the | |
| 568 // previous target and an artificial scroll begin event to the new target. | |
| 569 // Otherwise we will crash. | |
|
cjgrant
2017/02/13 15:54:51
No need for the last line here, it's implied.
tiborg
2017/02/13 22:15:26
I reset this due to changes in the scrolling behav
| |
| 570 if (is_scrolling_ && current_input_target_ != input_target) { | |
| 571 if (current_input_target_ != InputTarget::NONE) { | |
| 572 // End the scrolling on the previous target. | |
|
mthiesse
2017/02/13 15:47:08
Can you merge these two blocks with the "// Hover
cjgrant
2017/02/13 15:54:51
+1. Anything that makes switching input target fro
tiborg
2017/02/13 22:15:26
I reset this due to changes in the scrolling behav
| |
| 573 std::unique_ptr<WebGestureEvent> scrollEndEvent( | |
| 574 new WebGestureEvent(WebInputEvent::GestureScrollEnd, | |
| 575 WebInputEvent::NoModifiers, timestamp)); | |
| 576 scrollEndEvent->sourceDevice = blink::WebGestureDeviceTouchpad; | |
| 577 SendGesture(current_input_target_, std::move(scrollEndEvent)); | |
| 578 } | |
| 579 if (input_target != InputTarget::NONE) { | |
| 580 // Start scrolling on the new target. | |
| 581 std::unique_ptr<WebGestureEvent> scrollBeginEvent( | |
| 582 new WebGestureEvent(WebInputEvent::GestureScrollBegin, | |
| 583 WebInputEvent::NoModifiers, timestamp)); | |
| 584 scrollBeginEvent->sourceDevice = blink::WebGestureDeviceTouchpad; | |
| 585 scrollBeginEvent->x = pixel_x; | |
| 586 scrollBeginEvent->y = pixel_y; | |
| 587 SendGesture(input_target, std::move(scrollBeginEvent)); | |
| 588 } | |
| 589 } | |
| 590 | |
| 555 for (const auto& gesture : gesture_list) { | 591 for (const auto& gesture : gesture_list) { |
| 592 gesture->x = pixel_x; | |
| 593 gesture->y = pixel_y; | |
| 594 auto movableGesture = base::WrapUnique(new WebGestureEvent(*gesture)); | |
| 595 | |
| 556 switch (gesture->type()) { | 596 switch (gesture->type()) { |
| 557 case WebInputEvent::GestureScrollBegin: | 597 case WebInputEvent::GestureScrollBegin: |
| 598 is_scrolling_ = true; | |
| 599 if (input_target != InputTarget::NONE) { | |
| 600 SendGesture(input_target, std::move(movableGesture)); | |
| 601 } | |
| 602 break; | |
| 558 case WebInputEvent::GestureScrollUpdate: | 603 case WebInputEvent::GestureScrollUpdate: |
| 604 if (input_target != InputTarget::NONE) { | |
| 605 SendGesture(input_target, std::move(movableGesture)); | |
| 606 } | |
| 607 break; | |
| 559 case WebInputEvent::GestureScrollEnd: | 608 case WebInputEvent::GestureScrollEnd: |
| 609 if (input_target != InputTarget::NONE) { | |
| 610 SendGesture(input_target, std::move(movableGesture)); | |
| 611 } | |
| 612 is_scrolling_ = false; | |
| 613 break; | |
| 560 case WebInputEvent::GestureFlingCancel: | 614 case WebInputEvent::GestureFlingCancel: |
| 561 case WebInputEvent::GestureFlingStart: | 615 case WebInputEvent::GestureFlingStart: |
| 562 SendGesture(InputTarget::CONTENT, | 616 if (input_target != InputTarget::NONE) { |
| 563 base::WrapUnique(new WebGestureEvent(*gesture))); | 617 SendGesture(input_target, std::move(movableGesture)); |
| 618 } | |
| 564 break; | 619 break; |
| 565 case WebInputEvent::GestureTapDown: | 620 case WebInputEvent::GestureTapDown: |
| 566 gesture->x = pixel_x; | 621 if (input_target != InputTarget::NONE) { |
| 567 gesture->y = pixel_y; | 622 SendGesture(input_target, std::move(movableGesture)); |
| 568 if (input_target != InputTarget::NONE) | 623 } |
| 569 SendGesture(input_target, | |
| 570 base::WrapUnique(new WebGestureEvent(*gesture))); | |
| 571 break; | 624 break; |
| 572 case WebInputEvent::Undefined: | 625 case WebInputEvent::Undefined: |
| 573 break; | 626 break; |
| 574 default: | 627 default: |
| 575 NOTREACHED(); | 628 NOTREACHED(); |
| 576 } | 629 } |
| 577 } | 630 } |
| 578 | 631 |
| 579 // Hover support | 632 // Hover support |
| 580 bool new_target = input_target != current_input_target_; | 633 bool new_target = input_target != current_input_target_; |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1083 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, | 1136 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, |
| 1084 uint32_t device_id) { | 1137 uint32_t device_id) { |
| 1085 device::mojom::VRDisplayInfoPtr info = VrShell::CreateVRDisplayInfo( | 1138 device::mojom::VRDisplayInfoPtr info = VrShell::CreateVRDisplayInfo( |
| 1086 gvr_api_.get(), content_tex_physical_size_, device_id); | 1139 gvr_api_.get(), content_tex_physical_size_, device_id); |
| 1087 main_thread_task_runner_->PostTask( | 1140 main_thread_task_runner_->PostTask( |
| 1088 FROM_HERE, | 1141 FROM_HERE, |
| 1089 base::Bind(&RunVRDisplayInfoCallback, callback, base::Passed(&info))); | 1142 base::Bind(&RunVRDisplayInfoCallback, callback, base::Passed(&info))); |
| 1090 } | 1143 } |
| 1091 | 1144 |
| 1092 } // namespace vr_shell | 1145 } // namespace vr_shell |
| OLD | NEW |