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

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

Issue 10205013: Reland "Fix wallpaper fade animation flashing problem" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix issue Created 8 years, 8 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
« no previous file with comments | « ash/desktop_background/desktop_background_controller.cc ('k') | ash/shell_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/shell.h" 10 #include "ash/shell.h"
11 #include "ash/shell_window_ids.h" 11 #include "ash/shell_window_ids.h"
12 #include "ash/wm/root_window_layout_manager.h"
12 #include "ash/wm/window_animations.h" 13 #include "ash/wm/window_animations.h"
14 #include "base/message_loop.h"
13 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
14 #include "grit/ui_resources.h" 16 #include "grit/ui_resources.h"
15 #include "ui/aura/root_window.h" 17 #include "ui/aura/root_window.h"
16 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/compositor/layer.h"
21 #include "ui/gfx/compositor/layer_animation_observer.h"
22 #include "ui/gfx/compositor/scoped_layer_animation_settings.h"
18 #include "ui/gfx/image/image.h" 23 #include "ui/gfx/image/image.h"
19 #include "ui/views/widget/widget.h" 24 #include "ui/views/widget/widget.h"
20 25
21 namespace ash { 26 namespace ash {
22 namespace internal { 27 namespace internal {
28 namespace {
29
30 class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver {
31 public:
32 explicit ShowWallpaperAnimationObserver(views::Widget* desktop_widget)
33 : desktop_widget_(desktop_widget) {
34 }
35
36 virtual ~ShowWallpaperAnimationObserver() {
37 }
38
39 private:
40 // Overridden from ui::ImplicitAnimationObserver:
41 virtual void OnImplicitAnimationsCompleted() OVERRIDE {
42 internal::RootWindowLayoutManager* root_window_layout =
43 Shell::GetInstance()->root_window_layout();
44 root_window_layout->SetBackgroundWidget(desktop_widget_);
45 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
46 }
47
48 views::Widget* desktop_widget_;
49
50 DISALLOW_COPY_AND_ASSIGN(ShowWallpaperAnimationObserver);
51 };
52
53 } // namespace
23 54
24 // For our scaling ratios we need to round positive numbers. 55 // For our scaling ratios we need to round positive numbers.
25 static int RoundPositive(double x) { 56 static int RoundPositive(double x) {
26 return static_cast<int>(floor(x + 0.5)); 57 return static_cast<int>(floor(x + 0.5));
27 } 58 }
28 59
29 //////////////////////////////////////////////////////////////////////////////// 60 ////////////////////////////////////////////////////////////////////////////////
30 // DesktopBackgroundView, public: 61 // DesktopBackgroundView, public:
31 62
32 DesktopBackgroundView::DesktopBackgroundView(const SkBitmap& wallpaper, 63 DesktopBackgroundView::DesktopBackgroundView(const SkBitmap& wallpaper,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 120
90 bool DesktopBackgroundView::OnMousePressed(const views::MouseEvent& event) { 121 bool DesktopBackgroundView::OnMousePressed(const views::MouseEvent& event) {
91 return true; 122 return true;
92 } 123 }
93 124
94 void DesktopBackgroundView::OnMouseReleased(const views::MouseEvent& event) { 125 void DesktopBackgroundView::OnMouseReleased(const views::MouseEvent& event) {
95 if (event.IsRightMouseButton()) 126 if (event.IsRightMouseButton())
96 Shell::GetInstance()->ShowBackgroundMenu(GetWidget(), event.location()); 127 Shell::GetInstance()->ShowBackgroundMenu(GetWidget(), event.location());
97 } 128 }
98 129
99 views::Widget* CreateDesktopBackground(const SkBitmap& wallpaper, 130 void CreateDesktopBackground(const SkBitmap& wallpaper, ImageLayout layout) {
100 ImageLayout layout) {
101 views::Widget* desktop_widget = new views::Widget; 131 views::Widget* desktop_widget = new views::Widget;
102 views::Widget::InitParams params( 132 views::Widget::InitParams params(
103 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 133 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
104 DesktopBackgroundView* view = new DesktopBackgroundView(wallpaper, layout); 134 DesktopBackgroundView* view = new DesktopBackgroundView(wallpaper, layout);
105 params.delegate = view; 135 params.delegate = view;
106 params.parent = 136 params.parent =
107 Shell::GetInstance()->GetContainer( 137 Shell::GetInstance()->GetContainer(
108 ash::internal::kShellWindowId_DesktopBackgroundContainer); 138 ash::internal::kShellWindowId_DesktopBackgroundContainer);
109 desktop_widget->Init(params); 139 desktop_widget->Init(params);
110 desktop_widget->SetContentsView(view); 140 desktop_widget->SetContentsView(view);
111 ash::SetWindowVisibilityAnimationType( 141 ash::SetWindowVisibilityAnimationType(
112 desktop_widget->GetNativeView(), 142 desktop_widget->GetNativeView(),
113 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); 143 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
144 ash::SetWindowVisibilityAnimationTransition(
145 desktop_widget->GetNativeView(),
146 ash::ANIMATE_SHOW);
114 desktop_widget->SetBounds(params.parent->bounds()); 147 desktop_widget->SetBounds(params.parent->bounds());
148 ui::ScopedLayerAnimationSettings settings(desktop_widget->GetNativeView()->
149 layer()->GetAnimator());
150 settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
151 settings.AddObserver(new ShowWallpaperAnimationObserver(desktop_widget));
115 desktop_widget->Show(); 152 desktop_widget->Show();
116 desktop_widget->GetNativeView()->SetName("DesktopBackgroundView"); 153 desktop_widget->GetNativeView()->SetName("DesktopBackgroundView");
117 return desktop_widget;
118 } 154 }
119 155
120 } // namespace internal 156 } // namespace internal
121 } // namespace ash 157 } // namespace ash
OLDNEW
« no previous file with comments | « ash/desktop_background/desktop_background_controller.cc ('k') | ash/shell_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698