Commit 4698aea3 authored by Justin Donnelly's avatar Justin Donnelly Committed by Commit Bot

Revert "Move assistant icon animation to CompositorAnimationOberver"

This reverts commit 33fc6c64.

Reason for revert: One or the other of this CL and https://crrev.com/c/748268 (perhaps both in combination?) broke PaletteTrayTestWithVoiceInteraction.StylusBarrelButtonActivatesHighlighter on Linux ChromiumOS Tests (dbg)(1):

https://uberchromegw.corp.google.com/i/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%28dbg%29%281%29/builds/31692

The connection to these voice interaction Cls seems pretty clear. I can't identify which one it is, though, so while I apologize for the trouble, I'm going to revert both to ensure that the bot turns green again.

Original change's description:
> Move assistant icon animation to CompositorAnimationOberver
> 
> BUG=None
> TEST=locally build and see animation running as before.
> 
> Change-Id: I1eb62490108beaaec0795adb4251054c03b364e1
> Reviewed-on: https://chromium-review.googlesource.com/748273
> Commit-Queue: Xiaohui Chen <xiaohuic@chromium.org>
> Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#513211}

TBR=xiyuan@chromium.org,xiaohuic@chromium.org

Change-Id: I5ef677c189808601f8e357f56a171bf920b10fa0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: None
Reviewed-on: https://chromium-review.googlesource.com/749851Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Commit-Queue: Justin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513272}
parent b5762eb8
...@@ -114,8 +114,7 @@ constexpr int kMoleculeOrder[] = {0, 2, 3, 1}; ...@@ -114,8 +114,7 @@ constexpr int kMoleculeOrder[] = {0, 2, 3, 1};
} // namespace } // namespace
class VoiceInteractionIcon : public ui::Layer, class VoiceInteractionIcon : public ui::Layer {
public ui::CompositorAnimationObserver {
public: public:
VoiceInteractionIcon() : Layer(ui::LAYER_NOT_DRAWN) { VoiceInteractionIcon() : Layer(ui::LAYER_NOT_DRAWN) {
set_name("VoiceInteractionOverlay:ICON_LAYER"); set_name("VoiceInteractionOverlay:ICON_LAYER");
...@@ -127,32 +126,14 @@ class VoiceInteractionIcon : public ui::Layer, ...@@ -127,32 +126,14 @@ class VoiceInteractionIcon : public ui::Layer,
} }
void StartAnimation() { void StartAnimation() {
if (!GetCompositor()->HasAnimationObserver(this)) animation_timer_.Start(FROM_HERE,
GetCompositor()->AddAnimationObserver(this); base::TimeDelta::FromMilliseconds(
base::TimeTicks::kMillisecondsPerSecond /
gfx::LinearAnimation::kDefaultFrameRate),
this, &VoiceInteractionIcon::AnimationProgressed);
} }
void StopAnimation() { void StopAnimation() { animation_timer_.Stop(); }
if (GetCompositor()->HasAnimationObserver(this))
GetCompositor()->RemoveAnimationObserver(this);
}
// ui::CompositorAnimationObserver
void OnCompositingShuttingDown(ui::Compositor* compositor) override {}
void OnAnimationStep(base::TimeTicks timestamp) override {
uint64_t elapsed = (timestamp - base::TimeTicks()).InMilliseconds();
for (int i = 0; i < DOT_COUNT; ++i) {
float normalizedTime =
((elapsed - kMoleculeAnimationOffset * kMoleculeOrder[i]) %
kMoleculeAnimationDurationMs) /
static_cast<float>(kMoleculeAnimationDurationMs);
gfx::Transform transform;
transform.Translate(0,
kMoleculeAmplitude * sin(normalizedTime * 2 * M_PI));
dot_layers_[i]->SetTransform(transform);
}
}
private: private:
enum Dot { enum Dot {
...@@ -181,6 +162,25 @@ class VoiceInteractionIcon : public ui::Layer, ...@@ -181,6 +162,25 @@ class VoiceInteractionIcon : public ui::Layer,
return "UNKNOWN"; return "UNKNOWN";
} }
void AnimationProgressed() {
gfx::Transform transform;
uint64_t now =
(base::TimeTicks::Now() - base::TimeTicks()).InMilliseconds();
for (int i = 0; i < DOT_COUNT; ++i) {
float normalizedTime =
((now - kMoleculeAnimationOffset * kMoleculeOrder[i]) %
kMoleculeAnimationDurationMs) /
static_cast<float>(kMoleculeAnimationDurationMs);
transform.MakeIdentity();
transform.Translate(0,
kMoleculeAmplitude * sin(normalizedTime * 2 * M_PI));
dot_layers_[i]->SetTransform(transform);
}
}
/** /**
* Convenience method to place dots to Molecule shape used by Molecule * Convenience method to place dots to Molecule shape used by Molecule
* animations. * animations.
...@@ -209,6 +209,8 @@ class VoiceInteractionIcon : public ui::Layer, ...@@ -209,6 +209,8 @@ class VoiceInteractionIcon : public ui::Layer,
std::unique_ptr<ui::Layer> dot_layers_[DOT_COUNT]; std::unique_ptr<ui::Layer> dot_layers_[DOT_COUNT];
std::unique_ptr<views::CircleLayerDelegate> dot_layer_delegates_[DOT_COUNT]; std::unique_ptr<views::CircleLayerDelegate> dot_layer_delegates_[DOT_COUNT];
base::RepeatingTimer animation_timer_;
DISALLOW_COPY_AND_ASSIGN(VoiceInteractionIcon); DISALLOW_COPY_AND_ASSIGN(VoiceInteractionIcon);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment