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

Side by Side Diff: ash/desktop_background/desktop_background_view.cc

Issue 10827284: Fix white flash when user sings out and wallpaper animation regression (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 shell->desktop_background_controller()->
53 SetComponentForRootWindow(root_window_);
48 54
49 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 55 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
50 } 56 }
51 57
52 aura::RootWindow* root_window_; 58 aura::RootWindow* root_window_;
53 int container_id_; 59 int container_id_;
54 views::Widget* desktop_widget_; 60 views::Widget* desktop_widget_;
55 61
56 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver); 62 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver);
57 }; 63 };
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 params.delegate = view; 152 params.delegate = view;
147 if (controller->GetWallpaper().empty()) 153 if (controller->GetWallpaper().empty())
148 params.transparent = true; 154 params.transparent = true;
149 params.parent = root_window->GetChildById(container_id); 155 params.parent = root_window->GetChildById(container_id);
150 desktop_widget->Init(params); 156 desktop_widget->Init(params);
151 desktop_widget->SetContentsView(view); 157 desktop_widget->SetContentsView(view);
152 ash::WindowVisibilityAnimationType animation_type = 158 ash::WindowVisibilityAnimationType animation_type =
153 ash::Shell::GetInstance()->user_wallpaper_delegate()->GetAnimationType(); 159 ash::Shell::GetInstance()->user_wallpaper_delegate()->GetAnimationType();
154 ash::SetWindowVisibilityAnimationType(desktop_widget->GetNativeView(), 160 ash::SetWindowVisibilityAnimationType(desktop_widget->GetNativeView(),
155 animation_type); 161 animation_type);
156 ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(), 162 // Disable animation when creating the first widget. Otherwise, wallpaper
157 ash::ANIMATE_SHOW); 163 // will animate from a white screen. Note that boot animation is different.
164 // It animates from a white background.
165 if (animation_type == ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE &&
166 NULL == root_window->GetProperty(internal::kWindowDesktopComponent)) {
167 ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(),
168 ash::ANIMATE_NONE);
169 } else {
170 ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(),
171 ash::ANIMATE_SHOW);
172 }
158 desktop_widget->SetBounds(params.parent->bounds()); 173 desktop_widget->SetBounds(params.parent->bounds());
159 ui::ScopedLayerAnimationSettings settings( 174 ui::ScopedLayerAnimationSettings settings(
160 desktop_widget->GetNativeView()->layer()->GetAnimator()); 175 desktop_widget->GetNativeView()->layer()->GetAnimator());
161 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); 176 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
162 settings.AddObserver(new ShowWallpaperAnimationObserver(root_window, 177 settings.AddObserver(new ShowWallpaperAnimationObserver(root_window,
163 container_id, 178 container_id,
164 desktop_widget)); 179 desktop_widget));
165 desktop_widget->Show(); 180 desktop_widget->Show();
166 desktop_widget->GetNativeView()->SetName("DesktopBackgroundView"); 181 desktop_widget->GetNativeView()->SetName("DesktopBackgroundView");
167 return desktop_widget; 182 return desktop_widget;
168 } 183 }
169 184
170 } // namespace internal 185 } // namespace internal
171 } // namespace ash 186 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698