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

Side by Side Diff: chrome/browser/android/vr_shell/vr_util.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_UTIL_H_ 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_UTIL_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_UTIL_H_ 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr_types.h" 10 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr_types.h"
11 #include "ui/gl/gl_bindings.h" 11 #include "ui/gl/gl_bindings.h"
12 12
13 namespace vr_shell { 13 namespace vr_shell {
14 14
15 #define makeRectangularTextureBuffer(left, right, bottom, top) \
16 { \
17 left, bottom, left, top, right, bottom, left, top, right, top, right, \
18 bottom \
19 }
20
21 // 2D rectangles. Unlike gvr::Rectf and gvr::Recti, these have width and height
22 // rather than right and top.
23 typedef struct Recti {
David Trainor- moved to gerrit 2016/09/08 05:49:30 Just bringing up the gfx version of these things a
mthiesse 2016/09/08 17:44:41 Yes, these structs can easily just be cast and cop
David Trainor- moved to gerrit 2016/09/09 06:28:29 Makes sense. Do we push a lot of these?
24 int x;
25 int y;
26 int width;
27 int height;
28 } Recti;
29
30 typedef struct Rectf {
31 float x;
32 float y;
33 float width;
34 float height;
35 } Rectf;
36
37 void setIdentityM(gvr::Mat4f& mat);
David Trainor- moved to gerrit 2016/09/08 05:49:30 setIdentity -> SetIdentity, same with all other me
mthiesse 2016/09/08 17:44:41 Done.
38
39 void translateM(gvr::Mat4f& tmat, gvr::Mat4f& mat, float x, float y, float z);
40 void translateMRight(gvr::Mat4f& tmat,
41 gvr::Mat4f& mat,
42 float x,
43 float y,
44 float z);
45
46 void scaleM(gvr::Mat4f& tmat, gvr::Mat4f& mat, float x, float y, float z);
47 void scaleMRight(gvr::Mat4f& tmat, gvr::Mat4f& mat, float x, float y, float z);
48
15 std::array<float, 16> MatrixToGLArray(const gvr::Mat4f& matrix); 49 std::array<float, 16> MatrixToGLArray(const gvr::Mat4f& matrix);
16 50
17 // Util functions that are copied from the treasure_hunt NDK demo in 51 // Util functions that are copied from the treasure_hunt NDK demo in
18 // third_party/gvr-andoir-sdk/ folder. 52 // third_party/gvr-andoir-sdk/ folder.
19 gvr::Mat4f MatrixTranspose(const gvr::Mat4f& mat); 53 gvr::Mat4f MatrixTranspose(const gvr::Mat4f& mat);
54 std::array<float, 4> MatrixVectorMul(const gvr::Mat4f& matrix,
55 const std::array<float, 4>& vec);
56 std::array<float, 3> MatrixVectorMul(const gvr::Mat4f& matrix,
57 const std::array<float, 3>& vec);
58 gvr::Vec3f MatrixVectorMul(const gvr::Mat4f& m, gvr::Vec3f v);
David Trainor- moved to gerrit 2016/09/08 05:49:30 const & for the vecs as well?
mthiesse 2016/09/08 17:44:41 Done.
59 gvr::Vec3f MatrixVectorRotate(const gvr::Mat4f& m, gvr::Vec3f v);
20 gvr::Mat4f MatrixMul(const gvr::Mat4f& matrix1, const gvr::Mat4f& matrix2); 60 gvr::Mat4f MatrixMul(const gvr::Mat4f& matrix1, const gvr::Mat4f& matrix2);
61 gvr::Mat4f invertM(gvr::Mat4f mat);
David Trainor- moved to gerrit 2016/09/08 05:49:30 const &
mthiesse 2016/09/08 17:44:41 Done.
21 gvr::Mat4f PerspectiveMatrixFromView(const gvr::Rectf& fov, 62 gvr::Mat4f PerspectiveMatrixFromView(const gvr::Rectf& fov,
22 float z_near, 63 float z_near,
23 float z_far); 64 float z_far);
24 gvr::Rectf ModulateRect(const gvr::Rectf& rect, float width, float height); 65 gvr::Rectf ModulateRect(const gvr::Rectf& rect, float width, float height);
25 gvr::Recti CalculatePixelSpaceRect(const gvr::Sizei& texture_size, 66 gvr::Recti CalculatePixelSpaceRect(const gvr::Sizei& texture_size,
26 const gvr::Rectf& texture_rect); 67 const gvr::Rectf& texture_rect);
27 68
69 gvr::Vec3f getForwardVector(gvr::Mat4f matrix);
David Trainor- moved to gerrit 2016/09/08 05:49:30 const &
mthiesse 2016/09/08 17:44:41 Done.
70 gvr::Vec3f getTranslation(gvr::Mat4f matrix);
David Trainor- moved to gerrit 2016/09/08 05:49:30 const &
mthiesse 2016/09/08 17:44:41 Done.
71
28 // Compile a shader. 72 // Compile a shader.
29 GLuint CompileShader(GLenum shader_type, 73 GLuint CompileShader(GLenum shader_type,
30 const GLchar* shader_source, 74 const GLchar* shader_source,
31 std::string& error); 75 std::string& error);
32 76
33 // Compile and link a program. 77 // Compile and link a program.
34 GLuint CreateAndLinkProgram(GLuint vertex_shader_handle, 78 GLuint CreateAndLinkProgram(GLuint vertex_shader_handle,
35 GLuint fragment_shader_handle, 79 GLuint fragment_shader_handle,
36 int num_attributes, 80 int num_attributes,
37 const GLchar** attributes, 81 const GLchar** attributes,
38 std::string& error); 82 std::string& error);
39 83
84 gvr::Quatf QuatMultiply(const gvr::Quatf& a, const gvr::Quatf& b);
85
86 gvr::Mat4f QuatToMatrix(const gvr::Quatf& quat);
87
88 float VectorLength(const gvr::Vec3f& vec);
89
90 void NormalizeVector(gvr::Vec3f& vec);
91
92 float VectorDot(gvr::Vec3f& a, gvr::Vec3f& b);
93
94 void NormalizeQuat(gvr::Quatf& quat);
95
96 gvr::Quatf QuatFromAxisAngle(float x, float y, float z, float angle);
97
40 } // namespace vr_shell 98 } // namespace vr_shell
41 99
42 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_UTIL_H_ 100 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698