Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / ozone / platform / drm / host / drm_overlay_candidates_host.h
blob2f00cacb4176805eeaf815f9a558626b01e6daaa
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
3 // found in the LICENSE file.
5 #ifndef UI_OZONE_PLATFORM_DRM_HOST_OVERLAY_CANDIDATES_H_
6 #define UI_OZONE_PLATFORM_DRM_HOST_OVERLAY_CANDIDATES_H_
8 #include <deque>
9 #include <map>
10 #include <vector>
12 #include "base/containers/mru_cache.h"
13 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
14 #include "ui/ozone/public/gpu_platform_support_host.h"
15 #include "ui/ozone/public/overlay_candidates_ozone.h"
17 namespace ui {
19 class DrmGpuPlatformSupportHost;
21 // This is an implementation of OverlayCandidatesOzone where the driver is asked
22 // about overlay capabilities via IPC. We have no way of querying abstract
23 // capabilities, only if a particular configuration is supported or not.
24 // Each time we we are asked if a particular configuration is supported, if we
25 // have not seen that configuration before, it is IPCed to the GPU via
26 // OzoneGpuMsg_CheckOverlayCapabilities; a test commit is then performed and
27 // the result is returned in OzoneHostMsg_OverlayCapabilitiesReceived. Testing
28 // is asynchronous, until the reply arrives that configuration will be failed.
30 // There is a many:1 relationship between this class and
31 // DrmGpuPlatformSupportHost, each compositor will own one of these objects.
32 // Each request has a unique request ID, which is assigned from a shared
33 // sequence number so that replies can be routed to the correct object.
34 class DrmOverlayCandidatesHost : public OverlayCandidatesOzone,
35 public GpuPlatformSupportHost {
36 struct OverlayCompare {
37 bool operator()(const OverlayCheck_Params& l, const OverlayCheck_Params& r);
40 public:
41 DrmOverlayCandidatesHost(gfx::AcceleratedWidget widget,
42 DrmGpuPlatformSupportHost* platform_support);
43 ~DrmOverlayCandidatesHost() override;
45 // OverlayCandidatesOzone:
46 void CheckOverlaySupport(OverlaySurfaceCandidateList* candidates) override;
48 // GpuPlatformSupportHost:
49 void OnChannelEstablished(
50 int host_id,
51 scoped_refptr<base::SingleThreadTaskRunner> send_runner,
52 const base::Callback<void(IPC::Message*)>& sender) override;
53 void OnChannelDestroyed(int host_id) override;
54 bool OnMessageReceived(const IPC::Message& message) override;
56 private:
57 void SendRequest(const OverlaySurfaceCandidateList& candidates,
58 const OverlayCheck_Params& check);
59 void OnOverlayResult(bool* handled,
60 gfx::AcceleratedWidget widget,
61 bool result);
62 void ProcessResult(const OverlayCheck_Params& check, bool result);
64 void CheckSingleOverlay(OverlaySurfaceCandidateList* candidates);
66 gfx::AcceleratedWidget widget_;
67 DrmGpuPlatformSupportHost* platform_support_; // Not owned.
69 std::deque<OverlayCheck_Params> pending_checks_;
71 template <class KeyType, class ValueType>
72 struct OverlayMap {
73 typedef std::map<KeyType, ValueType, OverlayCompare> Type;
75 base::MRUCacheBase<OverlayCheck_Params,
76 bool,
77 base::MRUCacheNullDeletor<bool>,
78 OverlayMap> cache_;
80 DISALLOW_COPY_AND_ASSIGN(DrmOverlayCandidatesHost);
83 } // namespace ui
85 #endif // UI_OZONE_PLATFORM_DRM_HOST_OVERLAY_CANDIDATES_H_