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

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

Issue 2301633002: Refactor Vr activity into ChromeTabbedActivity. (Closed)
Patch Set: Address comments 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 "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.h"
14 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr_types.h" 16 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr_types.h"
15 17
18
16 namespace vr_shell { 19 namespace vr_shell {
17 20
18 class VrShellRenderer; 21 class VrShellRenderer;
19 22
20 class ContentRect {
21 public:
22 ContentRect();
23 ~ContentRect();
24 void SetIdentity();
25 void Translate(float x, float y, float z);
26 gvr::Mat4f transfrom_to_world;
27 int content_texture_handle;
28 };
29
30 class VrShell { 23 class VrShell {
31 public: 24 public:
32 VrShell(JNIEnv* env, jobject obj); 25 VrShell(JNIEnv* env, jobject obj);
33 26
34 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); 27 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
35
36 void GvrInit(JNIEnv* env, 28 void GvrInit(JNIEnv* env,
37 const base::android::JavaParamRef<jobject>& obj, 29 const base::android::JavaParamRef<jobject>& obj,
38 jlong native_gvr_api); 30 jlong native_gvr_api);
39 void InitializeGl(JNIEnv* env, 31 void InitializeGl(JNIEnv* env,
40 const base::android::JavaParamRef<jobject>& obj, 32 const base::android::JavaParamRef<jobject>& obj,
41 jint texture_data_handle); 33 jint texture_data_handle);
42 void DrawFrame(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); 34 void DrawFrame(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
43 void OnPause(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); 35 void OnPause(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
44 void OnResume(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); 36 void OnResume(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
45 37
46 private: 38 private:
47 ~VrShell(); 39 ~VrShell();
48
49 void DrawEye(const gvr::Mat4f& view_matrix, 40 void DrawEye(const gvr::Mat4f& view_matrix,
50 const gvr::BufferViewport& params); 41 const gvr::BufferViewport& params);
51 void DrawContentRect(); 42 void DrawUI();
52 43
53 std::unique_ptr<ContentRect> content_rect_; 44 void UpdateTransforms(float screenWidthMeters,
David Trainor- moved to gerrit 2016/09/08 05:49:30 fix variable names, same for others. Will stop ni
mthiesse 2016/09/08 17:44:41 haha sorry about that. I've scoured through the co
David Trainor- moved to gerrit 2016/09/09 06:28:29 No worries! I do the same thing especially moving
45 float screenHeightMeters,
46 float screenTilt);
47
48 // samplerExternalOES texture data for desktop content image.
49 jint content_texture_id_ = 0;
50
51 // Constant taken from treasure_hunt demo.
52 static constexpr long kPredictionTimeWithoutVsyncNanos = 50000000;
David Trainor- moved to gerrit 2016/09/08 05:49:30 Should these be in an anonymous namespace in the c
mthiesse 2016/09/08 17:44:41 There's no reason to have these in the header, rat
David Trainor- moved to gerrit 2016/09/09 06:28:29 Yeah sorry for the nit about this. For me it make
53
54 static constexpr float kZNear = 0.1f;
55 static constexpr float kZFar = 1000.0f;
56
57 static constexpr gvr::Vec3f kDesktopPositionDefault = {0.0f, 0.0f, -2.0f};
58 static constexpr float kDesktopHeightDefault = 1.6f;
59
60 // Screen angle in degrees. 0 = vertical, positive = top closer.
61 static constexpr float kDesktopScreenTiltDefault = 0;
62
63 static constexpr float kScreenHeightMeters = 2.0f;
64 static constexpr float kScreenWidthMeters = 2.0f;
65
66 float desktop_screen_tilt_ = kDesktopScreenTiltDefault;
67 float desktop_height_ = kDesktopHeightDefault;
68
69 ContentRectangle* desktop_plane_;
70 gvr::Vec3f desktop_position_ = kDesktopPositionDefault;
71
72 std::vector<std::unique_ptr<ContentRectangle>> ui_rects_;
73
54 std::unique_ptr<gvr::GvrApi> gvr_api_; 74 std::unique_ptr<gvr::GvrApi> gvr_api_;
55 std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_; 75 std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_;
56 std::unique_ptr<gvr::BufferViewport> buffer_viewport_; 76 std::unique_ptr<gvr::BufferViewport> buffer_viewport_;
57 std::unique_ptr<gvr::SwapChain> swap_chain_; 77 std::unique_ptr<gvr::SwapChain> swap_chain_;
58 78
59 gvr::Mat4f view_matrix_; 79 gvr::Mat4f view_matrix_;
60 gvr::Mat4f projection_matrix_; 80 gvr::Mat4f projection_matrix_;
61 81
62 gvr::Mat4f head_pose_; 82 gvr::Mat4f head_pose_;
63 83
64 gvr::Sizei render_size_; 84 gvr::Sizei render_size_;
65 85
66 std::unique_ptr<VrShellRenderer> vr_shell_renderer_; 86 std::unique_ptr<VrShellRenderer> vr_shell_renderer_;
67
68 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; 87 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_;
69 88
70 DISALLOW_COPY_AND_ASSIGN(VrShell); 89 DISALLOW_COPY_AND_ASSIGN(VrShell);
71 }; 90 };
72 91
73 bool RegisterVrShell(JNIEnv* env); 92 bool RegisterVrShell(JNIEnv* env);
74 93
75 } // namespace vr_shell 94 } // namespace vr_shell
76 95
77 #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