OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef UI_OZONE_PLATFORM_DRI_DRI_WINDOW_DELEGATE_IMPL_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRI_DRI_WINDOW_DELEGATE_IMPL_H_ |
6 #define UI_OZONE_PLATFORM_DRI_DRI_WINDOW_DELEGATE_IMPL_H_ | 6 #define UI_OZONE_PLATFORM_DRI_DRI_WINDOW_DELEGATE_IMPL_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | |
9 #include "base/timer/timer.h" | 8 #include "base/timer/timer.h" |
10 #include "ui/gfx/geometry/point.h" | 9 #include "ui/gfx/geometry/point.h" |
| 10 #include "ui/gfx/geometry/rect.h" |
11 #include "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
| 12 #include "ui/ozone/platform/dri/display_change_observer.h" |
12 #include "ui/ozone/platform/dri/dri_window_delegate.h" | 13 #include "ui/ozone/platform/dri/dri_window_delegate.h" |
13 | 14 |
14 namespace gfx { | |
15 class Rect; | |
16 } // namespace gfx | |
17 | |
18 namespace ui { | 15 namespace ui { |
19 | 16 |
20 class DriBuffer; | 17 class DriBuffer; |
21 class DriWindowDelegateManager; | 18 class DriWindowDelegateManager; |
22 class DriWrapper; | 19 class DriWrapper; |
23 class HardwareDisplayController; | 20 class HardwareDisplayController; |
24 class ScreenManager; | 21 class ScreenManager; |
25 | 22 |
26 class DriWindowDelegateImpl : public DriWindowDelegate { | 23 class DriWindowDelegateImpl : public DriWindowDelegate, |
| 24 public DisplayChangeObserver { |
27 public: | 25 public: |
28 DriWindowDelegateImpl(gfx::AcceleratedWidget widget, | 26 DriWindowDelegateImpl(gfx::AcceleratedWidget widget, |
29 DriWrapper* drm, | 27 DriWrapper* drm, |
30 DriWindowDelegateManager* window_manager, | 28 DriWindowDelegateManager* window_manager, |
31 ScreenManager* screen_manager); | 29 ScreenManager* screen_manager); |
32 ~DriWindowDelegateImpl() override; | 30 ~DriWindowDelegateImpl() override; |
33 | 31 |
34 // DriWindowDelegate: | 32 // DriWindowDelegate: |
35 void Initialize() override; | 33 void Initialize() override; |
36 void Shutdown() override; | 34 void Shutdown() override; |
37 gfx::AcceleratedWidget GetAcceleratedWidget() override; | 35 gfx::AcceleratedWidget GetAcceleratedWidget() override; |
38 HardwareDisplayController* GetController() override; | 36 HardwareDisplayController* GetController() override; |
39 void OnBoundsChanged(const gfx::Rect& bounds) override; | 37 void OnBoundsChanged(const gfx::Rect& bounds) override; |
40 void SetCursor(const std::vector<SkBitmap>& bitmaps, | 38 void SetCursor(const std::vector<SkBitmap>& bitmaps, |
41 const gfx::Point& location, | 39 const gfx::Point& location, |
42 int frame_delay_ms) override; | 40 int frame_delay_ms) override; |
43 void SetCursorWithoutAnimations(const std::vector<SkBitmap>& bitmaps, | 41 void SetCursorWithoutAnimations(const std::vector<SkBitmap>& bitmaps, |
44 const gfx::Point& location) override; | 42 const gfx::Point& location) override; |
45 void MoveCursor(const gfx::Point& location) override; | 43 void MoveCursor(const gfx::Point& location) override; |
46 | 44 |
| 45 // DisplayChangeObserver: |
| 46 void OnDisplayChanged(HardwareDisplayController* controller) override; |
| 47 void OnDisplayRemoved(HardwareDisplayController* controller) override; |
| 48 |
47 private: | 49 private: |
48 // Draw the last set cursor & update the cursor plane. | 50 // Draw the last set cursor & update the cursor plane. |
49 void ResetCursor(bool bitmap_only); | 51 void ResetCursor(bool bitmap_only); |
50 | 52 |
51 // Draw next frame in an animated cursor. | 53 // Draw next frame in an animated cursor. |
52 void OnCursorAnimationTimeout(); | 54 void OnCursorAnimationTimeout(); |
53 | 55 |
54 gfx::AcceleratedWidget widget_; | 56 gfx::AcceleratedWidget widget_; |
55 | 57 |
56 DriWrapper* drm_; // Not owned. | 58 DriWrapper* drm_; // Not owned. |
57 DriWindowDelegateManager* window_manager_; // Not owned. | 59 DriWindowDelegateManager* window_manager_; // Not owned. |
58 ScreenManager* screen_manager_; // Not owned. | 60 ScreenManager* screen_manager_; // Not owned. |
59 | 61 |
60 base::WeakPtr<HardwareDisplayController> controller_; | 62 // The current bounds of the window. |
| 63 gfx::Rect bounds_; |
| 64 |
| 65 // The controller associated with the current window. This may be nullptr if |
| 66 // the window isn't over an active display. |
| 67 HardwareDisplayController* controller_; |
61 | 68 |
62 base::RepeatingTimer<DriWindowDelegateImpl> cursor_timer_; | 69 base::RepeatingTimer<DriWindowDelegateImpl> cursor_timer_; |
63 | 70 |
64 scoped_refptr<DriBuffer> cursor_buffers_[2]; | 71 scoped_refptr<DriBuffer> cursor_buffers_[2]; |
65 int cursor_frontbuffer_; | 72 int cursor_frontbuffer_; |
66 | 73 |
67 std::vector<SkBitmap> cursor_bitmaps_; | 74 std::vector<SkBitmap> cursor_bitmaps_; |
68 gfx::Point cursor_location_; | 75 gfx::Point cursor_location_; |
69 int cursor_frame_; | 76 int cursor_frame_; |
70 int cursor_frame_delay_ms_; | 77 int cursor_frame_delay_ms_; |
71 | 78 |
72 DISALLOW_COPY_AND_ASSIGN(DriWindowDelegateImpl); | 79 DISALLOW_COPY_AND_ASSIGN(DriWindowDelegateImpl); |
73 }; | 80 }; |
74 | 81 |
75 } // namespace ui | 82 } // namespace ui |
76 | 83 |
77 #endif // UI_OZONE_PLATFORM_DRI_DRI_WINDOW_DELEGATE_IMPL_H_ | 84 #endif // UI_OZONE_PLATFORM_DRI_DRI_WINDOW_DELEGATE_IMPL_H_ |
OLD | NEW |