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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
content / renderer / media / win / dcomp_texture_host.h [blame]
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_RENDERER_MEDIA_WIN_DCOMP_TEXTURE_HOST_H_
#define CONTENT_RENDERER_MEDIA_WIN_DCOMP_TEXTURE_HOST_H_
#include <stdint.h>
#include "base/memory/raw_ptr.h"
#include "base/task/sequenced_task_runner.h"
#include "base/unguessable_token.h"
#include "base/win/windows_types.h"
#include "gpu/ipc/common/gpu_channel.mojom.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "ui/gfx/geometry/rect.h"
namespace base {
class UnguessableToken;
}
namespace gfx {
class Size;
}
namespace gpu {
class GpuChannelHost;
struct Mailbox;
} // namespace gpu
namespace content {
// Handles all mojo calls between DCOMPTextureWrapperImpl and the GPU process.
class DCOMPTextureHost : public gpu::mojom::DCOMPTextureClient {
public:
// Listener class that is listening to the DCOMP texture updates.
class Listener {
public:
virtual void OnSharedImageMailboxBound(gpu::Mailbox mailbox) = 0;
virtual void OnOutputRectChange(gfx::Rect output_rect) = 0;
};
DCOMPTextureHost(
scoped_refptr<gpu::GpuChannelHost> channel,
int32_t route_id,
scoped_refptr<base::SequencedTaskRunner> media_task_runner,
mojo::PendingAssociatedRemote<gpu::mojom::DCOMPTexture> texture,
Listener* listener);
DCOMPTextureHost(const DCOMPTextureHost&) = delete;
DCOMPTextureHost& operator=(const DCOMPTextureHost&) = delete;
~DCOMPTextureHost() override;
void SetTextureSize(const gfx::Size& size);
using SetDCOMPSurfaceHandleCB = base::OnceCallback<void(bool)>;
void SetDCOMPSurfaceHandle(
const base::UnguessableToken& token,
SetDCOMPSurfaceHandleCB set_dcomp_surface_handle_cb);
private:
void OnDisconnectedFromGpuProcess();
// gpu::mojom::DCOMPTextureClient:
void OnSharedImageMailboxBound(const gpu::Mailbox& mailbox) override;
void OnOutputRectChange(const gfx::Rect& output_rect) override;
scoped_refptr<gpu::GpuChannelHost> channel_;
const int32_t route_id_;
const raw_ptr<Listener>
listener_; // Raw pointer is safe because the `listener_`
// (DCOMPTextureWrapperImpl) owns `this`.
// Calls into the DCOMPTexture in the GPU process.
mojo::AssociatedRemote<gpu::mojom::DCOMPTexture> texture_remote_;
// Receives calls from the DCOMPTexture instance in the GPU process.
mojo::AssociatedReceiver<gpu::mojom::DCOMPTextureClient> receiver_{this};
};
} // namespace content
#endif // CONTENT_RENDERER_MEDIA_WIN_DCOMP_TEXTURE_HOST_H_