Index: ui/ozone/platform/drm/host/drm_host_overlay_candidates.h |
diff --git a/ui/ozone/platform/drm/host/drm_host_overlay_candidates.h b/ui/ozone/platform/drm/host/drm_host_overlay_candidates.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..22af15a6a521533566d15be29f3ce9cc3b6351f5 |
--- /dev/null |
+++ b/ui/ozone/platform/drm/host/drm_host_overlay_candidates.h |
@@ -0,0 +1,88 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef UI_OZONE_PLATFORM_DRM_HOST_OVERLAY_CANDIDATES_H_ |
+#define UI_OZONE_PLATFORM_DRM_HOST_OVERLAY_CANDIDATES_H_ |
+ |
+#include <deque> |
+#include <map> |
+#include <vector> |
+ |
+#include "ui/ozone/common/gpu/ozone_gpu_message_params.h" |
+#include "ui/ozone/public/gpu_platform_support_host.h" |
+#include "ui/ozone/public/overlay_candidates_ozone.h" |
+ |
+namespace ui { |
+ |
+class DrmGpuPlatformSupportHost; |
+ |
+// This is an implementation of OverlayCandidatesOzone where the driver is asked |
+// about overlay capabilities via IPC. We have no way of querying abstract |
+// capabilities, only if a particular configuration is supported or not. |
+// Each time we we are asked if a particular configuration is supported, if we |
+// have not seen that configuration before, it is IPCed to the GPU via |
+// OzoneGpuMsg_CheckOverlayCapabilities; a test commit is then performed and |
+// the result is returned in OzoneHostMsg_OverlayCapabilitiesReceived. Testing |
+// is asynchronous, until the reply arrives that configuration will be failed. |
+// |
+// There is a many:1 relationship between this class and |
+// DrmGpuPlatformSupportHost, each compositor will own one of these objects. |
+// Each request has a unique request ID, which is assigned from a shared |
+// sequence number so that replies can be routed to the correct object. |
+class DrmHostOverlayCandidates : public OverlayCandidatesOzone, |
+ public GpuPlatformSupportHost { |
+ struct PendingCheck { |
+ PendingCheck(uint32_t id, const OverlayCheck_Params& overlay); |
+ ~PendingCheck(); |
+ |
+ uint32_t request_id; |
+ OverlayCheck_Params overlay; |
+ }; |
+ |
+ struct OverlayCompare { |
+ bool operator()(const OverlayCheck_Params& l, const OverlayCheck_Params& r); |
+ }; |
+ |
+ public: |
+ DrmHostOverlayCandidates(gfx::AcceleratedWidget widget, |
+ DrmGpuPlatformSupportHost* platform_support); |
+ ~DrmHostOverlayCandidates() override; |
+ |
+ // OverlayCandidatesOzone: |
+ void CheckOverlaySupport(OverlaySurfaceCandidateList* candidates) override; |
+ |
+ // GpuPlatformSupportHost: |
+ void OnChannelEstablished( |
+ int host_id, |
+ scoped_refptr<base::SingleThreadTaskRunner> send_runner, |
+ const base::Callback<void(IPC::Message*)>& sender) override; |
+ void OnChannelDestroyed(int host_id) override; |
+ bool OnMessageReceived(const IPC::Message& message) override; |
+ |
+ private: |
+ void SendRequest(const OverlaySurfaceCandidateList& candidates, |
+ const PendingCheck& check); |
+ void OnOverlayResult(bool* handled, |
+ gfx::AcceleratedWidget widget, |
+ uint32_t id, |
+ bool result); |
+ void ProcessResult(const PendingCheck& check, bool result); |
+ |
+ void CheckSingleOverlay(OverlaySurfaceCandidateList* candidates); |
+ |
+ bool channel_established_; |
+ uint32_t next_request_id_; |
+ base::Callback<void(IPC::Message*)> send_callback_; |
+ gfx::AcceleratedWidget widget_; |
+ DrmGpuPlatformSupportHost* platform_support_; // Not owned. |
+ |
+ std::deque<PendingCheck> pending_checks_; |
+ std::map<OverlayCheck_Params, bool, OverlayCompare> cache_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DrmHostOverlayCandidates); |
+}; |
+ |
+} // namespace ui |
+ |
+#endif // UI_OZONE_PLATFORM_DRM_HOST_OVERLAY_CANDIDATES_H_ |