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.
5 #ifndef MEDIA_RENDERERS_RESOURCE_SYNC_TOKEN_CLIENT_H_
6 #define MEDIA_RENDERERS_RESOURCE_SYNC_TOKEN_CLIENT_H_
8 #include "gpu/command_buffer/common/sync_token.h"
9 #include "media/base/media_export.h"
10 #include "media/base/video_frame.h"
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 {
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;
33 ResourceSyncTokenClient(const ResourceSyncTokenClient&) = delete;
34 ResourceSyncTokenClient& operator=(const ResourceSyncTokenClient&) = delete;
36 // VideoFrame::SyncTokenClient implementation.
37 void GenerateSyncToken(gpu::SyncToken* sync_token) final;
38 void WaitSyncToken(const gpu::SyncToken& sync_token) final;
41 raw_ptr<gpu::InterfaceBase> const ib_;
42 gpu::SyncToken old_frame_release_token_;
43 gpu::SyncToken new_plane_release_token_;
48 #endif // MEDIA_RENDERERS_RESOURCE_SYNC_TOKEN_CLIENT_H_