Chromium Code Reviews| Index: content/public/browser/android/vr_gesture.h |
| diff --git a/content/public/browser/android/vr_gesture.h b/content/public/browser/android/vr_gesture.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bee0bb4644e4f90cad1975027cbc01a4c640e554 |
| --- /dev/null |
| +++ b/content/public/browser/android/vr_gesture.h |
| @@ -0,0 +1,164 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_ |
|
bshe
2016/09/21 15:18:41
nit: s/CHROME/CONTENT
asimjour
2016/09/22 14:48:37
Done.
|
| +#define CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_ |
| + |
| +typedef enum { |
| + GESTURE_DIRECTION_UP, |
| + GESTURE_DIRECTION_DOWN, |
| + GESTURE_DIRECTION_LEFT, |
| + GESTURE_DIRECTION_RIGHT |
| +} gesture_direction; |
| + |
| +typedef struct quatf { |
|
mthiesse
2016/09/21 17:43:27
I don't think you need this here at all. I don't t
asimjour
2016/09/22 14:48:37
considering that I'm moving this file to chrome/br
|
| + /// qx, qy, qz are the vector component. |
| + float qx; |
| + float qy; |
| + float qz; |
| + /// qw is the linelar component. |
|
mthiesse
2016/09/21 17:43:28
nit: linear?
asimjour
2016/09/22 14:48:37
Done.
|
| + float qw; |
| +} quatf; |
| + |
| +/// A floating point 2D vector. |
| +typedef struct vec2f { |
|
mthiesse
2016/09/21 17:43:27
use gfx::Vector2d
asimjour
2016/09/22 14:48:37
Replaced with gvr_vec2f
|
| + float x; |
| + float y; |
| +} vec2f; |
| + |
| +typedef struct { |
| + float dx, dy, dz; |
| + float x, y; |
| + float ordinal_dx, ordinal_dy, ordinal_dz; |
| + int type; |
| +} GestureAngularMove; |
| + |
| +typedef struct { |
| + float dx, dy; |
| + float ordinal_dx, ordinal_dy; |
| + // If set, stop_fling means that this scroll should stop flinging, thus |
| + // if an interpreter suppresses it for any reason (e.g., rounds the size |
| + // down to 0, thus making it a noop), it will replace it with a Fling |
| + // TAP_DOWN gesture |
| + int state; |
| + unsigned stop_fling : 1; |
| + float initial_touch_pos_x; |
| + float initial_touch_pos_y; |
| +} GestureScroll; |
| + |
| +typedef struct { |
| + // fling velocity (valid when fling_state is GESTURES_FLING_START): |
| + float vx, vy; |
| + float ordinal_vx, ordinal_vy; |
| + unsigned fling_state : 1; // GESTURES_FLING_START or GESTURES_FLING_TAP_DOWN |
| +} GestureFling; |
| + |
| +typedef struct { |
| + // zoom size; dz=1 means no zoom, dz < 1 means zoom-out, dz > 1 means zoom-in |
| + float dz; |
| +} GestureZoom; |
| + |
| +typedef struct { |
| + // If a bit is set in both down and up, client should process down first |
| + int x; |
| + int y; |
| + unsigned down; // bit field, use GESTURES_BUTTON_* |
| + unsigned up; // bit field, use GESTURES_BUTTON_* |
| +} GestureButtonsChange; |
| + |
| +enum GestureType { |
| + kGestureTypeNull, |
| + kGestureTypeAngularMove, |
| + kGestureTypeScroll, |
| + kGestureTypeButtonsChange, |
| + kGestureTypeFling, |
| + kGestureTypeZoom, |
| +}; |
| + |
| +enum GestureEventType { |
| + GESTURE_EVENT_TYPE_SCROLL_START, |
| + GESTURE_EVENT_TYPE_SCROLL_BY, |
| + GESTURE_EVENT_TYPE_SCROLL_END, |
| + GESTURE_EVENT_TYPE_PINCH_BEGIN, |
| + GESTURE_EVENT_TYPE_PINCH_BY, |
| + GESTURE_EVENT_TYPE_PINCH_END, |
| +}; |
| + |
| +struct VrGesture { |
|
mthiesse
2016/09/21 17:43:28
I don't think this should live in the content laye
asimjour
2016/09/22 14:48:37
You are right, it used to be included in vr_conten
|
| + VrGesture() : type(kGestureTypeNull) {} |
| + VrGesture(const GestureAngularMove&, int64_t start, int64_t end, quatf quat) |
| + : start_time(start), |
| + end_time(end), |
| + type(kGestureTypeAngularMove), |
| + quat(quat) {} |
| + VrGesture(const GestureScroll&, |
| + int64_t start, |
| + int64_t end, |
| + float dx, |
| + float dy, |
| + int state, |
| + quatf quat) |
| + : start_time(start), end_time(end), type(kGestureTypeScroll), quat(quat) { |
| + details.scroll.ordinal_dx = details.scroll.dx = dx; |
| + details.scroll.ordinal_dy = details.scroll.dy = dy; |
| + details.scroll.state = state; |
| + details.scroll.stop_fling = 0; |
| + } |
| + VrGesture(const GestureButtonsChange&, |
| + int64_t start, |
| + int64_t end, |
| + unsigned down, |
| + unsigned up, |
| + quatf quat) |
| + : start_time(start), |
| + end_time(end), |
| + type(kGestureTypeButtonsChange), |
| + quat(quat) { |
| + details.buttons.down = down; |
| + details.buttons.up = up; |
| + details.buttons.x = 0; |
| + details.buttons.y = 0; |
| + } |
| + VrGesture(const GestureFling&, |
| + int64_t start, |
| + int64_t end, |
| + float vx, |
| + float vy, |
| + unsigned state, |
| + quatf quat) |
| + : start_time(start), end_time(end), type(kGestureTypeFling), quat(quat) { |
| + details.fling.ordinal_vx = details.fling.vx = vx; |
| + details.fling.ordinal_vy = details.fling.vy = vy; |
| + details.fling.fling_state = state; |
| + } |
| + VrGesture(const GestureZoom&, |
| + int64_t start, |
| + int64_t end, |
| + float dz, |
| + quatf quat) |
| + : start_time(start), end_time(end), type(kGestureTypeZoom), quat(quat) { |
| + details.zoom.dz = dz; |
| + } |
| + |
| + int64_t start_time, end_time; |
| + enum GestureType type; |
| + union { |
| + GestureScroll scroll; |
| + GestureButtonsChange buttons; |
| + GestureFling fling; |
| + GestureZoom zoom; |
| + GestureAngularMove move; |
| + } details; |
| + quatf quat; |
| + vec2f velocity; |
| + vec2f displacement; |
| + gesture_direction direction; |
| +}; |
| + |
| +const GestureScroll kGestureScroll = {0, 0, 0, 0, 0, 0}; |
| +const GestureButtonsChange kGestureButtonsChange = {0, 0, 0, 0}; |
| +const GestureAngularMove kGestureAngularMove = {0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| +const GestureZoom kGestureZoom = {0}; |
| + |
| +#endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_GESTURE_H_ |