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

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

Issue 2301633002: Refactor Vr activity into ChromeTabbedActivity. (Closed)
Patch Set: Address comments and rebase 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) \
bshe 2016/09/09 14:42:10 see here: https://google.github.io/styleguide/cppg
mthiesse 2016/09/09 15:16:38 Done.
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 {
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);
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, const gvr::Mat4f& mat, float x, float y, float z);
47 void ScaleMRight(gvr::Mat4f& tmat, const gvr::Mat4f& mat,
48 float x, float y, float z);
49
15 std::array<float, 16> MatrixToGLArray(const gvr::Mat4f& matrix); 50 std::array<float, 16> MatrixToGLArray(const gvr::Mat4f& matrix);
16 51
17 // Util functions that are copied from the treasure_hunt NDK demo in 52 // Util functions that are copied from the treasure_hunt NDK demo in
18 // third_party/gvr-andoir-sdk/ folder. 53 // third_party/gvr-andoir-sdk/ folder.
19 gvr::Mat4f MatrixTranspose(const gvr::Mat4f& mat); 54 gvr::Mat4f MatrixTranspose(const gvr::Mat4f& mat);
55 std::array<float, 4> MatrixVectorMul(const gvr::Mat4f& matrix,
56 const std::array<float, 4>& vec);
57 std::array<float, 3> MatrixVectorMul(const gvr::Mat4f& matrix,
58 const std::array<float, 3>& vec);
59 gvr::Vec3f MatrixVectorMul(const gvr::Mat4f& m, const gvr::Vec3f& v);
60 gvr::Vec3f MatrixVectorRotate(const gvr::Mat4f& m, const gvr::Vec3f& v);
20 gvr::Mat4f MatrixMul(const gvr::Mat4f& matrix1, const gvr::Mat4f& matrix2); 61 gvr::Mat4f MatrixMul(const gvr::Mat4f& matrix1, const gvr::Mat4f& matrix2);
62 gvr::Mat4f InvertM(const gvr::Mat4f& mat);
21 gvr::Mat4f PerspectiveMatrixFromView(const gvr::Rectf& fov, 63 gvr::Mat4f PerspectiveMatrixFromView(const gvr::Rectf& fov,
22 float z_near, 64 float z_near,
23 float z_far); 65 float z_far);
24 gvr::Rectf ModulateRect(const gvr::Rectf& rect, float width, float height); 66 gvr::Rectf ModulateRect(const gvr::Rectf& rect, float width, float height);
25 gvr::Recti CalculatePixelSpaceRect(const gvr::Sizei& texture_size, 67 gvr::Recti CalculatePixelSpaceRect(const gvr::Sizei& texture_size,
26 const gvr::Rectf& texture_rect); 68 const gvr::Rectf& texture_rect);
27 69
70 gvr::Vec3f getForwardVector(const gvr::Mat4f& matrix);
71 gvr::Vec3f getTranslation(const gvr::Mat4f& matrix);
72
28 // Compile a shader. 73 // Compile a shader.
29 GLuint CompileShader(GLenum shader_type, 74 GLuint CompileShader(GLenum shader_type,
30 const GLchar* shader_source, 75 const GLchar* shader_source,
31 std::string& error); 76 std::string& error);
32 77
33 // Compile and link a program. 78 // Compile and link a program.
34 GLuint CreateAndLinkProgram(GLuint vertex_shader_handle, 79 GLuint CreateAndLinkProgram(GLuint vertex_shader_handle,
35 GLuint fragment_shader_handle, 80 GLuint fragment_shader_handle,
36 int num_attributes, 81 int num_attributes,
37 const GLchar** attributes, 82 const GLchar** attributes,
38 std::string& error); 83 std::string& error);
39 84
85 gvr::Quatf QuatMultiply(const gvr::Quatf& a, const gvr::Quatf& b);
86
87 gvr::Mat4f QuatToMatrix(const gvr::Quatf& quat);
88
89 float VectorLength(const gvr::Vec3f& vec);
90
91 void NormalizeVector(gvr::Vec3f& vec);
92
93 float VectorDot(const gvr::Vec3f& a, const gvr::Vec3f& b);
94
95 void NormalizeQuat(gvr::Quatf& quat);
96
97 gvr::Quatf QuatFromAxisAngle(float x, float y, float z, float angle);
98
40 } // namespace vr_shell 99 } // namespace vr_shell
41 100
42 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_UTIL_H_ 101 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698