OLD | NEW |
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 #include "chrome/browser/android/vr_shell/ui_elements.h" | 5 #include "chrome/browser/android/vr_shell/ui_elements.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/android/vr_shell/animation.h" | 8 #include "chrome/browser/android/vr_shell/animation.h" |
9 #include "chrome/browser/android/vr_shell/easing.h" | 9 #include "chrome/browser/android/vr_shell/easing.h" |
10 | 10 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 animation.from.push_back(rotation.x); | 115 animation.from.push_back(rotation.x); |
116 animation.from.push_back(rotation.y); | 116 animation.from.push_back(rotation.y); |
117 animation.from.push_back(rotation.z); | 117 animation.from.push_back(rotation.z); |
118 animation.from.push_back(rotation.angle); | 118 animation.from.push_back(rotation.angle); |
119 break; | 119 break; |
120 case Animation::TRANSLATION: | 120 case Animation::TRANSLATION: |
121 animation.from.push_back(translation.x); | 121 animation.from.push_back(translation.x); |
122 animation.from.push_back(translation.y); | 122 animation.from.push_back(translation.y); |
123 animation.from.push_back(translation.z); | 123 animation.from.push_back(translation.z); |
124 break; | 124 break; |
| 125 case Animation::OPACITY: |
| 126 animation.from.push_back(opacity); |
| 127 break; |
125 } | 128 } |
126 } | 129 } |
127 CHECK_EQ(animation.from.size(), animation.to.size()); | 130 CHECK_EQ(animation.from.size(), animation.to.size()); |
128 | 131 |
129 std::vector<float> values(animation.from.size()); | 132 std::vector<float> values(animation.from.size()); |
130 for (std::size_t i = 0; i < animation.from.size(); ++i) { | 133 for (std::size_t i = 0; i < animation.from.size(); ++i) { |
131 if (animation.to[i] == animation.from[i] || | 134 if (animation.to[i] == animation.from[i] || |
132 time >= (animation.start + animation.duration)) { | 135 time >= (animation.start + animation.duration)) { |
133 values[i] = animation.to[i]; | 136 values[i] = animation.to[i]; |
134 continue; | 137 continue; |
(...skipping 28 matching lines...) Expand all Loading... |
163 rotation.y = values[1]; | 166 rotation.y = values[1]; |
164 rotation.z = values[2]; | 167 rotation.z = values[2]; |
165 rotation.angle = values[3]; | 168 rotation.angle = values[3]; |
166 break; | 169 break; |
167 case Animation::TRANSLATION: | 170 case Animation::TRANSLATION: |
168 CHECK_EQ(animation.from.size(), 3u); | 171 CHECK_EQ(animation.from.size(), 3u); |
169 translation.x = values[0]; | 172 translation.x = values[0]; |
170 translation.y = values[1]; | 173 translation.y = values[1]; |
171 translation.z = values[2]; | 174 translation.z = values[2]; |
172 break; | 175 break; |
| 176 case Animation::OPACITY: |
| 177 CHECK_EQ(animation.from.size(), 1u); |
| 178 opacity = values[0]; |
| 179 break; |
173 } | 180 } |
174 } | 181 } |
175 for (auto it = animations.begin(); it != animations.end();) { | 182 for (auto it = animations.begin(); it != animations.end();) { |
176 const Animation& animation = **it; | 183 const Animation& animation = **it; |
177 if (time >= (animation.start + animation.duration)) { | 184 if (time >= (animation.start + animation.duration)) { |
178 it = animations.erase(it); | 185 it = animations.erase(it); |
179 } else { | 186 } else { |
180 ++it; | 187 ++it; |
181 } | 188 } |
182 } | 189 } |
183 } | 190 } |
184 | 191 |
| 192 bool ContentRectangle::IsVisible() const { |
| 193 return visible && computed_opacity > 0.0f; |
| 194 } |
| 195 |
| 196 bool ContentRectangle::IsHitTestable() const { |
| 197 return IsVisible() && hit_testable; |
| 198 } |
| 199 |
185 } // namespace vr_shell | 200 } // namespace vr_shell |
186 | 201 |
OLD | NEW |