forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirect_compositor_frame_sink.h
93 lines (79 loc) · 3.5 KB
/
direct_compositor_frame_sink.h
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
84
85
86
87
88
89
90
91
92
93
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_SURFACES_DIRECT_COMPOSITOR_FRAME_SINK_H_
#define CC_SURFACES_DIRECT_COMPOSITOR_FRAME_SINK_H_
#include "base/macros.h"
#include "base/threading/thread_checker.h"
#include "cc/output/compositor_frame_sink.h"
#include "cc/scheduler/begin_frame_source.h"
#include "cc/surfaces/compositor_frame_sink_support.h"
#include "cc/surfaces/compositor_frame_sink_support_client.h"
#include "cc/surfaces/display_client.h"
#include "cc/surfaces/local_surface_id_allocator.h"
#include "cc/surfaces/surfaces_export.h"
namespace cc {
class Display;
class LocalSurfaceIdAllocator;
class SurfaceManager;
// This class submits compositor frames to an in-process Display, with the
// client's frame being the root surface of the Display.
class CC_SURFACES_EXPORT DirectCompositorFrameSink
: public CompositorFrameSink,
public NON_EXPORTED_BASE(CompositorFrameSinkSupportClient),
public ExternalBeginFrameSourceClient,
public NON_EXPORTED_BASE(DisplayClient) {
public:
// The underlying Display, SurfaceManager, and LocalSurfaceIdAllocator must
// outlive this class.
DirectCompositorFrameSink(
const FrameSinkId& frame_sink_id,
SurfaceManager* surface_manager,
Display* display,
scoped_refptr<ContextProvider> context_provider,
scoped_refptr<ContextProvider> worker_context_provider,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
SharedBitmapManager* shared_bitmap_manager);
DirectCompositorFrameSink(
const FrameSinkId& frame_sink_id,
SurfaceManager* surface_manager,
Display* display,
scoped_refptr<VulkanContextProvider> vulkan_context_provider);
~DirectCompositorFrameSink() override;
// CompositorFrameSink implementation.
bool BindToClient(CompositorFrameSinkClient* client) override;
void DetachFromClient() override;
void SubmitCompositorFrame(CompositorFrame frame) override;
void DidNotProduceFrame(const BeginFrameAck& ack) override;
// DisplayClient implementation.
void DisplayOutputSurfaceLost() override;
void DisplayWillDrawAndSwap(bool will_draw_and_swap,
const RenderPassList& render_passes) override;
void DisplayDidDrawAndSwap() override;
protected:
std::unique_ptr<CompositorFrameSinkSupport> support_; // protected for test.
private:
// CompositorFrameSinkSupportClient implementation:
void DidReceiveCompositorFrameAck(
const ReturnedResourceArray& resources) override;
void OnBeginFrame(const BeginFrameArgs& args) override;
void ReclaimResources(const ReturnedResourceArray& resources) override;
void WillDrawSurface(const LocalSurfaceId& local_surface_id,
const gfx::Rect& damage_rect) override;
// ExternalBeginFrameSourceClient implementation:
void OnNeedsBeginFrames(bool needs_begin_frame) override;
// This class is only meant to be used on a single thread.
base::ThreadChecker thread_checker_;
const FrameSinkId frame_sink_id_;
LocalSurfaceId local_surface_id_;
SurfaceManager* surface_manager_;
LocalSurfaceIdAllocator local_surface_id_allocator_;
Display* display_;
gfx::Size last_swap_frame_size_;
float device_scale_factor_ = 1.f;
bool is_lost_ = false;
std::unique_ptr<ExternalBeginFrameSource> begin_frame_source_;
DISALLOW_COPY_AND_ASSIGN(DirectCompositorFrameSink);
};
} // namespace cc
#endif // CC_SURFACES_DIRECT_COMPOSITOR_FRAME_SINK_H_