| 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 { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 static constexpr int kVisibilityTimeoutMs = 200; | 14 static constexpr int kVisibilityTimeoutMs = 200; |
| 15 } | 15 } |
| 16 | 16 |
| 17 LoadingIndicator::LoadingIndicator(int preferred_width) | 17 LoadingIndicator::LoadingIndicator(int preferred_width) |
| 18 : TexturedElement(preferred_width), | 18 : TexturedElement(preferred_width), |
| 19 texture_(base::MakeUnique<LoadingIndicatorTexture>()) {} | 19 texture_(base::MakeUnique<LoadingIndicatorTexture>()) { |
| 20 set_visible(false); |
| 21 } |
| 20 | 22 |
| 21 LoadingIndicator::~LoadingIndicator() = default; | 23 LoadingIndicator::~LoadingIndicator() = default; |
| 22 | 24 |
| 23 UiTexture* LoadingIndicator::GetTexture() const { | 25 UiTexture* LoadingIndicator::GetTexture() const { |
| 24 return texture_.get(); | 26 return texture_.get(); |
| 25 } | 27 } |
| 26 | 28 |
| 27 void LoadingIndicator::SetEnabled(bool enabled) { | 29 void LoadingIndicator::SetEnabled(bool enabled) { |
| 28 if (enabled_ == enabled) | 30 if (enabled_ == enabled) |
| 29 return; | 31 return; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 59 void LoadingIndicator::SetVisibility() { | 61 void LoadingIndicator::SetVisibility() { |
| 60 set_visible(enabled_ && (loading_ || visibility_timer_.IsRunning())); | 62 set_visible(enabled_ && (loading_ || visibility_timer_.IsRunning())); |
| 61 } | 63 } |
| 62 | 64 |
| 63 void LoadingIndicator::OnBeginFrame(const base::TimeTicks& ticks) { | 65 void LoadingIndicator::OnBeginFrame(const base::TimeTicks& ticks) { |
| 64 if (enabled_ && texture_->dirty()) | 66 if (enabled_ && texture_->dirty()) |
| 65 UpdateTexture(); | 67 UpdateTexture(); |
| 66 } | 68 } |
| 67 | 69 |
| 68 } // namespace vr_shell | 70 } // namespace vr_shell |
| OLD | NEW |