display_animator.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_DISPLAY_DISPLAY_ANIMATOR_H_
  5. #define ASH_DISPLAY_DISPLAY_ANIMATOR_H_
  6. #include <map>
  7. #include <memory>
  8. #include "ash/ash_export.h"
  9. #include "base/callback.h"
  10. #include "base/memory/weak_ptr.h"
  11. #include "base/timer/timer.h"
  12. #include "ui/display/manager/display_configurator.h"
  13. namespace aura {
  14. class Window;
  15. } // namespace aura
  16. namespace ui {
  17. class Layer;
  18. } // namespace ui
  19. namespace ash {
  20. // DisplayAnimator provides the visual effects for
  21. // display::DisplayConfigurator, such like fade-out/in during changing
  22. // the display mode.
  23. class ASH_EXPORT DisplayAnimator
  24. : public display::DisplayConfigurator::Observer {
  25. public:
  26. DisplayAnimator();
  27. DisplayAnimator(const DisplayAnimator&) = delete;
  28. DisplayAnimator& operator=(const DisplayAnimator&) = delete;
  29. ~DisplayAnimator() override;
  30. void StartFadeOutAnimation(base::OnceClosure callback);
  31. void StartFadeInAnimation();
  32. protected:
  33. // display::DisplayConfigurator::Observer overrides:
  34. void OnDisplayModeChanged(
  35. const display::DisplayConfigurator::DisplayStateList& outputs) override;
  36. void OnDisplayModeChangeFailed(
  37. const display::DisplayConfigurator::DisplayStateList& displays,
  38. display::MultipleDisplayState failed_new_state) override;
  39. private:
  40. // Clears all hiding layers. Note that in case that this method is called
  41. // during an animation, the method call will cancel all of the animations
  42. // and *not* call the registered callback.
  43. void ClearHidingLayers();
  44. std::map<aura::Window*, std::unique_ptr<ui::Layer>> hiding_layers_;
  45. std::unique_ptr<base::OneShotTimer> timer_;
  46. base::WeakPtrFactory<DisplayAnimator> weak_ptr_factory_{this};
  47. };
  48. } // namespace ash
  49. #endif // ASH_DISPLAY_DISPLAY_ANIMATOR_H_