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

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

Issue 2730883003: Remove unnecessary UI element math. (Closed)
Patch Set: Remove more code. Created 3 years, 9 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_UI_ELEMENTS_H_ 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_H_ 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 26 matching lines...) Expand all
37 // center color. 37 // center color.
38 OPAQUE_GRADIENT = 2, 38 OPAQUE_GRADIENT = 2,
39 // Same as OPAQUE_GRADIENT but the element is drawn as a grid. 39 // Same as OPAQUE_GRADIENT but the element is drawn as a grid.
40 GRID_GRADIENT = 3, 40 GRID_GRADIENT = 3,
41 // The element is filled with the content web site. Only one content element 41 // The element is filled with the content web site. Only one content element
42 // may be added to the 42 // may be added to the
43 // scene. 43 // scene.
44 CONTENT = 4, 44 CONTENT = 4,
45 }; 45 };
46 46
47 struct ReversibleTransform { 47 struct Transform {
48 ReversibleTransform(); 48 Transform();
49 49
50 void MakeIdentity(); 50 void MakeIdentity();
51 void Rotate(gvr::Quatf quat); 51 void Rotate(gvr::Quatf quat);
52 void Rotate(float ax, float ay, float az, float rad); 52 void Rotate(float ax, float ay, float az, float rad);
53 void Translate(float tx, float ty, float tz); 53 void Translate(float tx, float ty, float tz);
54 void Scale(float sx, float sy, float sz); 54 void Scale(float sx, float sy, float sz);
55 55
56 gvr::Mat4f to_world; 56 gvr::Mat4f to_world;
57 gvr::Mat4f from_world;
58
59 // This object-to-world orientation quaternion is technically
60 // redundant, but it's easy to track it here for use as needed.
61 // TODO(klausw): use this instead of MatrixVectorRotation()?
62 // Would need quat * vector implementation.
63 gvr::Quatf orientation = {0.0f, 0.0f, 0.0f, 1.0f};
64 }; 57 };
65 58
66 struct WorldObject { 59 class WorldRectangle {
67 ReversibleTransform transform; 60 public:
68 }; 61 const gvr::Mat4f& TransformMatrix() const;
62 void SetTransform(const Transform& transform);
69 63
70 struct WorldRectangle : public WorldObject {
71 gvr::Vec3f GetCenter() const; 64 gvr::Vec3f GetCenter() const;
72 gvr::Vec3f GetNormal() const; 65 gvr::Vec3f GetNormal() const;
73 float GetRayDistance(gvr::Vec3f rayOrigin, gvr::Vec3f rayVector) const; 66 bool GetRayDistance(const gvr::Vec3f& ray_origin,
tiborg 2017/03/06 17:51:43 Add comment to describe the return type and parame
cjgrant 2017/03/06 18:41:47 Done.
67 const gvr::Vec3f& ray_vector,
68 float* distance) const;
69 gvr::Vec2f GetUnitRectangleCoordinates(const gvr::Vec3f& world_point);
tiborg 2017/03/06 17:51:43 Also here I would say comments help a lot (return
cjgrant 2017/03/06 18:41:47 Done.
70
71 private:
72 Transform transform_;
74 }; 73 };
75 74
76 struct ContentRectangle : public WorldRectangle { 75 struct ContentRectangle : public WorldRectangle {
77 ContentRectangle(); 76 ContentRectangle();
78 ~ContentRectangle(); 77 ~ContentRectangle();
79 78
80 void Animate(int64_t time); 79 void Animate(int64_t time);
81 80
82 // Indicates whether the element should be visually rendered. 81 // Indicates whether the element should be visually rendered.
83 bool IsVisible() const; 82 bool IsVisible() const;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 141
143 int draw_phase = 1; 142 int draw_phase = 1;
144 143
145 private: 144 private:
146 DISALLOW_COPY_AND_ASSIGN(ContentRectangle); 145 DISALLOW_COPY_AND_ASSIGN(ContentRectangle);
147 }; 146 };
148 147
149 } // namespace vr_shell 148 } // namespace vr_shell
150 149
151 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_H_ 150 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/vr_shell/ui_elements.cc » ('j') | chrome/browser/android/vr_shell/ui_elements.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698