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

Side by Side Diff: ash/desktop_background/desktop_background_widget_controller.h

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: Sky's review 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 #ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_ 5 #ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_
6 #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_ 6 #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "ui/aura/window_property.h" 9 #include "ui/aura/window_property.h"
10 #include "ui/compositor/layer.h" 10 #include "ui/compositor/layer.h"
11 #include "ui/views/widget/widget.h" 11 #include "ui/views/widget/widget.h"
12 12
13 namespace ash { 13 namespace ash {
14 namespace internal { 14 namespace internal {
15 15
16 // This class hides difference between two possible background implementations: 16 // This class hides difference between two possible background implementations:
17 // effective Layer-based for solid color, and Widget-based for images. 17 // effective Layer-based for solid color, and Widget-based for images.
18 class DesktopBackgroundWidgetController { 18 class DesktopBackgroundWidgetController {
19 public: 19 public:
20 // Create 20 // Create
21 explicit DesktopBackgroundWidgetController(views::Widget* widget); 21 explicit DesktopBackgroundWidgetController(views::Widget* widget);
22 explicit DesktopBackgroundWidgetController(ui::Layer* layer); 22 explicit DesktopBackgroundWidgetController(ui::Layer* layer);
23 23
24 // When set kWindowDesktopComponent property from root window, this
25 // desctructor is called. It immediately remove the widget or layer it
sky 2012/08/13 17:31:05 Move this to the class level. Also, its rather con
bshe 2012/08/13 18:28:22 Done.
26 // contains. On wallpaper change, if set property is called immediately after
27 // a new component is created. The old widget or layer will removed
28 // immediately. And a white screen will show. The new wallpaper will fade in
29 // from the white screen, which gives white flash from users' perspective.
24 ~DesktopBackgroundWidgetController(); 30 ~DesktopBackgroundWidgetController();
25 31
26 // Set bounds of component that draws background. 32 // Set bounds of component that draws background.
27 void SetBounds(gfx::Rect bounds); 33 void SetBounds(gfx::Rect bounds);
28 34
29 // Move component from |src_container| in |root_window| to |dest_container|. 35 // Move component from |src_container| in |root_window| to |dest_container|.
30 // It is required for lock screen, when we need to move background so that 36 // It is required for lock screen, when we need to move background so that
31 // it hides user's windows. 37 // it hides user's windows.
32 void Reparent(aura::RootWindow* root_window, 38 void Reparent(aura::RootWindow* root_window,
33 int src_container, 39 int src_container,
34 int dest_container); 40 int dest_container);
35 41
36 views::Widget* widget() { return widget_; } 42 views::Widget* widget() { return widget_; }
37 ui::Layer* layer() { return layer_.get(); } 43 ui::Layer* layer() { return layer_.get(); }
38 44
39 private: 45 private:
40 views::Widget* widget_; 46 views::Widget* widget_;
41 scoped_ptr<ui::Layer> layer_; 47 scoped_ptr<ui::Layer> layer_;
42 48
43 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundWidgetController); 49 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundWidgetController);
44 }; 50 };
45 51
52 // This class wrappes a DesktopBackgroundWidgetController pointer. It is used to
sky 2012/08/13 17:31:05 wraps
bshe 2012/08/13 18:28:22 Done.
53 // save the pointer on kComponentWrapper property during the time
54 // DesktopBackgroundWidgetController initialized and wallpaper animation
55 // finished. After animation finished, the pointer in this class is set as
56 // kWindowDesktopComponent property. If we set the pointer immediately after it
57 // is created, a white flash will appear when changing wallpaper as described
58 // in the comment for ~DesktopBackgroundWidgetController.
59 class ComponentWrapper {
60 public:
61 explicit ComponentWrapper(
62 DesktopBackgroundWidgetController* component);
63 ~ComponentWrapper() {}
64 DesktopBackgroundWidgetController* component() { return component_; }
65
66 private:
67 DesktopBackgroundWidgetController* component_;
68 DISALLOW_COPY_AND_ASSIGN(ComponentWrapper);
sky 2012/08/13 17:31:05 nit: newline between 67/68.
bshe 2012/08/13 18:28:22 Done.
69 };
70
46 // Window property key, that binds instance of DesktopBackgroundWidgetController 71 // Window property key, that binds instance of DesktopBackgroundWidgetController
47 // to root windows. 72 // to root windows.
48 extern const aura::WindowProperty<DesktopBackgroundWidgetController*>* const 73 extern const aura::WindowProperty<DesktopBackgroundWidgetController*>* const
49 kWindowDesktopComponent; 74 kWindowDesktopComponent;
50 75
76 extern const aura::WindowProperty<ComponentWrapper*>* const kComponentWrapper;
77
51 } // namespace internal 78 } // namespace internal
52 } // namespace ash 79 } // namespace ash
53 80
54 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_ 81 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698