OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_WINDOW_H_ |
| 6 #define UI_OZONE_PLATFORM_DRM_GPU_DRM_WINDOW_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/timer/timer.h" |
| 11 #include "ui/gfx/geometry/point.h" |
| 12 #include "ui/gfx/geometry/rect.h" |
| 13 #include "ui/gfx/native_widget_types.h" |
| 14 #include "ui/gfx/swap_result.h" |
| 15 #include "ui/ozone/ozone_export.h" |
| 16 #include "ui/ozone/platform/drm/gpu/overlay_plane.h" |
| 17 #include "ui/ozone/platform/drm/gpu/page_flip_request.h" |
| 18 #include "ui/ozone/public/surface_ozone_egl.h" |
| 19 |
| 20 class SkBitmap; |
| 21 |
| 22 namespace gfx { |
| 23 class Point; |
| 24 class Rect; |
| 25 } // namespace gfx |
| 26 |
| 27 namespace ui { |
| 28 |
| 29 class DrmBuffer; |
| 30 class DrmDeviceManager; |
| 31 class HardwareDisplayController; |
| 32 struct OverlayCheck_Params; |
| 33 class ScanoutBufferGenerator; |
| 34 class ScreenManager; |
| 35 |
| 36 // A delegate of the platform window (DrmWindow) on the GPU process. This is |
| 37 // used to keep track of window state changes such that each platform window is |
| 38 // correctly associated with a display. |
| 39 // A window is associated with the display whose bounds contains the window |
| 40 // bounds. If there's no suitable display, the window is disconnected and its |
| 41 // contents will not be visible. |
| 42 class OZONE_EXPORT DrmWindow { |
| 43 public: |
| 44 DrmWindow(gfx::AcceleratedWidget widget, |
| 45 DrmDeviceManager* device_manager, |
| 46 ScreenManager* screen_manager); |
| 47 |
| 48 ~DrmWindow(); |
| 49 |
| 50 gfx::Rect bounds() const { return bounds_; } |
| 51 |
| 52 void Initialize(); |
| 53 |
| 54 void Shutdown(); |
| 55 |
| 56 // Returns the accelerated widget associated with the delegate. |
| 57 gfx::AcceleratedWidget GetAcceleratedWidget(); |
| 58 |
| 59 // Returns the current controller the window is displaying on. Callers should |
| 60 // not cache the result as the controller may change as the window is moved. |
| 61 HardwareDisplayController* GetController(); |
| 62 |
| 63 void SetController(HardwareDisplayController* controller); |
| 64 |
| 65 // Called when the window is resized/moved. |
| 66 void OnBoundsChanged(const gfx::Rect& bounds); |
| 67 |
| 68 // Update the HW cursor bitmap & move to specified location. If |
| 69 // the bitmap is empty, the cursor is hidden. |
| 70 void SetCursor(const std::vector<SkBitmap>& bitmaps, |
| 71 const gfx::Point& location, |
| 72 int frame_delay_ms); |
| 73 |
| 74 // Update the HW cursor bitmap & move to specified location. If |
| 75 // the bitmap is empty, the cursor is hidden. |
| 76 void SetCursorWithoutAnimations(const std::vector<SkBitmap>& bitmaps, |
| 77 const gfx::Point& location); |
| 78 |
| 79 // Move the HW cursor to the specified location. |
| 80 void MoveCursor(const gfx::Point& location); |
| 81 |
| 82 // Queue overlay planes and page flips. |
| 83 // If hardware display controller is available, forward the information |
| 84 // immediately, otherwise queue up on the window and forward when the hardware |
| 85 // is once again ready. |
| 86 void QueueOverlayPlane(const OverlayPlane& plane); |
| 87 |
| 88 bool SchedulePageFlip(bool is_sync, const SwapCompletionCallback& callback); |
| 89 bool TestPageFlip(const std::vector<OverlayCheck_Params>& planes, |
| 90 ScanoutBufferGenerator* buffer_generator); |
| 91 |
| 92 // Returns the last buffer associated with this window. |
| 93 const OverlayPlane* GetLastModesetBuffer(); |
| 94 |
| 95 private: |
| 96 // Draw the last set cursor & update the cursor plane. |
| 97 void ResetCursor(bool bitmap_only); |
| 98 |
| 99 // Draw next frame in an animated cursor. |
| 100 void OnCursorAnimationTimeout(); |
| 101 |
| 102 // When |controller_| changes this is called to reallocate the cursor buffers |
| 103 // since the allocation DRM device may have changed. |
| 104 void UpdateCursorBuffers(); |
| 105 |
| 106 gfx::AcceleratedWidget widget_; |
| 107 |
| 108 DrmDeviceManager* device_manager_; // Not owned. |
| 109 ScreenManager* screen_manager_; // Not owned. |
| 110 |
| 111 // The current bounds of the window. |
| 112 gfx::Rect bounds_; |
| 113 |
| 114 // The controller associated with the current window. This may be nullptr if |
| 115 // the window isn't over an active display. |
| 116 HardwareDisplayController* controller_ = nullptr; |
| 117 |
| 118 base::RepeatingTimer<DrmWindow> cursor_timer_; |
| 119 |
| 120 scoped_refptr<DrmBuffer> cursor_buffers_[2]; |
| 121 int cursor_frontbuffer_ = 0; |
| 122 |
| 123 std::vector<SkBitmap> cursor_bitmaps_; |
| 124 gfx::Point cursor_location_; |
| 125 int cursor_frame_ = 0; |
| 126 int cursor_frame_delay_ms_ = 0; |
| 127 |
| 128 // Planes and flips currently being queued in the absence of hardware display |
| 129 // controller. |
| 130 OverlayPlaneList pending_planes_; |
| 131 OverlayPlaneList last_submitted_planes_; |
| 132 bool last_swap_sync_ = false; |
| 133 |
| 134 DISALLOW_COPY_AND_ASSIGN(DrmWindow); |
| 135 }; |
| 136 |
| 137 } // namespace ui |
| 138 |
| 139 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_WINDOW_H_ |
OLD | NEW |