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

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

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

Powered by Google App Engine
This is Rietveld 408576698