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 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/android/jni_weak_ref.h" | 11 #include "base/android/jni_weak_ref.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "device/vr/android/gvr/gvr_delegate.h" |
13 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g
vr.h" | 14 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g
vr.h" |
14 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g
vr_types.h" | 15 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g
vr_types.h" |
15 | 16 |
16 namespace vr_shell { | 17 namespace vr_shell { |
17 | 18 |
18 class VrShellRenderer; | 19 class VrShellRenderer; |
19 | 20 |
20 class ContentRect { | 21 class ContentRect { |
21 public: | 22 public: |
22 ContentRect(); | 23 ContentRect(); |
23 ~ContentRect(); | 24 ~ContentRect(); |
24 void SetIdentity(); | 25 void SetIdentity(); |
25 void Translate(float x, float y, float z); | 26 void Translate(float x, float y, float z); |
26 gvr::Mat4f transfrom_to_world; | 27 gvr::Mat4f transfrom_to_world; |
27 int content_texture_handle; | 28 int content_texture_handle; |
28 }; | 29 }; |
29 | 30 |
30 class VrShell { | 31 class VrShell : public device::GvrDelegate { |
31 public: | 32 public: |
32 VrShell(JNIEnv* env, jobject obj); | 33 VrShell(JNIEnv* env, jobject obj); |
33 | 34 |
34 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 35 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
35 | 36 |
36 void GvrInit(JNIEnv* env, | 37 void GvrInit(JNIEnv* env, |
37 const base::android::JavaParamRef<jobject>& obj, | 38 const base::android::JavaParamRef<jobject>& obj, |
38 jlong native_gvr_api); | 39 jlong native_gvr_api); |
39 void InitializeGl(JNIEnv* env, | 40 void InitializeGl(JNIEnv* env, |
40 const base::android::JavaParamRef<jobject>& obj, | 41 const base::android::JavaParamRef<jobject>& obj, |
41 jint texture_data_handle); | 42 jint texture_data_handle); |
42 void DrawFrame(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 43 void DrawFrame(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
43 void OnPause(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 44 void OnPause(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
44 void OnResume(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 45 void OnResume(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
45 | 46 |
| 47 // GvrDelegate |
| 48 void RequestWebVRPresent() override; |
| 49 void ExitWebVRPresent() override; |
| 50 void SubmitWebVRFrame() override; |
| 51 void UpdateWebVRTextureBounds( |
| 52 int eye, float left, float top, float width, float height) override; |
| 53 gvr::GvrApi* gvr_api() override; |
| 54 |
46 private: | 55 private: |
47 ~VrShell(); | 56 virtual ~VrShell(); |
48 | 57 |
| 58 void DrawVrShell(); |
49 void DrawEye(const gvr::Mat4f& view_matrix, | 59 void DrawEye(const gvr::Mat4f& view_matrix, |
50 const gvr::BufferViewport& params); | 60 const gvr::BufferViewport& params); |
51 void DrawContentRect(); | 61 void DrawContentRect(); |
| 62 void DrawWebVr(); |
52 | 63 |
53 std::unique_ptr<ContentRect> content_rect_; | 64 std::unique_ptr<ContentRect> content_rect_; |
54 std::unique_ptr<gvr::GvrApi> gvr_api_; | 65 std::unique_ptr<gvr::GvrApi> gvr_api_; |
55 std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_; | 66 std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_; |
56 std::unique_ptr<gvr::BufferViewport> buffer_viewport_; | 67 std::unique_ptr<gvr::BufferViewport> buffer_viewport_; |
57 std::unique_ptr<gvr::SwapChain> swap_chain_; | 68 std::unique_ptr<gvr::SwapChain> swap_chain_; |
58 | 69 |
59 gvr::Mat4f view_matrix_; | 70 gvr::Mat4f view_matrix_; |
60 gvr::Mat4f projection_matrix_; | 71 gvr::Mat4f projection_matrix_; |
61 | 72 |
62 gvr::Mat4f head_pose_; | 73 gvr::Mat4f head_pose_; |
63 | 74 |
64 gvr::Sizei render_size_; | 75 gvr::Sizei render_size_; |
65 | 76 |
66 std::unique_ptr<VrShellRenderer> vr_shell_renderer_; | 77 std::unique_ptr<VrShellRenderer> vr_shell_renderer_; |
67 | 78 |
68 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; | 79 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; |
69 | 80 |
| 81 bool webvr_mode_; |
| 82 |
70 DISALLOW_COPY_AND_ASSIGN(VrShell); | 83 DISALLOW_COPY_AND_ASSIGN(VrShell); |
71 }; | 84 }; |
72 | 85 |
73 bool RegisterVrShell(JNIEnv* env); | 86 bool RegisterVrShell(JNIEnv* env); |
74 | 87 |
75 } // namespace vr_shell | 88 } // namespace vr_shell |
76 | 89 |
77 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 90 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
OLD | NEW |