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

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

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