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