OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_MUS_THREAD_PROXY_H_ |
| 6 #define UI_OZONE_PLATFORM_DRM_MUS_THREAD_PROXY_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/observer_list.h" |
| 12 #include "base/synchronization/lock.h" |
| 13 #include "ui/gfx/native_widget_types.h" |
| 14 #include "ui/ozone/platform/drm/gpu/inter_thread_messaging_proxy.h" |
| 15 #include "ui/ozone/platform/drm/host/drm_cursor.h" |
| 16 #include "ui/ozone/platform/drm/host/gpu_thread_adapter.h" |
| 17 |
| 18 namespace base { |
| 19 class SingleThreadTaskRunner; |
| 20 } |
| 21 |
| 22 namespace ui { |
| 23 |
| 24 class DrmCursor; |
| 25 class DrmDisplayHostManager; |
| 26 class DrmOverlayManager; |
| 27 class DrmThread; |
| 28 class GpuThreadObserver; |
| 29 |
| 30 // In Mus, the window server thread (analogous to Chrome's UI thread), GPU and |
| 31 // DRM threads coexist in a single Mus process. The |MusThreadProxy| connects |
| 32 // these threads together via cross-thread calls. |
| 33 class MusThreadProxy : public GpuThreadAdapter, |
| 34 public InterThreadMessagingProxy, |
| 35 public DrmCursorProxy { |
| 36 public: |
| 37 MusThreadProxy(); |
| 38 ~MusThreadProxy() override; |
| 39 |
| 40 void StartDrmThread(); |
| 41 void ProvideManagers(DrmDisplayHostManager* display_manager, |
| 42 DrmOverlayManager* overlay_manager); |
| 43 |
| 44 // InterThreadMessagingProxy. |
| 45 void SetDrmThread(DrmThread* thread) override; |
| 46 |
| 47 // This is the core functionality. They are invoked when we have a main |
| 48 // thread, a gpu thread and we have called initialize on both. |
| 49 void AddGpuThreadObserver(GpuThreadObserver* observer) override; |
| 50 void RemoveGpuThreadObserver(GpuThreadObserver* observer) override; |
| 51 bool IsConnected() override; |
| 52 |
| 53 // Services needed for DrmDisplayHostMananger. |
| 54 void RegisterHandlerForDrmDisplayHostManager( |
| 55 DrmDisplayHostManager* handler) override; |
| 56 void UnRegisterHandlerForDrmDisplayHostManager() override; |
| 57 |
| 58 bool GpuTakeDisplayControl() override; |
| 59 bool GpuRefreshNativeDisplays() override; |
| 60 bool GpuRelinquishDisplayControl() override; |
| 61 bool GpuAddGraphicsDevice(const base::FilePath& path, |
| 62 const base::FileDescriptor& fd) override; |
| 63 bool GpuRemoveGraphicsDevice(const base::FilePath& path) override; |
| 64 |
| 65 // Services needed for DrmOverlayManager. |
| 66 void RegisterHandlerForDrmOverlayManager(DrmOverlayManager* handler) override; |
| 67 void UnRegisterHandlerForDrmOverlayManager() override; |
| 68 |
| 69 bool GpuCheckOverlayCapabilities( |
| 70 gfx::AcceleratedWidget widget, |
| 71 const std::vector<OverlayCheck_Params>& new_params) override; |
| 72 |
| 73 // Services needed by DrmDisplayHost |
| 74 bool GpuConfigureNativeDisplay(int64_t display_id, |
| 75 const ui::DisplayMode_Params& display_mode, |
| 76 const gfx::Point& point) override; |
| 77 bool GpuDisableNativeDisplay(int64_t display_id) override; |
| 78 bool GpuGetHDCPState(int64_t display_id) override; |
| 79 bool GpuSetHDCPState(int64_t display_id, ui::HDCPState state) override; |
| 80 bool GpuSetGammaRamp(int64_t display_id, |
| 81 const std::vector<GammaRampRGBEntry>& lut) override; |
| 82 |
| 83 // Services needed by DrmWindowHost |
| 84 bool GpuDestroyWindow(gfx::AcceleratedWidget widget) override; |
| 85 bool GpuCreateWindow(gfx::AcceleratedWidget widget) override; |
| 86 bool GpuWindowBoundsChanged(gfx::AcceleratedWidget widget, |
| 87 const gfx::Rect& bounds) override; |
| 88 |
| 89 // DrmCursorProxy. |
| 90 void CursorSet(gfx::AcceleratedWidget window, |
| 91 const std::vector<SkBitmap>& bitmaps, |
| 92 const gfx::Point& point, |
| 93 int frame_delay_ms) override; |
| 94 void Move(gfx::AcceleratedWidget window, const gfx::Point& point) override; |
| 95 |
| 96 private: |
| 97 void RunObservers(); |
| 98 void DispatchObserversFromDrmThread(); |
| 99 |
| 100 void GpuCheckOverlayCapabilitiesCallback( |
| 101 gfx::AcceleratedWidget widget, |
| 102 const std::vector<OverlayCheck_Params>& overlays) const; |
| 103 |
| 104 void GpuConfigureNativeDisplayCallback(int64_t display_id, |
| 105 bool success) const; |
| 106 |
| 107 void GpuRefreshNativeDisplaysCallback( |
| 108 const std::vector<DisplaySnapshot_Params>& displays) const; |
| 109 void GpuDisableNativeDisplayCallback(int64_t display_id, bool success) const; |
| 110 void GpuTakeDisplayControlCallback(bool success) const; |
| 111 void GpuRelinquishDisplayControlCallback(bool success) const; |
| 112 void GpuGetHDCPStateCallback(int64_t display_id, |
| 113 bool success, |
| 114 HDCPState state) const; |
| 115 void GpuSetHDCPStateCallback(int64_t display_id, bool success) const; |
| 116 |
| 117 scoped_refptr<base::SingleThreadTaskRunner> ws_task_runner_; |
| 118 |
| 119 DrmThread* drm_thread_; // Not owned. |
| 120 |
| 121 // Guards for multi-theaded access to drm_thread_. |
| 122 base::Lock lock_; |
| 123 |
| 124 DrmDisplayHostManager* display_manager_; // Not owned. |
| 125 DrmOverlayManager* overlay_manager_; // Not owned. |
| 126 |
| 127 base::ObserverList<GpuThreadObserver> gpu_thread_observers_; |
| 128 |
| 129 base::ThreadChecker on_window_server_thread_; |
| 130 |
| 131 base::WeakPtrFactory<MusThreadProxy> weak_ptr_factory_; |
| 132 |
| 133 DISALLOW_COPY_AND_ASSIGN(MusThreadProxy); |
| 134 }; |
| 135 |
| 136 } // namespace ui |
| 137 |
| 138 #endif // UI_OZONE_PLATFORM_DRM_MUS_THREAD_PROXY_H_ |
OLD | NEW |