| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/loading_indicator.h" | 5 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/android/vr_shell/textures/loading_indicator_texture.h" | 8 #include "chrome/browser/android/vr_shell/textures/loading_indicator_texture.h" |
| 9 | 9 |
| 10 namespace vr_shell { | 10 namespace vr_shell { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 LoadingIndicator::~LoadingIndicator() = default; | 23 LoadingIndicator::~LoadingIndicator() = default; |
| 24 | 24 |
| 25 UiTexture* LoadingIndicator::GetTexture() const { | 25 UiTexture* LoadingIndicator::GetTexture() const { |
| 26 return texture_.get(); | 26 return texture_.get(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void LoadingIndicator::SetEnabled(bool enabled) { | 29 void LoadingIndicator::SetEnabled(bool enabled) { |
| 30 if (enabled_ == enabled) | 30 if (enabled_ == enabled) |
| 31 return; | 31 return; |
| 32 enabled_ = enabled; | 32 enabled_ = enabled; |
| 33 ResetVisibilityTimer(); | |
| 34 SetVisibility(); | 33 SetVisibility(); |
| 35 } | 34 } |
| 36 | 35 |
| 37 void LoadingIndicator::SetLoading(bool loading) { | 36 void LoadingIndicator::SetLoading(bool loading) { |
| 38 if (loading_ == loading) | 37 if (loading_ == loading) |
| 39 return; | 38 return; |
| 40 loading_ = loading; | 39 loading_ = loading; |
| 41 texture_->SetLoading(loading); | 40 texture_->SetLoading(loading); |
| 42 texture_->SetLoadProgress(0); | 41 texture_->SetLoadProgress(0); |
| 43 ResetVisibilityTimer(); | 42 ResetVisibilityTimer(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 61 void LoadingIndicator::SetVisibility() { | 60 void LoadingIndicator::SetVisibility() { |
| 62 set_visible(enabled_ && (loading_ || visibility_timer_.IsRunning())); | 61 set_visible(enabled_ && (loading_ || visibility_timer_.IsRunning())); |
| 63 } | 62 } |
| 64 | 63 |
| 65 void LoadingIndicator::OnBeginFrame(const base::TimeTicks& ticks) { | 64 void LoadingIndicator::OnBeginFrame(const base::TimeTicks& ticks) { |
| 66 if (enabled_) | 65 if (enabled_) |
| 67 UpdateTexture(); | 66 UpdateTexture(); |
| 68 } | 67 } |
| 69 | 68 |
| 70 } // namespace vr_shell | 69 } // namespace vr_shell |
| OLD | NEW |