Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(629)

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell.h

Issue 2301633002: Refactor Vr activity into ChromeTabbedActivity. (Closed)
Patch Set: UiElements are now structs Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 11
11 #include "base/android/jni_weak_ref.h" 12 #include "base/android/jni_weak_ref.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "chrome/browser/android/vr_shell/ui_elements.h"
13 #include "device/vr/android/gvr/gvr_delegate.h" 15 #include "device/vr/android/gvr/gvr_delegate.h"
14 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr.h" 16 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr.h"
15 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr_types.h" 17 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr_types.h"
16 18
19
17 namespace vr_shell { 20 namespace vr_shell {
18 21
19 class VrShellRenderer; 22 class VrShellRenderer;
20 23
21 class ContentRect {
22 public:
23 ContentRect();
24 ~ContentRect();
25 void SetIdentity();
26 void Translate(float x, float y, float z);
27 gvr::Mat4f transfrom_to_world;
28 int content_texture_handle;
29 };
30 24
31 class VrShell : public device::GvrDelegate { 25 class VrShell : public device::GvrDelegate {
32 public: 26 public:
33 VrShell(JNIEnv* env, jobject obj); 27 VrShell(JNIEnv* env, jobject obj);
34 28
35 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); 29 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
36
37 void GvrInit(JNIEnv* env, 30 void GvrInit(JNIEnv* env,
38 const base::android::JavaParamRef<jobject>& obj, 31 const base::android::JavaParamRef<jobject>& obj,
39 jlong native_gvr_api); 32 jlong native_gvr_api);
40 void InitializeGl(JNIEnv* env, 33 void InitializeGl(JNIEnv* env,
41 const base::android::JavaParamRef<jobject>& obj, 34 const base::android::JavaParamRef<jobject>& obj,
42 jint texture_data_handle); 35 jint texture_data_handle);
43 void DrawFrame(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); 36 void DrawFrame(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
44 void OnPause(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); 37 void OnPause(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
45 void OnResume(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); 38 void OnResume(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
46 39
47 // GvrDelegate 40 // GvrDelegate
48 void RequestWebVRPresent() override; 41 void RequestWebVRPresent() override;
49 void ExitWebVRPresent() override; 42 void ExitWebVRPresent() override;
50 void SubmitWebVRFrame() override; 43 void SubmitWebVRFrame() override;
51 void UpdateWebVRTextureBounds( 44 void UpdateWebVRTextureBounds(
52 int eye, float left, float top, float width, float height) override; 45 int eye, float left, float top, float width, float height) override;
53 gvr::GvrApi* gvr_api() override; 46 gvr::GvrApi* gvr_api() override;
54 47
55 private: 48 private:
56 virtual ~VrShell(); 49 virtual ~VrShell();
57
58 void DrawVrShell(); 50 void DrawVrShell();
59 void DrawEye(const gvr::Mat4f& view_matrix, 51 void DrawEye(const gvr::Mat4f& view_matrix,
60 const gvr::BufferViewport& params); 52 const gvr::BufferViewport& params);
61 void DrawContentRect(); 53 void DrawContentRect();
62 void DrawWebVr(); 54 void DrawWebVr();
55 void DrawUI();
63 56
64 std::unique_ptr<ContentRect> content_rect_; 57 void UpdateTransforms(float screen_width_meters,
58 float screen_height_meters,
59 float scree_tilt);
60
61 // samplerExternalOES texture data for content area image.
62 jint content_texture_id_ = 0;
63
64 float desktop_screen_tilt_;
65 float desktop_height_;
66
67 ContentRectangle* desktop_plane_;
68 gvr::Vec3f desktop_position_;
69
70 std::vector<std::unique_ptr<ContentRectangle>> ui_rects_;
71
65 std::unique_ptr<gvr::GvrApi> gvr_api_; 72 std::unique_ptr<gvr::GvrApi> gvr_api_;
66 std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_; 73 std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_;
67 std::unique_ptr<gvr::BufferViewport> buffer_viewport_; 74 std::unique_ptr<gvr::BufferViewport> buffer_viewport_;
68 std::unique_ptr<gvr::SwapChain> swap_chain_; 75 std::unique_ptr<gvr::SwapChain> swap_chain_;
69 76
70 gvr::Mat4f view_matrix_; 77 gvr::Mat4f view_matrix_;
71 gvr::Mat4f projection_matrix_; 78 gvr::Mat4f projection_matrix_;
72 79
73 gvr::Mat4f head_pose_; 80 gvr::Mat4f head_pose_;
74 81
75 gvr::Sizei render_size_; 82 gvr::Sizei render_size_;
76 83
77 std::unique_ptr<VrShellRenderer> vr_shell_renderer_; 84 std::unique_ptr<VrShellRenderer> vr_shell_renderer_;
78
79 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; 85 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_;
80 86
81 bool webvr_mode_; 87 bool webvr_mode_ = false;
82 88
83 DISALLOW_COPY_AND_ASSIGN(VrShell); 89 DISALLOW_COPY_AND_ASSIGN(VrShell);
84 }; 90 };
85 91
86 bool RegisterVrShell(JNIEnv* env); 92 bool RegisterVrShell(JNIEnv* env);
87 93
88 } // namespace vr_shell 94 } // namespace vr_shell
89 95
90 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ 96 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698