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

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

Issue 2834543006: Hook up insecure content warnings for http webVR presentation. (Closed)
Patch Set: rebase Created 3 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENT_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENT_H_
7
8 #include <memory>
9 #include <string>
10 #include <vector>
11
12 #include "base/macros.h"
13 #include "device/vr/vr_types.h"
14
15 namespace base {
16 class TimeTicks;
17 }
18
19 namespace vr_shell {
20
21 class Animation;
22
23 enum XAnchoring {
24 XNONE = 0,
25 XLEFT,
26 XRIGHT,
27 };
28
29 enum YAnchoring {
30 YNONE = 0,
31 YTOP,
32 YBOTTOM,
33 };
34
35 enum Fill {
36 NONE = 0,
37 SKIA = 1,
38 // The element is filled with a radial gradient as specified by the edge and
39 // center color.
40 OPAQUE_GRADIENT = 2,
41 // Same as OPAQUE_GRADIENT but the element is drawn as a grid.
42 GRID_GRADIENT = 3,
43 // The element is filled with the content web site. Only one content element
44 // may be added to the
45 // scene.
46 CONTENT = 4,
47 };
48
49 struct Transform {
50 Transform();
51
52 void MakeIdentity();
53 void Rotate(const vr::Quatf& quat);
54 void Rotate(const vr::RotationAxisAngle& axis_angle);
55 void Translate(const gfx::Vector3dF& translation);
56 void Scale(const gfx::Vector3dF& scale);
57
58 vr::Mat4f to_world;
59 };
60
61 class WorldRectangle {
62 public:
63 const vr::Mat4f& TransformMatrix() const;
64 Transform* mutable_transform() { return &transform_; }
65
66 gfx::Point3F GetCenter() const;
67 gfx::Vector3dF GetNormal() const;
68
69 // Computes the distance from |ray_origin| to this rectangles's plane, along
70 // |ray_vector|. Returns true and populates |distance| if the calculation is
71 // possible, and false if the ray is parallel to the plane.
72 bool GetRayDistance(const gfx::Point3F& ray_origin,
73 const gfx::Vector3dF& ray_vector,
74 float* distance) const;
75
76 // Projects a 3D world point onto the X and Y axes of the transformed
77 // rectangle, returning 2D coordinates relative to the un-transformed unit
78 // rectangle. This allows beam intersection points to be mapped to sprite
79 // pixel coordinates. Points that fall onto the rectangle will generate X and
80 // Y values on the interval [-0.5, 0.5].
81 gfx::PointF GetUnitRectangleCoordinates(const gfx::Point3F& world_point);
82
83 private:
84 Transform transform_;
85 };
86
87 struct UiElement : public WorldRectangle {
88 UiElement();
89 ~UiElement();
90
91 void Animate(const base::TimeTicks& time);
92
93 // Indicates whether the element should be visually rendered.
94 bool IsVisible() const;
95
96 // Indicates whether the element should be tested for cursor input.
97 bool IsHitTestable() const;
98
99 // Valid IDs are non-negative.
100 int id = -1;
101
102 // Name string for debugging and testing purposes.
103 std::string name;
104
105 // If a non-negative parent ID is specified, applicable transformations
106 // are applied relative to the parent, rather than absolutely.
107 int parent_id = -1;
108
109 // If true, this object will be visible.
110 bool visible = true;
111
112 // If false, the reticle will not hit the element, even if visible.
113 bool hit_testable = true;
114
115 // If true, transformations will be applied relative to the field of view,
116 // rather than the world.
117 bool lock_to_fov = false;
118
119 // The size of the object. This does not affect children.
120 gfx::Vector3dF size = {1.0f, 1.0f, 1.0f};
121
122 // The scale of the object, and its children.
123 gfx::Vector3dF scale = {1.0f, 1.0f, 1.0f};
124
125 // The rotation of the object, and its children.
126 vr::RotationAxisAngle rotation = {1.0f, 0.0f, 0.0f, 0.0f};
127
128 // The translation of the object, and its children. Translation is applied
129 // after rotation and scaling.
130 gfx::Vector3dF translation = {0.0f, 0.0f, 0.0f};
131
132 // The opacity of the object (between 0.0 and 1.0).
133 float opacity = 1.0f;
134
135 // The computed opacity, incorporating opacity of parent objects.
136 float computed_opacity;
137
138 // The computed lock to the FoV, incorporating lock of parent objects.
139 bool computed_lock_to_fov;
140
141 // If anchoring is specified, the translation will be relative to the
142 // specified edge(s) of the parent, rather than the center. A parent object
143 // must be specified when using anchoring.
144 XAnchoring x_anchoring = XAnchoring::XNONE;
145 YAnchoring y_anchoring = YAnchoring::YNONE;
146
147 // Animations that affect the properties of the object over time.
148 std::vector<std::unique_ptr<Animation>> animations;
149
150 Fill fill = Fill::NONE;
151
152 vr::Colorf edge_color = {1.0f, 1.0f, 1.0f, 1.0f};
153 vr::Colorf center_color = {1.0f, 1.0f, 1.0f, 1.0f};
154
155 int gridline_count = 1;
156
157 int draw_phase = 1;
158
159 // This transform can be used by children to derive position of its parent.
160 Transform inheritable_transform;
161
162 // A flag usable during transformation calculates to avoid duplicate work.
163 bool dirty;
164
165 private:
166 DISALLOW_COPY_AND_ASSIGN(UiElement);
167 };
168
169 } // namespace vr_shell
170
171 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENT_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/textures/ui_texture.cc ('k') | chrome/browser/android/vr_shell/ui_element.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698