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 #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 // DesktopBackgroundWidgetController is installed as an owned property on the | |
19 // RootWindow. To avoid a white flash during wallpaper changes the old | |
20 // DesktopBackgroundWidgetController is moved to a secondary property | |
21 // (kComponentWrapper). When the animation completes the old | |
22 // DesktopBackgroundWidgetController is destroyed. | |
23 class DesktopBackgroundWidgetController { | 18 class DesktopBackgroundWidgetController { |
24 public: | 19 public: |
25 // Create | 20 // Create |
26 explicit DesktopBackgroundWidgetController(views::Widget* widget); | 21 explicit DesktopBackgroundWidgetController(views::Widget* widget); |
27 explicit DesktopBackgroundWidgetController(ui::Layer* layer); | 22 explicit DesktopBackgroundWidgetController(ui::Layer* layer); |
28 | 23 |
29 ~DesktopBackgroundWidgetController(); | 24 ~DesktopBackgroundWidgetController(); |
30 | 25 |
31 // Set bounds of component that draws background. | 26 // Set bounds of component that draws background. |
32 void SetBounds(gfx::Rect bounds); | 27 void SetBounds(gfx::Rect bounds); |
33 | 28 |
34 // Move component from |src_container| in |root_window| to |dest_container|. | 29 // Move component from |src_container| in |root_window| to |dest_container|. |
35 // It is required for lock screen, when we need to move background so that | 30 // It is required for lock screen, when we need to move background so that |
36 // it hides user's windows. | 31 // it hides user's windows. |
37 void Reparent(aura::RootWindow* root_window, | 32 void Reparent(aura::RootWindow* root_window, |
38 int src_container, | 33 int src_container, |
39 int dest_container); | 34 int dest_container); |
40 | 35 |
41 views::Widget* widget() { return widget_; } | 36 views::Widget* widget() { return widget_; } |
42 ui::Layer* layer() { return layer_.get(); } | 37 ui::Layer* layer() { return layer_.get(); } |
43 | 38 |
44 private: | 39 private: |
45 views::Widget* widget_; | 40 views::Widget* widget_; |
46 scoped_ptr<ui::Layer> layer_; | 41 scoped_ptr<ui::Layer> layer_; |
47 | 42 |
48 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundWidgetController); | 43 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundWidgetController); |
49 }; | 44 }; |
50 | 45 |
51 // This class wraps a DesktopBackgroundWidgetController pointer. It is installed | |
52 // as an owned property on the RootWindow. DesktopBackgroundWidgetController is | |
53 // moved to this property before animation completes. After animation completes, | |
54 // the kWindowDesktopComponent property on RootWindow is set to the | |
55 // DesktopBackgroundWidgetController in this class. | |
56 class ComponentWrapper { | |
57 public: | |
58 explicit ComponentWrapper( | |
59 DesktopBackgroundWidgetController* component); | |
60 ~ComponentWrapper() {} | |
61 DesktopBackgroundWidgetController* component() { return component_; } | |
62 | |
63 private: | |
64 DesktopBackgroundWidgetController* component_; | |
65 | |
66 DISALLOW_COPY_AND_ASSIGN(ComponentWrapper); | |
67 }; | |
68 | |
69 // Window property key, that binds instance of DesktopBackgroundWidgetController | 46 // Window property key, that binds instance of DesktopBackgroundWidgetController |
70 // to root windows. | 47 // to root windows. |
71 extern const aura::WindowProperty<DesktopBackgroundWidgetController*>* const | 48 extern const aura::WindowProperty<DesktopBackgroundWidgetController*>* const |
72 kWindowDesktopComponent; | 49 kWindowDesktopComponent; |
73 | 50 |
74 extern const aura::WindowProperty<ComponentWrapper*>* const kComponentWrapper; | |
75 | |
76 } // namespace internal | 51 } // namespace internal |
77 } // namespace ash | 52 } // namespace ash |
78 | 53 |
79 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_ | 54 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_ |
OLD | NEW |