Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 #include "ui/aura/test/test_windows.h" | 24 #include "ui/aura/test/test_windows.h" |
| 25 #include "ui/aura/test/window_test_api.h" | 25 #include "ui/aura/test/window_test_api.h" |
| 26 #include "ui/aura/window_delegate.h" | 26 #include "ui/aura/window_delegate.h" |
| 27 #include "ui/aura/window_event_dispatcher.h" | 27 #include "ui/aura/window_event_dispatcher.h" |
| 28 #include "ui/aura/window_observer.h" | 28 #include "ui/aura/window_observer.h" |
| 29 #include "ui/aura/window_property.h" | 29 #include "ui/aura/window_property.h" |
| 30 #include "ui/aura/window_tree_host.h" | 30 #include "ui/aura/window_tree_host.h" |
| 31 #include "ui/base/hit_test.h" | 31 #include "ui/base/hit_test.h" |
| 32 #include "ui/compositor/layer.h" | 32 #include "ui/compositor/layer.h" |
| 33 #include "ui/compositor/layer_animation_observer.h" | 33 #include "ui/compositor/layer_animation_observer.h" |
| 34 #include "ui/compositor/paint_context.h" | 34 #include "ui/compositor/paint_recorder.h" |
|
sadrul
2015/04/07 21:10:13
Perhaps this include isn't necessary at all?
danakj
2015/04/07 21:11:48
Oh, seems not!
| |
| 35 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 35 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 36 #include "ui/compositor/scoped_layer_animation_settings.h" | 36 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 37 #include "ui/compositor/test/test_layers.h" | 37 #include "ui/compositor/test/test_layers.h" |
| 38 #include "ui/events/event.h" | 38 #include "ui/events/event.h" |
| 39 #include "ui/events/event_utils.h" | 39 #include "ui/events/event_utils.h" |
| 40 #include "ui/events/gesture_detection/gesture_configuration.h" | 40 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 41 #include "ui/events/keycodes/keyboard_codes.h" | 41 #include "ui/events/keycodes/keyboard_codes.h" |
| 42 #include "ui/events/test/event_generator.h" | 42 #include "ui/events/test/event_generator.h" |
| 43 #include "ui/gfx/canvas.h" | 43 #include "ui/gfx/canvas.h" |
| 44 #include "ui/gfx/geometry/vector2d.h" | 44 #include "ui/gfx/geometry/vector2d.h" |
| (...skipping 2789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2834 o.ValidateState(index++, params); | 2834 o.ValidateState(index++, params); |
| 2835 | 2835 |
| 2836 w1.reset(); | 2836 w1.reset(); |
| 2837 w2.reset(); | 2837 w2.reset(); |
| 2838 } | 2838 } |
| 2839 | 2839 |
| 2840 } | 2840 } |
| 2841 | 2841 |
| 2842 namespace { | 2842 namespace { |
| 2843 | 2843 |
| 2844 // Tracks the number of times paint is invoked along with what the clip and | |
| 2845 // translate was. | |
| 2846 class PaintWindowDelegate : public TestWindowDelegate { | |
| 2847 public: | |
| 2848 PaintWindowDelegate() : paint_count_(0) {} | |
| 2849 ~PaintWindowDelegate() override {} | |
| 2850 | |
| 2851 const gfx::Rect& most_recent_paint_clip_bounds() const { | |
| 2852 return most_recent_paint_clip_bounds_; | |
| 2853 } | |
| 2854 | |
| 2855 const gfx::Vector2d& most_recent_paint_matrix_offset() const { | |
| 2856 return most_recent_paint_matrix_offset_; | |
| 2857 } | |
| 2858 | |
| 2859 void clear_paint_count() { paint_count_ = 0; } | |
| 2860 int paint_count() const { return paint_count_; } | |
| 2861 | |
| 2862 // TestWindowDelegate:: | |
| 2863 void OnPaint(const ui::PaintContext& context) override { | |
| 2864 gfx::Canvas* canvas = context.canvas(); | |
| 2865 paint_count_++; | |
| 2866 canvas->GetClipBounds(&most_recent_paint_clip_bounds_); | |
| 2867 const SkMatrix& matrix = canvas->sk_canvas()->getTotalMatrix(); | |
| 2868 most_recent_paint_matrix_offset_ = gfx::Vector2d( | |
| 2869 SkScalarFloorToInt(matrix.getTranslateX()), | |
| 2870 SkScalarFloorToInt(matrix.getTranslateY())); | |
| 2871 } | |
| 2872 | |
| 2873 private: | |
| 2874 int paint_count_; | |
| 2875 gfx::Rect most_recent_paint_clip_bounds_; | |
| 2876 gfx::Vector2d most_recent_paint_matrix_offset_; | |
| 2877 | |
| 2878 DISALLOW_COPY_AND_ASSIGN(PaintWindowDelegate); | |
| 2879 }; | |
| 2880 | |
| 2881 } // namespace | |
| 2882 | |
| 2883 namespace { | |
| 2884 | |
| 2885 class TestLayerAnimationObserver : public ui::LayerAnimationObserver { | 2844 class TestLayerAnimationObserver : public ui::LayerAnimationObserver { |
| 2886 public: | 2845 public: |
| 2887 TestLayerAnimationObserver() | 2846 TestLayerAnimationObserver() |
| 2888 : animation_completed_(false), | 2847 : animation_completed_(false), |
| 2889 animation_aborted_(false) {} | 2848 animation_aborted_(false) {} |
| 2890 ~TestLayerAnimationObserver() override {} | 2849 ~TestLayerAnimationObserver() override {} |
| 2891 | 2850 |
| 2892 bool animation_completed() const { return animation_completed_; } | 2851 bool animation_completed() const { return animation_completed_; } |
| 2893 bool animation_aborted() const { return animation_aborted_; } | 2852 bool animation_aborted() const { return animation_aborted_; } |
| 2894 | 2853 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2962 | 2921 |
| 2963 EXPECT_TRUE(animator.get()); | 2922 EXPECT_TRUE(animator.get()); |
| 2964 EXPECT_FALSE(animator->is_animating()); | 2923 EXPECT_FALSE(animator->is_animating()); |
| 2965 EXPECT_TRUE(observer.animation_completed()); | 2924 EXPECT_TRUE(observer.animation_completed()); |
| 2966 EXPECT_FALSE(observer.animation_aborted()); | 2925 EXPECT_FALSE(observer.animation_aborted()); |
| 2967 animator->RemoveObserver(&observer); | 2926 animator->RemoveObserver(&observer); |
| 2968 } | 2927 } |
| 2969 | 2928 |
| 2970 } // namespace test | 2929 } // namespace test |
| 2971 } // namespace aura | 2930 } // namespace aura |
| OLD | NEW |