OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CHROME_BROWSER_UI_COCOA_FULLSCREEN_LOW_POWER_COORDINATOR_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_FULLSCREEN_LOW_POWER_COORDINATOR_H_ |
6 #define CHROME_BROWSER_UI_COCOA_FULLSCREEN_LOW_POWER_COORDINATOR_H_ | 6 #define CHROME_BROWSER_UI_COCOA_FULLSCREEN_LOW_POWER_COORDINATOR_H_ |
7 | 7 |
8 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" | 8 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" |
9 #include "ui/accelerated_widget_mac/fullscreen_low_power_coordinator.h" | 9 #include "ui/accelerated_widget_mac/fullscreen_low_power_coordinator.h" |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 const NSRect& infobar_frame, | 35 const NSRect& infobar_frame, |
36 const NSRect& content_frame, | 36 const NSRect& content_frame, |
37 const NSRect& download_shelf_frame); | 37 const NSRect& download_shelf_frame); |
38 void SetHasActiveSheet(bool has_sheet); | 38 void SetHasActiveSheet(bool has_sheet); |
39 void ChildWindowsChanged(); | 39 void ChildWindowsChanged(); |
40 | 40 |
41 // ui::FullscreenLowPowerCoordinator implementation. | 41 // ui::FullscreenLowPowerCoordinator implementation. |
42 void SetLowPowerLayerValid(bool valid) override; | 42 void SetLowPowerLayerValid(bool valid) override; |
43 void WillLoseAcceleratedWidget() override; | 43 void WillLoseAcceleratedWidget() override; |
44 | 44 |
| 45 // Call EnterOrExitLowPowerModeIfNeeded to wind down counters. |
| 46 void TickEnterOrExitForTesting(); |
| 47 |
45 private: | 48 private: |
46 // Determine if we should be fullscreen low power mode, and enter or exit | 49 // Determine if we should be fullscreen low power mode, and enter or exit |
47 // the mode as needed. | 50 // the mode as needed. |
48 void EnterOrExitLowPowerModeIfNeeded(); | 51 void EnterOrExitLowPowerModeIfNeeded(); |
49 | 52 |
50 // The main fullscreen window. | 53 // The main fullscreen window. |
51 base::scoped_nsobject<NSWindow> content_window_; | 54 base::scoped_nsobject<NSWindow> content_window_; |
52 | 55 |
53 // Weak, reset by WillLoseAcceleratedWidget before it goes away. | 56 // Weak, reset by WillLoseAcceleratedWidget before it goes away. |
54 ui::AcceleratedWidgetMac* widget_ = nullptr; | 57 ui::AcceleratedWidgetMac* widget_ = nullptr; |
55 | 58 |
56 // The window that we will put in front of the main fullscreen window when we | 59 // The window that we will put in front of the main fullscreen window when we |
57 // can. | 60 // can. |
58 base::scoped_nsobject<FullscreenLowPowerWindow> low_power_window_; | 61 base::scoped_nsobject<FullscreenLowPowerWindow> low_power_window_; |
59 | 62 |
60 // Don't use the fullscreen low power window until we have completely | 63 // Don't use the fullscreen low power window until we have completely |
61 // transitioned to low power mode. | 64 // transitioned to low power mode. |
62 bool allowed_by_fullscreen_transition_ = false; | 65 bool allowed_by_fullscreen_transition_ = false; |
63 | 66 |
64 // Set by the AcceleratedWidgetHost with each frame. This must be true for | 67 // Set by the AcceleratedWidgetHost with each frame to indicate if the low |
65 // 15 consecutive frames to enter low power mode (this is to ensure that the | 68 // power layer's contents are valid. |
66 // low power window has actually updated to the correct content before it | 69 bool low_power_layer_valid_ = false; |
67 // appears). | |
68 uint64_t low_power_layer_valid_frame_count_ = 0; | |
69 | 70 |
70 // Set if the NSView hierarchy allows low power mode. Low power mode is only | 71 // Set if the NSView hierarchy allows low power mode. Low power mode is only |
71 // allowed when nothing but the web contents is on-screen. | 72 // allowed when nothing but the web contents is on-screen. |
72 bool allowed_by_nsview_layout_ = true; | 73 bool allowed_by_nsview_layout_ = true; |
73 | 74 |
74 // Set if there are no NSWindows that would be covered by the fullscreen low | 75 // Set if there are no NSWindows that would be covered by the fullscreen low |
75 // power window. | 76 // power window. |
76 bool allowed_by_child_windows_ = false; | 77 bool allowed_by_child_windows_ = false; |
77 | 78 |
78 // Set if there are no sheets (modal dialogues) that would be covered by the | 79 // Set if there are no sheets (modal dialogues) that would be covered by the |
79 // fullscreen low power window. | 80 // fullscreen low power window. |
80 bool allowed_by_active_sheet_ = false; | 81 bool allowed_by_active_sheet_ = false; |
81 | 82 |
82 // Updated by EnterOrExitLowPowerModeIfNeeded. | 83 // Updated by EnterOrExitLowPowerModeIfNeeded. |
83 bool in_low_power_mode_ = false; | 84 enum State { |
| 85 // The fullscreen low power window is hidden behind the main window. |
| 86 Disabled, |
| 87 // The fullscreen low power window is still hidden, but is counting up |
| 88 // transition frames before showing itself. |
| 89 WarmingUp, |
| 90 // The fullscreen low power window is in front of the main window. |
| 91 Enabled, |
| 92 }; |
| 93 State state_ = Disabled; |
| 94 uint64_t frames_in_state_ = 0; |
84 }; | 95 }; |
85 | 96 |
86 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_LOW_POWER_COORDINATOR_H_ | 97 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_LOW_POWER_COORDINATOR_H_ |
OLD | NEW |