OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/desktop_background/desktop_background_view.h" | 5 #include "ash/desktop_background/desktop_background_view.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "ash/ash_export.h" | 9 #include "ash/ash_export.h" |
10 #include "ash/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
| 11 #include "ash/desktop_background/desktop_background_widget_controller.h" |
11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
12 #include "ash/shell_window_ids.h" | 13 #include "ash/shell_window_ids.h" |
13 #include "ash/wm/window_animations.h" | 14 #include "ash/wm/window_animations.h" |
14 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
15 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
16 #include "grit/ui_resources.h" | 17 #include "grit/ui_resources.h" |
17 #include "ui/aura/root_window.h" | 18 #include "ui/aura/root_window.h" |
18 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
19 #include "ui/compositor/layer.h" | 20 #include "ui/compositor/layer.h" |
20 #include "ui/compositor/layer_animation_observer.h" | 21 #include "ui/compositor/layer_animation_observer.h" |
(...skipping 15 matching lines...) Expand all Loading... |
36 container_id_(container_id), | 37 container_id_(container_id), |
37 desktop_widget_(desktop_widget) { | 38 desktop_widget_(desktop_widget) { |
38 } | 39 } |
39 | 40 |
40 virtual ~ShowWallpaperAnimationObserver() { | 41 virtual ~ShowWallpaperAnimationObserver() { |
41 } | 42 } |
42 | 43 |
43 private: | 44 private: |
44 // Overridden from ui::ImplicitAnimationObserver: | 45 // Overridden from ui::ImplicitAnimationObserver: |
45 virtual void OnImplicitAnimationsCompleted() OVERRIDE { | 46 virtual void OnImplicitAnimationsCompleted() OVERRIDE { |
46 ash::Shell::GetInstance()-> | 47 ash::Shell* shell = ash::Shell::GetInstance(); |
47 user_wallpaper_delegate()->OnWallpaperAnimationFinished(); | 48 shell->user_wallpaper_delegate()->OnWallpaperAnimationFinished(); |
| 49 // Only removes old component when wallpaper animation finished. If we |
| 50 // remove the old one too early, there will be a white flash during |
| 51 // animation. |
| 52 if (root_window_->GetProperty(kComponentWrapper)) { |
| 53 internal::DesktopBackgroundWidgetController* component = |
| 54 root_window_->GetProperty(kComponentWrapper)->component(); |
| 55 root_window_->SetProperty(kWindowDesktopComponent, component); |
| 56 } |
48 | 57 |
49 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 58 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
50 } | 59 } |
51 | 60 |
52 aura::RootWindow* root_window_; | 61 aura::RootWindow* root_window_; |
53 int container_id_; | 62 int container_id_; |
54 views::Widget* desktop_widget_; | 63 views::Widget* desktop_widget_; |
55 | 64 |
56 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver); | 65 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver); |
57 }; | 66 }; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 params.delegate = view; | 155 params.delegate = view; |
147 if (controller->GetWallpaper().empty()) | 156 if (controller->GetWallpaper().empty()) |
148 params.transparent = true; | 157 params.transparent = true; |
149 params.parent = root_window->GetChildById(container_id); | 158 params.parent = root_window->GetChildById(container_id); |
150 desktop_widget->Init(params); | 159 desktop_widget->Init(params); |
151 desktop_widget->SetContentsView(view); | 160 desktop_widget->SetContentsView(view); |
152 ash::WindowVisibilityAnimationType animation_type = | 161 ash::WindowVisibilityAnimationType animation_type = |
153 ash::Shell::GetInstance()->user_wallpaper_delegate()->GetAnimationType(); | 162 ash::Shell::GetInstance()->user_wallpaper_delegate()->GetAnimationType(); |
154 ash::SetWindowVisibilityAnimationType(desktop_widget->GetNativeView(), | 163 ash::SetWindowVisibilityAnimationType(desktop_widget->GetNativeView(), |
155 animation_type); | 164 animation_type); |
156 ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(), | 165 // Disable animation when creating the first widget. Otherwise, wallpaper |
157 ash::ANIMATE_SHOW); | 166 // will animate from a white screen. Note that boot animation is different. |
| 167 // It animates from a white background. |
| 168 if (animation_type == ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE && |
| 169 NULL == root_window->GetProperty(internal::kComponentWrapper)) { |
| 170 ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(), |
| 171 ash::ANIMATE_NONE); |
| 172 } else { |
| 173 ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(), |
| 174 ash::ANIMATE_SHOW); |
| 175 } |
158 desktop_widget->SetBounds(params.parent->bounds()); | 176 desktop_widget->SetBounds(params.parent->bounds()); |
159 ui::ScopedLayerAnimationSettings settings( | 177 ui::ScopedLayerAnimationSettings settings( |
160 desktop_widget->GetNativeView()->layer()->GetAnimator()); | 178 desktop_widget->GetNativeView()->layer()->GetAnimator()); |
161 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); | 179 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); |
162 settings.AddObserver(new ShowWallpaperAnimationObserver(root_window, | 180 settings.AddObserver(new ShowWallpaperAnimationObserver(root_window, |
163 container_id, | 181 container_id, |
164 desktop_widget)); | 182 desktop_widget)); |
165 desktop_widget->Show(); | 183 desktop_widget->Show(); |
166 desktop_widget->GetNativeView()->SetName("DesktopBackgroundView"); | 184 desktop_widget->GetNativeView()->SetName("DesktopBackgroundView"); |
167 return desktop_widget; | 185 return desktop_widget; |
168 } | 186 } |
169 | 187 |
170 } // namespace internal | 188 } // namespace internal |
171 } // namespace ash | 189 } // namespace ash |
OLD | NEW |