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/scoped_animation_duration_scale_mode.h" | 35 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
35 #include "ui/compositor/scoped_layer_animation_settings.h" | 36 #include "ui/compositor/scoped_layer_animation_settings.h" |
36 #include "ui/compositor/test/test_layers.h" | 37 #include "ui/compositor/test/test_layers.h" |
37 #include "ui/events/event.h" | 38 #include "ui/events/event.h" |
38 #include "ui/events/event_utils.h" | 39 #include "ui/events/event_utils.h" |
39 #include "ui/events/gesture_detection/gesture_configuration.h" | 40 #include "ui/events/gesture_detection/gesture_configuration.h" |
40 #include "ui/events/keycodes/keyboard_codes.h" | 41 #include "ui/events/keycodes/keyboard_codes.h" |
41 #include "ui/events/test/event_generator.h" | 42 #include "ui/events/test/event_generator.h" |
42 #include "ui/gfx/canvas.h" | 43 #include "ui/gfx/canvas.h" |
43 #include "ui/gfx/geometry/vector2d.h" | 44 #include "ui/gfx/geometry/vector2d.h" |
(...skipping 2993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3037 } | 3038 } |
3038 | 3039 |
3039 const gfx::Vector2d& most_recent_paint_matrix_offset() const { | 3040 const gfx::Vector2d& most_recent_paint_matrix_offset() const { |
3040 return most_recent_paint_matrix_offset_; | 3041 return most_recent_paint_matrix_offset_; |
3041 } | 3042 } |
3042 | 3043 |
3043 void clear_paint_count() { paint_count_ = 0; } | 3044 void clear_paint_count() { paint_count_ = 0; } |
3044 int paint_count() const { return paint_count_; } | 3045 int paint_count() const { return paint_count_; } |
3045 | 3046 |
3046 // TestWindowDelegate:: | 3047 // TestWindowDelegate:: |
3047 void OnPaint(gfx::Canvas* canvas) override { | 3048 void OnPaint(const ui::PaintContext& context) override { |
| 3049 gfx::Canvas* canvas = context.canvas(); |
3048 paint_count_++; | 3050 paint_count_++; |
3049 canvas->GetClipBounds(&most_recent_paint_clip_bounds_); | 3051 canvas->GetClipBounds(&most_recent_paint_clip_bounds_); |
3050 const SkMatrix& matrix = canvas->sk_canvas()->getTotalMatrix(); | 3052 const SkMatrix& matrix = canvas->sk_canvas()->getTotalMatrix(); |
3051 most_recent_paint_matrix_offset_ = gfx::Vector2d( | 3053 most_recent_paint_matrix_offset_ = gfx::Vector2d( |
3052 SkScalarFloorToInt(matrix.getTranslateX()), | 3054 SkScalarFloorToInt(matrix.getTranslateX()), |
3053 SkScalarFloorToInt(matrix.getTranslateY())); | 3055 SkScalarFloorToInt(matrix.getTranslateY())); |
3054 } | 3056 } |
3055 | 3057 |
3056 private: | 3058 private: |
3057 int paint_count_; | 3059 int paint_count_; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3099 w111->Show(); | 3101 w111->Show(); |
3100 w11ll->AddChild(w111); | 3102 w11ll->AddChild(w111); |
3101 | 3103 |
3102 EXPECT_EQ(0, w1ll_delegate.paint_count()); | 3104 EXPECT_EQ(0, w1ll_delegate.paint_count()); |
3103 EXPECT_EQ(0, w11ll_delegate.paint_count()); | 3105 EXPECT_EQ(0, w11ll_delegate.paint_count()); |
3104 EXPECT_EQ(0, w111_delegate.paint_count()); | 3106 EXPECT_EQ(0, w111_delegate.paint_count()); |
3105 | 3107 |
3106 // Paint the root, this should trigger painting of the two layerless | 3108 // Paint the root, this should trigger painting of the two layerless |
3107 // descendants but not the layered descendant. | 3109 // descendants but not the layered descendant. |
3108 gfx::Canvas canvas(gfx::Size(200, 200), 1.0f, true); | 3110 gfx::Canvas canvas(gfx::Size(200, 200), 1.0f, true); |
3109 static_cast<ui::LayerDelegate&>(root).OnPaintLayer(&canvas); | 3111 static_cast<ui::LayerDelegate&>(root).OnPaintLayer(ui::PaintContext(&canvas)); |
3110 | 3112 |
3111 // NOTE: SkCanvas::getClipBounds() extends the clip 1 pixel to the left and up | 3113 // NOTE: SkCanvas::getClipBounds() extends the clip 1 pixel to the left and up |
3112 // and 2 pixels down and to the right. | 3114 // and 2 pixels down and to the right. |
3113 EXPECT_EQ(1, w1ll_delegate.paint_count()); | 3115 EXPECT_EQ(1, w1ll_delegate.paint_count()); |
3114 EXPECT_EQ("-1,-1 42x52", | 3116 EXPECT_EQ("-1,-1 42x52", |
3115 w1ll_delegate.most_recent_paint_clip_bounds().ToString()); | 3117 w1ll_delegate.most_recent_paint_clip_bounds().ToString()); |
3116 EXPECT_EQ("[1 2]", | 3118 EXPECT_EQ("[1 2]", |
3117 w1ll_delegate.most_recent_paint_matrix_offset().ToString()); | 3119 w1ll_delegate.most_recent_paint_matrix_offset().ToString()); |
3118 EXPECT_EQ(1, w11ll_delegate.paint_count()); | 3120 EXPECT_EQ(1, w11ll_delegate.paint_count()); |
3119 EXPECT_EQ("-1,-1 13x14", | 3121 EXPECT_EQ("-1,-1 13x14", |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3582 | 3584 |
3583 EXPECT_TRUE(animator.get()); | 3585 EXPECT_TRUE(animator.get()); |
3584 EXPECT_FALSE(animator->is_animating()); | 3586 EXPECT_FALSE(animator->is_animating()); |
3585 EXPECT_TRUE(observer.animation_completed()); | 3587 EXPECT_TRUE(observer.animation_completed()); |
3586 EXPECT_FALSE(observer.animation_aborted()); | 3588 EXPECT_FALSE(observer.animation_aborted()); |
3587 animator->RemoveObserver(&observer); | 3589 animator->RemoveObserver(&observer); |
3588 } | 3590 } |
3589 | 3591 |
3590 } // namespace test | 3592 } // namespace test |
3591 } // namespace aura | 3593 } // namespace aura |
OLD | NEW |