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

Unified Diff: chrome/browser/android/vr_shell/ui_scene.cc

Issue 2801073002: [vr] Use base's time classes (Closed)
Patch Set: updated tests 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene.h ('k') | chrome/browser/android/vr_shell/ui_scene_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/ui_scene.cc
diff --git a/chrome/browser/android/vr_shell/ui_scene.cc b/chrome/browser/android/vr_shell/ui_scene.cc
index fc46134aae41fea9882d1a4f3dbaea609191bd7b..d1c387ae92d8c72394dd44bb14328ab33a121dfd 100644
--- a/chrome/browser/android/vr_shell/ui_scene.cc
+++ b/chrome/browser/android/vr_shell/ui_scene.cc
@@ -8,6 +8,7 @@
#include <utility>
#include "base/memory/ptr_util.h"
+#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/android/vr_shell/animation.h"
#include "chrome/browser/android/vr_shell/easing.h"
@@ -229,7 +230,7 @@ void UiScene::AddAnimation(int element_id,
}
void UiScene::AddAnimationFromDict(const base::DictionaryValue& dict,
- int64_t time_in_micro) {
+ const base::TimeTicks& current_time) {
int animation_id;
int element_id;
Animation::Property property;
@@ -261,8 +262,9 @@ void UiScene::AddAnimationFromDict(const base::DictionaryValue& dict,
ParseEndpointToFloats(property, *from_dict, &from);
}
- int64_t start = time_in_micro + (start_time_ms * 1000.0);
- int64_t duration = duration_ms * 1000.0;
+ base::TimeDelta delay = base::TimeDelta::FromMilliseconds(start_time_ms);
+ base::TimeTicks start = current_time + delay;
+ base::TimeDelta duration = base::TimeDelta::FromMilliseconds(duration_ms);
ContentRectangle* element = GetUiElementById(element_id);
CHECK_NE(element, nullptr);
@@ -285,7 +287,7 @@ void UiScene::RemoveAnimation(int element_id, int animation_id) {
}
void UiScene::HandleCommands(std::unique_ptr<base::ListValue> commands,
- int64_t time_in_micro) {
+ const base::TimeTicks& time) {
for (auto& item : *commands) {
base::DictionaryValue* dict;
CHECK(item->GetAsDictionary(&dict));
@@ -309,7 +311,7 @@ void UiScene::HandleCommands(std::unique_ptr<base::ListValue> commands,
break;
}
case Command::ADD_ANIMATION:
- AddAnimationFromDict(*data, time_in_micro);
+ AddAnimationFromDict(*data, time);
break;
case Command::REMOVE_ANIMATION: {
int element_id, animation_id;
@@ -327,10 +329,10 @@ void UiScene::HandleCommands(std::unique_ptr<base::ListValue> commands,
}
}
-void UiScene::UpdateTransforms(int64_t time_in_micro) {
+void UiScene::UpdateTransforms(const base::TimeTicks& time) {
for (auto& element : ui_elements_) {
// Process all animations before calculating object transforms.
- element->Animate(time_in_micro);
+ element->Animate(time);
element->dirty = true;
}
for (auto& element : ui_elements_) {
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene.h ('k') | chrome/browser/android/vr_shell/ui_scene_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698