| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_DRM_GPU_DRM_THREAD_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_THREAD_H_ |
| 6 #define UI_OZONE_PLATFORM_DRM_GPU_DRM_THREAD_H_ | 6 #define UI_OZONE_PLATFORM_DRM_GPU_DRM_THREAD_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/files/scoped_file.h" | 12 #include "base/files/scoped_file.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 16 #include "mojo/public/cpp/bindings/binding_set.h" |
| 17 #include "services/shell/public/cpp/connection.h" |
| 16 #include "ui/gfx/native_pixmap_handle_ozone.h" | 18 #include "ui/gfx/native_pixmap_handle_ozone.h" |
| 17 #include "ui/gfx/native_widget_types.h" | 19 #include "ui/gfx/native_widget_types.h" |
| 18 #include "ui/gfx/vsync_provider.h" | 20 #include "ui/gfx/vsync_provider.h" |
| 19 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h" | 21 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h" |
| 22 #include "ui/ozone/public/interfaces/device_cursor.mojom.h" |
| 20 #include "ui/ozone/public/surface_ozone_egl.h" | 23 #include "ui/ozone/public/surface_ozone_egl.h" |
| 21 | 24 |
| 22 namespace base { | 25 namespace base { |
| 23 struct FileDescriptor; | 26 struct FileDescriptor; |
| 24 } | 27 } |
| 25 | 28 |
| 26 namespace gfx { | 29 namespace gfx { |
| 27 class Point; | 30 class Point; |
| 28 class Rect; | 31 class Rect; |
| 29 } | 32 } |
| 30 | 33 |
| 34 namespace shell { |
| 35 class Connection; |
| 36 } |
| 37 |
| 31 namespace ui { | 38 namespace ui { |
| 32 | 39 |
| 33 class DrmDeviceManager; | 40 class DrmDeviceManager; |
| 34 class DrmGpuDisplayManager; | 41 class DrmGpuDisplayManager; |
| 35 class DrmWindow; | 42 class DrmWindow; |
| 36 class DrmWindowProxy; | 43 class DrmWindowProxy; |
| 37 class GbmBuffer; | 44 class GbmBuffer; |
| 38 class ScanoutBufferGenerator; | 45 class ScanoutBufferGenerator; |
| 39 class ScreenManager; | 46 class ScreenManager; |
| 40 | 47 |
| 41 struct GammaRampRGBEntry; | 48 struct GammaRampRGBEntry; |
| 42 struct OverlayPlane; | 49 struct OverlayPlane; |
| 43 | 50 |
| 44 // Holds all the DRM related state and performs all DRM related operations. | 51 // Holds all the DRM related state and performs all DRM related operations. |
| 45 // | 52 // |
| 46 // The DRM thread is used to insulate DRM operations from potential blocking | 53 // The DRM thread is used to insulate DRM operations from potential blocking |
| 47 // behaviour on the GPU main thread in order to reduce the potential for jank | 54 // behaviour on the GPU main thread in order to reduce the potential for jank |
| 48 // (for example jank in the cursor if the GPU main thread is performing heavy | 55 // (for example jank in the cursor if the GPU main thread is performing heavy |
| 49 // operations). The inverse is also true as blocking operations on the DRM | 56 // operations). The inverse is also true as blocking operations on the DRM |
| 50 // thread (such as modesetting) no longer block the GPU main thread. | 57 // thread (such as modesetting) no longer block the GPU main thread. |
| 51 class DrmThread : public base::Thread { | 58 class DrmThread : public base::Thread, public ozone::mojom::DeviceCursor { |
| 52 public: | 59 public: |
| 53 DrmThread(); | 60 DrmThread(); |
| 54 ~DrmThread() override; | 61 ~DrmThread() override; |
| 55 | 62 |
| 56 void Start(); | 63 void Start(); |
| 57 | 64 |
| 58 // Must be called on the DRM thread. | 65 // Must be called on the DRM thread. |
| 59 void CreateBuffer(gfx::AcceleratedWidget widget, | 66 void CreateBuffer(gfx::AcceleratedWidget widget, |
| 60 const gfx::Size& size, | 67 const gfx::Size& size, |
| 61 gfx::BufferFormat format, | 68 gfx::BufferFormat format, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 72 void SchedulePageFlip(gfx::AcceleratedWidget widget, | 79 void SchedulePageFlip(gfx::AcceleratedWidget widget, |
| 73 const std::vector<OverlayPlane>& planes, | 80 const std::vector<OverlayPlane>& planes, |
| 74 const SwapCompletionCallback& callback); | 81 const SwapCompletionCallback& callback); |
| 75 void GetVSyncParameters( | 82 void GetVSyncParameters( |
| 76 gfx::AcceleratedWidget widget, | 83 gfx::AcceleratedWidget widget, |
| 77 const gfx::VSyncProvider::UpdateVSyncCallback& callback); | 84 const gfx::VSyncProvider::UpdateVSyncCallback& callback); |
| 78 | 85 |
| 79 void CreateWindow(gfx::AcceleratedWidget widget); | 86 void CreateWindow(gfx::AcceleratedWidget widget); |
| 80 void DestroyWindow(gfx::AcceleratedWidget widget); | 87 void DestroyWindow(gfx::AcceleratedWidget widget); |
| 81 void SetWindowBounds(gfx::AcceleratedWidget widget, const gfx::Rect& bounds); | 88 void SetWindowBounds(gfx::AcceleratedWidget widget, const gfx::Rect& bounds); |
| 82 void SetCursor(gfx::AcceleratedWidget widget, | 89 void SetCursor(const gfx::AcceleratedWidget& widget, |
| 83 const std::vector<SkBitmap>& bitmaps, | 90 const std::vector<SkBitmap>& bitmaps, |
| 84 const gfx::Point& location, | 91 const gfx::Point& location, |
| 85 int frame_delay_ms); | 92 uint32_t frame_delay_ms); |
| 86 void MoveCursor(const gfx::AcceleratedWidget& widget, | 93 void MoveCursor(const gfx::AcceleratedWidget& widget, |
| 87 const gfx::Point& location); | 94 const gfx::Point& location); |
| 88 void CheckOverlayCapabilities( | 95 void CheckOverlayCapabilities( |
| 89 gfx::AcceleratedWidget widget, | 96 gfx::AcceleratedWidget widget, |
| 90 const std::vector<OverlayCheck_Params>& overlays, | 97 const std::vector<OverlayCheck_Params>& overlays, |
| 91 const base::Callback<void(gfx::AcceleratedWidget, | 98 const base::Callback<void(gfx::AcceleratedWidget, |
| 92 const std::vector<OverlayCheck_Params>&)>& | 99 const std::vector<OverlayCheck_Params>&)>& |
| 93 callback); | 100 callback); |
| 94 void RefreshNativeDisplays( | 101 void RefreshNativeDisplays( |
| 95 const base::Callback<void(const std::vector<DisplaySnapshot_Params>&)>& | 102 const base::Callback<void(const std::vector<DisplaySnapshot_Params>&)>& |
| (...skipping 18 matching lines...) Expand all Loading... |
| 114 HDCPState state, | 121 HDCPState state, |
| 115 const base::Callback<void(int64_t, bool)>& callback); | 122 const base::Callback<void(int64_t, bool)>& callback); |
| 116 void SetColorCorrection(int64_t display_id, | 123 void SetColorCorrection(int64_t display_id, |
| 117 const std::vector<GammaRampRGBEntry>& degamma_lut, | 124 const std::vector<GammaRampRGBEntry>& degamma_lut, |
| 118 const std::vector<GammaRampRGBEntry>& gamma_lut, | 125 const std::vector<GammaRampRGBEntry>& gamma_lut, |
| 119 const std::vector<float>& correction_matrix); | 126 const std::vector<float>& correction_matrix); |
| 120 | 127 |
| 121 // base::Thread: | 128 // base::Thread: |
| 122 void Init() override; | 129 void Init() override; |
| 123 | 130 |
| 131 // Mojo support for DeviceCursorRequest. |
| 132 void AddBinding(shell::Connection* connection, |
| 133 ozone::mojom::DeviceCursorRequest request); |
| 134 |
| 124 private: | 135 private: |
| 125 std::unique_ptr<DrmDeviceManager> device_manager_; | 136 std::unique_ptr<DrmDeviceManager> device_manager_; |
| 126 std::unique_ptr<ScanoutBufferGenerator> buffer_generator_; | 137 std::unique_ptr<ScanoutBufferGenerator> buffer_generator_; |
| 127 std::unique_ptr<ScreenManager> screen_manager_; | 138 std::unique_ptr<ScreenManager> screen_manager_; |
| 128 std::unique_ptr<DrmGpuDisplayManager> display_manager_; | 139 std::unique_ptr<DrmGpuDisplayManager> display_manager_; |
| 129 | 140 |
| 141 // The mojo implementation requires a BindingSet because the DrmThread serves |
| 142 // requests from two different client threads. |
| 143 mojo::BindingSet<ozone::mojom::DeviceCursor> bindings_; |
| 144 |
| 130 DISALLOW_COPY_AND_ASSIGN(DrmThread); | 145 DISALLOW_COPY_AND_ASSIGN(DrmThread); |
| 131 }; | 146 }; |
| 132 | 147 |
| 133 } // namespace ui | 148 } // namespace ui |
| 134 | 149 |
| 135 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_THREAD_H_ | 150 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_THREAD_H_ |
| OLD | NEW |