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