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

Unified Diff: ash/rotator/screen_rotation_animator.h

Issue 2728803002: Handles users rotating screen too early (Closed)
Patch Set: Rebased to commit. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/display/display_configuration_controller_unittest.cc ('k') | ash/rotator/screen_rotation_animator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/rotator/screen_rotation_animator.h
diff --git a/ash/rotator/screen_rotation_animator.h b/ash/rotator/screen_rotation_animator.h
index f5b25d69298505c1d7d3d14e4ecb3631b1cb791d..ac6f18a83569e0e1aeab745949ba9149bf5342fd 100644
--- a/ash/rotator/screen_rotation_animator.h
+++ b/ash/rotator/screen_rotation_animator.h
@@ -9,9 +9,21 @@
#include "ash/ash_export.h"
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/observer_list.h"
#include "ui/display/display.h"
+namespace ui {
+class Layer;
+class LayerTreeOwner;
+} // namespace ui
+
namespace ash {
+namespace test {
+class ScreenRotationAnimatorTestApi;
+} // namespace test
+
+class ScreenRotationAnimatorObserver;
// Utility to perform a screen rotation with an animation.
class ASH_EXPORT ScreenRotationAnimator {
@@ -19,22 +31,58 @@ class ASH_EXPORT ScreenRotationAnimator {
explicit ScreenRotationAnimator(int64_t display_id);
~ScreenRotationAnimator();
- // 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 CanAnimate() const;
-
// Rotates the display::Display specified by |display_id_| to the
- // |new_rotation|
- // orientation, for the given |source|. The rotation will also become active.
- // Clients should only call |Rotate()| if |CanAnimate()| returns true.
+ // |new_rotation| orientation, for the given |source|. The rotation will also
+ // become active. Should only be called when |display_id_| references a valid
+ // display::Display. |screen_rotation_animator_observer_| will be notified
+ // when rotation is finished and there is no more pending rotation request.
+ // Otherwise, any ongoing animation will be stopped and progressed to the
+ // target position, followed by a new |Rotate()| call with the pending
+ // rotation request.
void Rotate(display::Display::Rotation new_rotation,
display::Display::RotationSource source);
+ int64_t display_id() const { return display_id_; }
+
+ void AddScreenRotationAnimatorObserver(
+ ScreenRotationAnimatorObserver* observer);
+ void RemoveScreenRotationAnimatorObserver(
+ ScreenRotationAnimatorObserver* observer);
+
+ void OnLayerAnimationEnded();
+
+ void OnLayerAnimationAborted();
+
private:
+ friend class ash::test::ScreenRotationAnimatorTestApi;
+ struct ScreenRotationRequest;
+
+ // Set the screen orientation to |new_rotation| and animate the change. The
+ // animation will rotate the initial orientation's layer towards the new
+ // orientation through |rotation_degrees| while fading out, and the new
+ // orientation's layer will be rotated in to the |new_orientation| through
+ // |rotation_degrees| arc.
+ void AnimateRotation(std::unique_ptr<ScreenRotationRequest> rotation_request);
+
+ // When screen rotation animation is ended or aborted, if the request queue is
+ // not empty, it will call |Rotate()| with the pending rotation request.
+ // Otherwise it will notify |screen_rotation_animator_observer_|.
+ void ProcessAnimationQueue();
+
+ void set_disable_animation_timers_for_test(bool disable_timers);
+
+ void StopAnimating();
+
// The id of the display to rotate.
int64_t display_id_;
+ bool is_rotating_;
+ // Only set in unittest to disable animation timers.
+ bool disable_animation_timers_for_test_;
+ base::ObserverList<ScreenRotationAnimatorObserver>
+ screen_rotation_animator_observers_;
+ std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner_;
+ std::unique_ptr<ScreenRotationRequest> last_pending_request_;
+ base::WeakPtrFactory<ScreenRotationAnimator> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator);
};
« no previous file with comments | « ash/display/display_configuration_controller_unittest.cc ('k') | ash/rotator/screen_rotation_animator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698