Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Side by Side Diff: services/ui/ws/gpu_compositor_frame_sink.h

Issue 2481263002: Introduce Display Compositor mojo interface. Use InProcessContextProvider. (Closed)
Patch Set: Make ContextProvider NON_EXPORTED_BASE of InProcessContextProvider Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
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 SERVICES_UI_WS_GPU_COMPOSITOR_FRAME_SINK_H_
6 #define SERVICES_UI_WS_GPU_COMPOSITOR_FRAME_SINK_H_
7
8 #include <memory>
9 #include <set>
10
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "cc/ipc/compositor_frame.mojom.h"
14 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h"
15 #include "cc/output/context_provider.h"
16 #include "cc/scheduler/begin_frame_source.h"
17 #include "cc/surfaces/display.h"
18 #include "cc/surfaces/display_client.h"
19 #include "cc/surfaces/frame_sink_id.h"
20 #include "cc/surfaces/surface_factory.h"
21 #include "cc/surfaces/surface_factory_client.h"
22 #include "cc/surfaces/surface_id.h"
23 #include "cc/surfaces/surface_id_allocator.h"
24 #include "mojo/public/cpp/bindings/binding.h"
25 #include "services/ui/surfaces/surfaces_context_provider.h"
26
27 namespace base {
28 class SingleThreadTaskRunner;
29 }
30
31 namespace gpu {
32 class GpuMemoryBufferManager;
33 }
34
35 namespace ui {
36
37 class DisplayCompositor;
38
39 namespace ws {
40
41 // Server side representation of a WindowSurface.
42 class GpuCompositorFrameSink : public cc::mojom::MojoCompositorFrameSink,
43 public cc::DisplayClient,
44 public cc::mojom::MojoCompositorFrameSinkPrivate,
45 public cc::SurfaceFactoryClient,
46 public cc::BeginFrameObserver {
47 public:
48 // TODO(fsamuel): DisplayCompositor should own
49 // GpuCompositorFrameSink. GpuCompositorFrameSink should not
50 // refer to GpuCompositorFrameSinkManager.
51 GpuCompositorFrameSink(
52 scoped_refptr<DisplayCompositor> display_compositor,
53 const cc::FrameSinkId& frame_sink_id,
54 gfx::AcceleratedWidget widget,
55 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
56 scoped_refptr<SurfacesContextProvider> context_provider,
57 cc::mojom::MojoCompositorFrameSinkRequest request,
58 cc::mojom::MojoCompositorFrameSinkClientPtr client);
59
60 ~GpuCompositorFrameSink() override;
61
62 // cc::mojom::MojoCompositorFrameSink:
63 void SetNeedsBeginFrame(bool needs_begin_frame) override;
64 void SubmitCompositorFrame(cc::CompositorFrame frame) override;
65
66 // cc::mojom::MojoCompositorFrameSinkPrivate:
67 void AddChildFrameSink(const cc::FrameSinkId& child_frame_sink_id) override;
68 void RemoveChildFrameSink(
69 const cc::FrameSinkId& child_frame_sink_id) override;
70
71 private:
72 void InitDisplay(gfx::AcceleratedWidget widget,
73 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
74 scoped_refptr<SurfacesContextProvider> context_provider);
75
76 void DidReceiveCompositorFrameAck();
77
78 // cc::DisplayClient implementation.
79 void DisplayOutputSurfaceLost() override;
80 void DisplayWillDrawAndSwap(bool will_draw_and_swap,
81 const cc::RenderPassList& render_passes) override;
82 void DisplayDidDrawAndSwap() override;
83
84 // cc::SurfaceFactoryClient implementation.
85 void ReturnResources(const cc::ReturnedResourceArray& resources) override;
86 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override;
87
88 // cc::BeginFrameObserver implementation.
89 void OnBeginFrame(const cc::BeginFrameArgs& args) override;
90 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override;
91 void OnBeginFrameSourcePausedChanged(bool paused) override;
92
93 void UpdateNeedsBeginFramesInternal();
94
95 const cc::FrameSinkId frame_sink_id_;
96 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
97
98 // TODO(fsamuel): We hold a reference to DisplayCompositor so we can talk to
99 // SurfaceManager in the destructor. In the future, DisplayCompositor will own
100 // GpuCompositorFrameSink.
101 scoped_refptr<DisplayCompositor> display_compositor_;
102
103 gfx::Size last_submitted_frame_size_;
104 // GpuCompositorFrameSink holds a cc::Display if it created with
105 // non-null gfx::AcceleratedWidget. In the window server, the display root
106 // window's CompositorFrameSink will have a valid gfx::AcceleratedWidget.
107 std::unique_ptr<cc::Display> display_;
108
109 cc::LocalFrameId local_frame_id_;
110 cc::SurfaceIdAllocator surface_id_allocator_;
111 cc::SurfaceFactory surface_factory_;
112 // Counts the number of CompositorFrames that have been submitted and have not
113 // yet received an ACK.
114 int ack_pending_count_ = 0;
115 cc::ReturnedResourceArray surface_returned_resources_;
116
117 // The begin frame source being observered. Null if none.
118 cc::BeginFrameSource* begin_frame_source_ = nullptr;
119
120 // The last begin frame args generated by the begin frame source.
121 cc::BeginFrameArgs last_begin_frame_args_;
122
123 // Whether a request for begin frames has been issued.
124 bool needs_begin_frame_ = false;
125
126 // Whether or not a frame observer has been added.
127 bool added_frame_observer_ = false;
128
129 cc::mojom::MojoCompositorFrameSinkClientPtr client_;
130 mojo::Binding<cc::mojom::MojoCompositorFrameSink> binding_;
131
132 DISALLOW_COPY_AND_ASSIGN(GpuCompositorFrameSink);
133 };
134
135 } // namespace ws
136
137 } // namespace ui
138
139 #endif // SERVICES_UI_WS_GPU_COMPOSITOR_FRAME_SINK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698