Chromium Code Reviews| Index: ash/display/display_configuration_controller.h |
| diff --git a/ash/display/display_configuration_controller.h b/ash/display/display_configuration_controller.h |
| index 03563a28a6624c93b9b9db3f0fe70452fbee9e02..1128cce851205632b185e521bb35dc0608978557 100644 |
| --- a/ash/display/display_configuration_controller.h |
| +++ b/ash/display/display_configuration_controller.h |
| @@ -9,6 +9,7 @@ |
| #include "ash/ash_export.h" |
| #include "ash/display/window_tree_host_manager.h" |
| +#include "ash/rotator/screen_rotation_animator_observer.h" |
| #include "base/macros.h" |
| #include "base/memory/weak_ptr.h" |
| #include "ui/display/display.h" |
| @@ -21,10 +22,11 @@ class DisplayManager; |
| namespace ash { |
| namespace test { |
| -class ShellTestApi; |
| +class DisplayConfigurationControllerTestApi; |
| } // namespace test |
| class DisplayAnimator; |
| +class ScreenRotationAnimator; |
| // This class controls Display related configuration. Specifically it: |
| // * Handles animated transitions where appropriate. |
| @@ -32,7 +34,8 @@ class DisplayAnimator; |
| // * Provides a single interface for UI and API classes. |
| // * TODO: Forwards display configuration changed events to UI and API classes. |
| class ASH_EXPORT DisplayConfigurationController |
| - : public WindowTreeHostManager::Observer { |
| + : public WindowTreeHostManager::Observer, |
| + public ScreenRotationAnimatorObserver { |
| public: |
| DisplayConfigurationController( |
| display::DisplayManager* display_manager, |
| @@ -59,8 +62,12 @@ class ASH_EXPORT DisplayConfigurationController |
| // WindowTreeHostManager::Observer |
| void OnDisplayConfigurationChanged() override; |
| + // ScreenRotationAnimatorObserver |
| + void OnEndedOrAbortedScreenRotationAnimation( |
|
oshima
2017/03/16 20:13:09
OnRotationAnimationFinished. then document that it
wutao
2017/03/17 00:01:03
Changed to OnScreenRotationAnimationFinished
|
| + ScreenRotationAnimator* animator) override; |
| + |
| protected: |
| - friend class ash::test::ShellTestApi; |
| + friend class ash::test::DisplayConfigurationControllerTestApi; |
| // Allow tests to skip animations. |
| void ResetAnimatorForTest(); |
| @@ -76,11 +83,35 @@ class ASH_EXPORT DisplayConfigurationController |
| void SetMirrorModeImpl(bool mirror); |
| void SetPrimaryDisplayIdImpl(int64_t display_id); |
| + // Returns true if the screen rotation animation can be completed |
| + // successfully. For example an animation is not possible if |display_id_| |
| + // specifies a display::Display that is not currently active. See |
| + // www.crbug.com/479503. |
| + bool CanAnimateScreenRotation(int64_t display_id) const; |
| + |
| + // Returns the currently active rotation for the display with |display_id|. If |
| + // an animation is in progress, the target rotation will be returned. |
| + display::Display::Rotation GetCurrentScreenRotation(int64_t display_id) const; |
| + |
| + // Returns the ScreenRotationAnimator associated with the |display_id|. If |
| + // there is no existing ScreenRotationAnimator for |display_id|, it will make |
| + // one and store the pair in the |rotation_animator_map_|. |
| + ScreenRotationAnimator* GetScreenRotationAnimatorForDisplay( |
| + int64_t display_id); |
| + |
| display::DisplayManager* display_manager_; // weak ptr |
| WindowTreeHostManager* window_tree_host_manager_; // weak ptr |
| std::unique_ptr<DisplayAnimator> display_animator_; |
| std::unique_ptr<DisplayChangeLimiter> limiter_; |
| + // Tracks |display_id| to ScreenRotationAnimator mappings. The |
| + // |rotation_animator_map_| is populated on demand the first time a |
| + // ScreenRotationAnimator is needed for a given |display_id|. |
| + // On animation ended or aborted, the animator may be deleted if there is no |
| + // more pending rotation request. |
| + std::unordered_map<int64_t, std::unique_ptr<ScreenRotationAnimator>> |
| + rotation_animator_map_; |
| + |
| base::WeakPtrFactory<DisplayConfigurationController> weak_ptr_factory_; |
| DISALLOW_COPY_AND_ASSIGN(DisplayConfigurationController); |