Upload upstream chromium 120.0.6099.5
[platform/framework/web/chromium-efl.git] / media / renderers / resource_sync_token_client.h
1 // Copyright 2023 The Chromium Authors
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 MEDIA_RENDERERS_RESOURCE_SYNC_TOKEN_CLIENT_H_
6 #define MEDIA_RENDERERS_RESOURCE_SYNC_TOKEN_CLIENT_H_
7
8 #include "gpu/command_buffer/common/sync_token.h"
9 #include "media/base/media_export.h"
10 #include "media/base/video_frame.h"
11
12 namespace gpu {
13 class InterfaceBase;
14 }
15
16 namespace media {
17
18 // A SyncTokenClient specialized in handling SyncTokens provided for resource
19 // return during a viz::ReleaseCallback. It attempts to minimize the number of
20 // waits and new sync tokens generated.
21 class MEDIA_EXPORT ResourceSyncTokenClient
22     : public VideoFrame::SyncTokenClient {
23  public:
24   // `old_frame_release_token` is the SyncToken that the underlying VideoFrame
25   // had when the resource was imported and the ReleaseCallback bound.
26   // `new_plane_release_token` is the SyncToken the plane ReleaseCallback was
27   // called with. It must not be null.
28   ResourceSyncTokenClient(gpu::InterfaceBase* gl,
29                           gpu::SyncToken old_frame_release_token,
30                           gpu::SyncToken new_plane_release_token);
31   ~ResourceSyncTokenClient() override;
32
33   ResourceSyncTokenClient(const ResourceSyncTokenClient&) = delete;
34   ResourceSyncTokenClient& operator=(const ResourceSyncTokenClient&) = delete;
35
36   // VideoFrame::SyncTokenClient implementation.
37   void GenerateSyncToken(gpu::SyncToken* sync_token) final;
38   void WaitSyncToken(const gpu::SyncToken& sync_token) final;
39
40  private:
41   raw_ptr<gpu::InterfaceBase> const ib_;
42   gpu::SyncToken old_frame_release_token_;
43   gpu::SyncToken new_plane_release_token_;
44 };
45
46 }  // namespace media
47
48 #endif  // MEDIA_RENDERERS_RESOURCE_SYNC_TOKEN_CLIENT_H_