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_HOST_OVERLAY_CANDIDATES_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRM_HOST_OVERLAY_CANDIDATES_H_ |
6 #define UI_OZONE_PLATFORM_DRM_HOST_OVERLAY_CANDIDATES_H_ | 6 #define UI_OZONE_PLATFORM_DRM_HOST_OVERLAY_CANDIDATES_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h" | |
14 #include "ui/ozone/platform/drm/host/drm_overlay_candidates_host_core.h" | |
15 #include "ui/ozone/public/gpu_platform_support_host.h" | |
16 #include "ui/ozone/public/overlay_candidates_ozone.h" | 13 #include "ui/ozone/public/overlay_candidates_ozone.h" |
17 | 14 |
18 namespace ui { | 15 namespace ui { |
19 | 16 |
20 class DrmGpuPlatformSupportHost; | 17 class DrmOverlayManagerCore; |
21 class DrmWindowHost; | |
22 class DrmOverlayCandidatesHost; | |
23 | 18 |
24 // This is an implementation of OverlayCandidatesOzone where the driver is asked | 19 // This is an implementation of OverlayCandidatesOzone where the driver is asked |
25 // about overlay capabilities via IPC. We have no way of querying abstract | 20 // about overlay capabilities via IPC. We have no way of querying abstract |
26 // capabilities, only if a particular configuration is supported or not. | 21 // capabilities, only if a particular configuration is supported or not. |
27 // Each time we we are asked if a particular configuration is supported, if we | 22 // Each time we we are asked if a particular configuration is supported, if we |
28 // have not seen that configuration before, it is IPCed to the GPU via | 23 // have not seen that configuration before, it is IPCed to the GPU via |
29 // OzoneGpuMsg_CheckOverlayCapabilities; a test commit is then performed and | 24 // OzoneGpuMsg_CheckOverlayCapabilities; a test commit is then performed and |
30 // the result is returned in OzoneHostMsg_OverlayCapabilitiesReceived. Testing | 25 // the result is returned in OzoneHostMsg_OverlayCapabilitiesReceived. Testing |
31 // is asynchronous, until the reply arrives that configuration will be failed. | 26 // is asynchronous, until the reply arrives that configuration will be failed. |
32 // | 27 // |
33 // There is a many:1 relationship between this class and | 28 // All OverlayCandidatesOzone objects share a single cache of tested |
34 // DrmGpuPlatformSupportHost, each compositor will own one of these objects. | 29 // configurations stored in the overlay manager. |
35 // Each request has a unique request ID, which is assigned from a shared | 30 class DrmOverlayCandidatesHost : public OverlayCandidatesOzone { |
36 // sequence number so that replies can be routed to the correct object. | |
37 // TODO(rjkroege): Consider removing the dependency on | |
38 // GpuPlatformSupportHost. | |
39 class DrmOverlayCandidatesHost : public OverlayCandidatesOzone, | |
40 public GpuPlatformSupportHost { | |
41 public: | 31 public: |
42 DrmOverlayCandidatesHost(DrmGpuPlatformSupportHost* platform_support, | 32 DrmOverlayCandidatesHost(DrmOverlayManagerCore* manager_core, |
43 DrmWindowHost* window); | 33 gfx::AcceleratedWidget widget); |
44 ~DrmOverlayCandidatesHost() override; | 34 ~DrmOverlayCandidatesHost() override; |
45 | 35 |
46 // OverlayCandidatesOzone: | |
47 void CheckOverlaySupport(OverlaySurfaceCandidateList* candidates) override; | 36 void CheckOverlaySupport(OverlaySurfaceCandidateList* candidates) override; |
48 | 37 |
49 // GpuPlatformSupportHost: | |
50 void OnChannelEstablished( | |
51 int host_id, | |
52 scoped_refptr<base::SingleThreadTaskRunner> send_runner, | |
53 const base::Callback<void(IPC::Message*)>& sender) override; | |
54 void OnChannelDestroyed(int host_id) override; | |
55 bool OnMessageReceived(const IPC::Message& message) override; | |
56 | |
57 private: | 38 private: |
58 class OverlayCandidatesIPC : public DrmOverlayCandidatesHostProxy { | 39 DrmOverlayManagerCore* overlay_manager_; // Not owned. |
59 public: | 40 gfx::AcceleratedWidget widget_; |
60 OverlayCandidatesIPC(DrmGpuPlatformSupportHost* platform_support, | |
61 DrmOverlayCandidatesHost* parent); | |
62 ~OverlayCandidatesIPC() override; | |
63 void RegisterHandler() override; | |
64 bool IsConnected() override; | |
65 void UnregisterHandler() override; | |
66 bool CheckOverlayCapabilities( | |
67 gfx::AcceleratedWidget widget, | |
68 const std::vector<OverlayCheck_Params>& new_params) override; | |
69 | |
70 private: | |
71 DrmGpuPlatformSupportHost* platform_support_; | |
72 DrmOverlayCandidatesHost* parent_; | |
73 DISALLOW_COPY_AND_ASSIGN(OverlayCandidatesIPC); | |
74 }; | |
75 | |
76 // Entry point for incoming IPC. | |
77 void OnOverlayResult(bool* handled, | |
78 gfx::AcceleratedWidget widget, | |
79 const std::vector<OverlayCheck_Params>& params); | |
80 | |
81 // Sends messages to the GPU thread. | |
82 scoped_ptr<OverlayCandidatesIPC> sender_; | |
83 | |
84 // Implementation without messaging functionality. | |
85 scoped_ptr<DrmOverlayCandidatesHostCore> core_; | |
86 | 41 |
87 DISALLOW_COPY_AND_ASSIGN(DrmOverlayCandidatesHost); | 42 DISALLOW_COPY_AND_ASSIGN(DrmOverlayCandidatesHost); |
88 }; | 43 }; |
89 | 44 |
90 } // namespace ui | 45 } // namespace ui |
91 | 46 |
92 #endif // UI_OZONE_PLATFORM_DRM_HOST_OVERLAY_CANDIDATES_H_ | 47 #endif // UI_OZONE_PLATFORM_DRM_HOST_OVERLAY_CANDIDATES_H_ |
OLD | NEW |