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

Unified Diff: ash/rotator/screen_rotation_animator.h

Issue 2728803002: Handles users rotating screen too early (Closed)
Patch Set: Created 3 years, 10 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
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..a49a3dd47544341e9e1ff029d43378adb879ae4d 100644
--- a/ash/rotator/screen_rotation_animator.h
+++ b/ash/rotator/screen_rotation_animator.h
@@ -9,6 +9,8 @@
#include "ash/ash_export.h"
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "ui/compositor/layer_tree_owner.h"
#include "ui/display/display.h"
namespace ash {
@@ -16,14 +18,28 @@ namespace ash {
// Utility to perform a screen rotation with an animation.
class ASH_EXPORT ScreenRotationAnimator {
public:
+ class ASH_EXPORT ScreenRotationAnimatorObserver {
+ public:
+ ScreenRotationAnimatorObserver();
+ virtual void OnEndedOrAbortedAnimation(
+ base::WeakPtr<ScreenRotationAnimator> animator);
+
+ protected:
+ ~ScreenRotationAnimatorObserver();
+ };
+
+ struct ScreenRotationRequest {
+ ScreenRotationAnimator* animator;
+ int64_t display_id;
+ display::Display::Rotation initial_rotation;
+ display::Display::Rotation new_rotation;
+ display::Display::RotationSource source;
+ };
+
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;
+ display::Display::Rotation GetCurrentRotation() const;
// Rotates the display::Display specified by |display_id_| to the
// |new_rotation|
@@ -32,9 +48,32 @@ class ASH_EXPORT ScreenRotationAnimator {
void Rotate(display::Display::Rotation new_rotation,
display::Display::RotationSource source);
+ int64_t display_id() const;
bruthig 2017/03/02 18:25:45 You should inline the definition of simple getters
wutao 2017/03/03 02:45:52 I move the simple getters and setters in the .h.
+
+ bool is_animating() const;
+ void set_is_animating(bool rotating);
bruthig 2017/03/02 18:25:45 I think it is very odd that clients of the animato
wutao 2017/03/03 02:45:52 I was debating myself where is the best to reset i
+
+ ScreenRotationAnimatorObserver* observer() const;
+ void SetObserver(ScreenRotationAnimatorObserver* observer);
+ void RemoveObserver();
+
+ ui::LayerTreeOwner* old_layer_tree_owner() const;
+ void reset_old_layer_tree_owner();
+ void set_old_layer_tree_owner(ui::LayerTreeOwner* layer_tree_owner);
+
+ ScreenRotationRequest* last_pending_request() const;
+ void reset_last_pending_request();
+
+ base::WeakPtr<ScreenRotationAnimator> WeakPtr();
+
private:
// The id of the display to rotate.
int64_t display_id_;
+ bool is_animating_;
+ ScreenRotationAnimatorObserver* observer_;
+ 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);
};

Powered by Google App Engine
This is Rietveld 408576698