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 #include <vector> | 10 #include <vector> |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 namespace vr_shell { | 29 namespace vr_shell { |
30 | 30 |
31 class VrCompositor; | 31 class VrCompositor; |
32 class VrShellDelegate; | 32 class VrShellDelegate; |
33 class VrShellRenderer; | 33 class VrShellRenderer; |
34 | 34 |
35 class VrShell : public device::GvrDelegate { | 35 class VrShell : public device::GvrDelegate { |
36 public: | 36 public: |
37 VrShell(JNIEnv* env, jobject obj, | 37 VrShell(JNIEnv* env, jobject obj, |
38 content::ContentViewCore* content_view_core, | 38 content::ContentViewCore* content_cvc, |
39 ui::WindowAndroid* content_window); | 39 ui::WindowAndroid* content_window, |
| 40 content::ContentViewCore* ui_cvc, |
| 41 ui::WindowAndroid* ui_window); |
40 | 42 |
41 void UpdateCompositorLayers(JNIEnv* env, | 43 void UpdateCompositorLayers(JNIEnv* env, |
42 const base::android::JavaParamRef<jobject>& obj); | 44 const base::android::JavaParamRef<jobject>& obj); |
43 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 45 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
44 void SetDelegate(JNIEnv* env, | 46 void SetDelegate(JNIEnv* env, |
45 const base::android::JavaParamRef<jobject>& obj, | 47 const base::android::JavaParamRef<jobject>& obj, |
46 const base::android::JavaParamRef<jobject>& delegate); | 48 const base::android::JavaParamRef<jobject>& delegate); |
47 void GvrInit(JNIEnv* env, | 49 void GvrInit(JNIEnv* env, |
48 const base::android::JavaParamRef<jobject>& obj, | 50 const base::android::JavaParamRef<jobject>& obj, |
49 jlong native_gvr_api); | 51 jlong native_gvr_api); |
50 void InitializeGl(JNIEnv* env, | 52 void InitializeGl(JNIEnv* env, |
51 const base::android::JavaParamRef<jobject>& obj, | 53 const base::android::JavaParamRef<jobject>& obj, |
52 jint texture_data_handle); | 54 jint content_texture_handle, |
| 55 jint ui_texture_handle); |
53 void DrawFrame(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 56 void DrawFrame(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
54 void OnPause(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 57 void OnPause(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
55 void OnResume(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 58 void OnResume(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
56 void SetWebVrMode(JNIEnv* env, | 59 void SetWebVrMode(JNIEnv* env, |
57 const base::android::JavaParamRef<jobject>& obj, | 60 const base::android::JavaParamRef<jobject>& obj, |
58 bool enabled); | 61 bool enabled); |
59 | 62 |
60 // html/js UI hooks. | 63 // html/js UI hooks. |
61 static base::WeakPtr<VrShell> GetWeakPtr(); | 64 static base::WeakPtr<VrShell> GetWeakPtr(); |
62 void OnDomContentsLoaded(); | 65 void OnDomContentsLoaded(); |
63 void SetUiTextureSize(int width, int height); | 66 void SetUiTextureSize(int width, int height); |
64 | 67 |
65 // device::GvrDelegate implementation | 68 // device::GvrDelegate implementation |
66 void SubmitWebVRFrame() override; | 69 void SubmitWebVRFrame() override; |
67 void UpdateWebVRTextureBounds( | 70 void UpdateWebVRTextureBounds( |
68 int eye, float left, float top, float width, float height) override; | 71 int eye, float left, float top, float width, float height) override; |
69 gvr::GvrApi* gvr_api() override; | 72 gvr::GvrApi* gvr_api() override; |
70 | 73 |
71 void ContentSurfaceDestroyed( | 74 void ContentSurfaceChanged( |
72 JNIEnv* env, | 75 JNIEnv* env, |
73 const base::android::JavaParamRef<jobject>& object); | 76 const base::android::JavaParamRef<jobject>& object, |
74 void ContentSurfaceChanged( | 77 jint width, |
| 78 jint height, |
| 79 const base::android::JavaParamRef<jobject>& surface); |
| 80 void UiSurfaceChanged( |
75 JNIEnv* env, | 81 JNIEnv* env, |
76 const base::android::JavaParamRef<jobject>& object, | 82 const base::android::JavaParamRef<jobject>& object, |
77 jint width, | 83 jint width, |
78 jint height, | 84 jint height, |
79 const base::android::JavaParamRef<jobject>& surface); | 85 const base::android::JavaParamRef<jobject>& surface); |
80 | 86 |
81 private: | 87 private: |
82 virtual ~VrShell(); | 88 virtual ~VrShell(); |
| 89 void LoadUIContent(); |
83 void DrawVrShell(int64_t time); | 90 void DrawVrShell(int64_t time); |
84 void DrawEye(const gvr::Mat4f& view_matrix, | 91 void DrawEye(const gvr::Mat4f& view_matrix, |
85 const gvr::BufferViewport& params); | 92 const gvr::BufferViewport& params); |
86 void DrawContentRect(); | 93 void DrawContentRect(); |
87 void DrawWebVr(); | 94 void DrawWebVr(); |
88 void DrawUI(); | 95 void DrawUI(); |
89 void DrawCursor(); | 96 void DrawCursor(); |
90 | 97 |
91 void UpdateController(); | 98 void UpdateController(); |
92 | 99 |
93 // samplerExternalOES texture data for content area image. | 100 // samplerExternalOES texture data for UI content image. |
| 101 jint ui_texture_id_ = 0; |
| 102 // samplerExternalOES texture data for main content image. |
94 jint content_texture_id_ = 0; | 103 jint content_texture_id_ = 0; |
95 | 104 |
96 float desktop_screen_tilt_; | 105 float desktop_screen_tilt_; |
97 float desktop_height_; | 106 float desktop_height_; |
98 | 107 |
99 ContentRectangle* desktop_plane_; | 108 ContentRectangle* desktop_plane_; |
100 gvr::Vec3f desktop_position_; | 109 gvr::Vec3f desktop_position_; |
101 | 110 |
102 UiScene scene_; | 111 UiScene scene_; |
103 | 112 |
104 std::unique_ptr<gvr::GvrApi> gvr_api_; | 113 std::unique_ptr<gvr::GvrApi> gvr_api_; |
105 std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_; | 114 std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_; |
106 std::unique_ptr<gvr::BufferViewport> buffer_viewport_; | 115 std::unique_ptr<gvr::BufferViewport> buffer_viewport_; |
107 std::unique_ptr<gvr::SwapChain> swap_chain_; | 116 std::unique_ptr<gvr::SwapChain> swap_chain_; |
108 | 117 |
109 gvr::Mat4f view_matrix_; | 118 gvr::Mat4f view_matrix_; |
110 gvr::Mat4f projection_matrix_; | 119 gvr::Mat4f projection_matrix_; |
111 | 120 |
112 gvr::Mat4f head_pose_; | 121 gvr::Mat4f head_pose_; |
113 gvr::Vec3f forward_vector_; | 122 gvr::Vec3f forward_vector_; |
114 | 123 |
115 gvr::Sizei render_size_; | 124 gvr::Sizei render_size_; |
116 float cursor_distance_; | 125 float cursor_distance_; |
117 | 126 |
118 std::unique_ptr<VrCompositor> content_compositor_view_; | 127 std::unique_ptr<VrCompositor> content_compositor_; |
119 content::ContentViewCore* content_cvc_; | 128 content::ContentViewCore* content_cvc_; |
| 129 std::unique_ptr<VrCompositor> ui_compositor_; |
| 130 content::ContentViewCore* ui_cvc_; |
120 | 131 |
121 VrShellDelegate* delegate_; | 132 VrShellDelegate* delegate_; |
122 std::unique_ptr<VrShellRenderer> vr_shell_renderer_; | 133 std::unique_ptr<VrShellRenderer> vr_shell_renderer_; |
123 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; | 134 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; |
124 | 135 |
125 gvr::Quatf controller_quat_; | 136 gvr::Quatf controller_quat_; |
126 bool controller_active_ = false; | 137 bool controller_active_ = false; |
127 gvr::Vec3f look_at_vector_; | 138 gvr::Vec3f look_at_vector_; |
128 int ui_tex_width_ = 0; | 139 int ui_tex_width_ = 0; |
129 int ui_tex_height_ = 0; | 140 int ui_tex_height_ = 0; |
130 | 141 |
131 bool webvr_mode_ = false; | 142 bool webvr_mode_ = false; |
132 | 143 |
133 base::WeakPtrFactory<VrShell> weak_ptr_factory_; | 144 base::WeakPtrFactory<VrShell> weak_ptr_factory_; |
134 | 145 |
135 DISALLOW_COPY_AND_ASSIGN(VrShell); | 146 DISALLOW_COPY_AND_ASSIGN(VrShell); |
136 }; | 147 }; |
137 | 148 |
138 bool RegisterVrShell(JNIEnv* env); | 149 bool RegisterVrShell(JNIEnv* env); |
139 | 150 |
140 } // namespace vr_shell | 151 } // namespace vr_shell |
141 | 152 |
142 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ | 153 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ |
OLD | NEW |