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

Side by Side Diff: ash/wm/screen_dimmer.h

Issue 2332893002: Changes ownership of ScreenDimmer (Closed)
Patch Set: merge to tot Created 4 years, 3 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
« no previous file with comments | « no previous file | ash/wm/screen_dimmer.cc » ('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 #ifndef ASH_WM_SCREEN_DIMMER_H_ 5 #ifndef ASH_WM_SCREEN_DIMMER_H_
6 #define ASH_WM_SCREEN_DIMMER_H_ 6 #define ASH_WM_SCREEN_DIMMER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector>
9 10
10 #include "ash/ash_export.h" 11 #include "ash/ash_export.h"
11 #include "ash/common/shell_observer.h" 12 #include "ash/common/shell_observer.h"
12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "ui/aura/window_observer.h"
15
16 namespace ui {
17 class Layer;
18 }
19 14
20 namespace ash { 15 namespace ash {
21 namespace test { 16 namespace test {
22 class ScreenDimmerTest; 17 class ScreenDimmerTest;
23 } 18 }
24 19
25 class WindowDimmer; 20 class WindowDimmer;
26 21
27 template <typename UserData> 22 template <typename UserData>
28 class WmWindowUserData; 23 class WmWindowUserData;
29 24
30 // ScreenDimmer displays a partially-opaque layer above everything 25 // ScreenDimmer displays a partially-opaque layer above everything
31 // else in the given container window to darken the display. It shouldn't be 26 // else in the given container window to darken the display. It shouldn't be
32 // used for long-term brightness adjustments due to performance 27 // used for long-term brightness adjustments due to performance
33 // considerations -- it's only intended for cases where we want to 28 // considerations -- it's only intended for cases where we want to
34 // briefly dim the screen (e.g. to indicate to the user that we're 29 // briefly dim the screen (e.g. to indicate to the user that we're
35 // about to suspend a machine that lacks an internal backlight that 30 // about to suspend a machine that lacks an internal backlight that
36 // can be adjusted). 31 // can be adjusted).
37 class ASH_EXPORT ScreenDimmer : public ShellObserver { 32 class ASH_EXPORT ScreenDimmer : public ShellObserver {
38 public: 33 public:
39 // Creates a screen dimmer for the containers given by |container_id|. 34 // Indicates the container ScreenDimmer operates on.
40 // It's owned by the container in the primary root window and will be 35 enum class Container {
41 // destroyed when the container is destroyed. 36 ROOT,
42 static ScreenDimmer* GetForContainer(int container_id); 37 LOCK_SCREEN,
38 };
43 39
44 // Creates a dimmer a root window level. This is used for suspend animation. 40 explicit ScreenDimmer(Container container);
45 static ScreenDimmer* GetForRoot();
46
47 ~ScreenDimmer() override; 41 ~ScreenDimmer() override;
48 42
49 // Dim or undim the layers. 43 // Dim or undim the layers.
50 void SetDimming(bool should_dim); 44 void SetDimming(bool should_dim);
51 45
52 void set_at_bottom(bool at_bottom) { at_bottom_ = at_bottom; } 46 void set_at_bottom(bool at_bottom) { at_bottom_ = at_bottom; }
53 47
54 bool is_dimming() const { return is_dimming_; } 48 bool is_dimming() const { return is_dimming_; }
55 49
56 // Find a ScreenDimmer in the container, or nullptr if it does not exist. 50 // Find a ScreenDimmer in the container, or nullptr if it does not exist.
57 static ScreenDimmer* FindForTest(int container_id); 51 static ScreenDimmer* FindForTest(int container_id);
58 52
59 private: 53 private:
60 friend class test::ScreenDimmerTest; 54 friend class test::ScreenDimmerTest;
61 55
62 explicit ScreenDimmer(int container_id); 56 // Returns the WmWindows (one per display) that correspond to |container_|.
57 std::vector<WmWindow*> GetAllContainers();
63 58
64 // ShellObserver: 59 // ShellObserver:
65 void OnRootWindowAdded(WmWindow* root_window) override; 60 void OnRootWindowAdded(WmWindow* root_window) override;
66 61
67 // Update the dimming state. This will also create a new DimWindow 62 // Update the dimming state. This will also create a new DimWindow
68 // if necessary. (Used when a new display is connected) 63 // if necessary. (Used when a new display is connected)
69 void Update(bool should_dim); 64 void Update(bool should_dim);
70 65
71 int container_id_; 66 const Container container_;
72 float target_opacity_;
73 67
74 // Are we currently dimming the screen? 68 // Are we currently dimming the screen?
75 bool is_dimming_; 69 bool is_dimming_;
76 bool at_bottom_; 70 bool at_bottom_;
77 71
78 // Owns the WindowDimmers. 72 // Owns the WindowDimmers.
79 std::unique_ptr<WmWindowUserData<WindowDimmer>> window_dimmers_; 73 std::unique_ptr<WmWindowUserData<WindowDimmer>> window_dimmers_;
80 74
81 DISALLOW_COPY_AND_ASSIGN(ScreenDimmer); 75 DISALLOW_COPY_AND_ASSIGN(ScreenDimmer);
82 }; 76 };
83 77
84 } // namespace ash 78 } // namespace ash
85 79
86 #endif // ASH_WM_SCREEN_DIMMER_H_ 80 #endif // ASH_WM_SCREEN_DIMMER_H_
OLDNEW
« no previous file with comments | « no previous file | ash/wm/screen_dimmer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698