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

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

Issue 2543373002: Extract non-Mojo bits of GpuCompositorFrameSink to CompositorFrameSinkSupport (Closed)
Patch Set: Rebased 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
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_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_ 5 #ifndef SERVICES_UI_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_
6 #define SERVICES_UI_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_ 6 #define SERVICES_UI_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_
7 7
8 #include <memory>
9 #include <set>
10
11 #include "base/macros.h" 8 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
14 #include "cc/ipc/compositor_frame.mojom.h"
15 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" 10 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h"
16 #include "cc/scheduler/begin_frame_source.h" 11 #include "cc/surfaces/compositor_frame_sink_support.h"
17 #include "cc/surfaces/display_client.h" 12 #include "cc/surfaces/compositor_frame_sink_support_client.h"
18 #include "cc/surfaces/frame_sink_id.h"
19 #include "cc/surfaces/surface_factory.h"
20 #include "cc/surfaces/surface_factory_client.h"
21 #include "cc/surfaces/surface_id.h"
22 #include "cc/surfaces/surface_id_allocator.h"
23 #include "mojo/public/cpp/bindings/binding.h" 13 #include "mojo/public/cpp/bindings/binding.h"
24 14
25 namespace cc { 15 namespace cc {
26 class Display; 16 class Display;
27 } 17 }
28 18
29 namespace ui { 19 namespace ui {
30 20
31 class DisplayCompositor; 21 class DisplayCompositor;
32 22
33 // Server side representation of a WindowSurface. 23 // Server side representation of a WindowSurface.
34 class GpuCompositorFrameSink : public cc::mojom::MojoCompositorFrameSink, 24 class GpuCompositorFrameSink
35 public cc::DisplayClient, 25 : public cc::CompositorFrameSinkSupportClient,
36 public cc::mojom::MojoCompositorFrameSinkPrivate, 26 public cc::mojom::MojoCompositorFrameSink,
37 public cc::SurfaceFactoryClient, 27 public cc::mojom::MojoCompositorFrameSinkPrivate {
38 public cc::BeginFrameObserver {
39 public: 28 public:
40 GpuCompositorFrameSink( 29 GpuCompositorFrameSink(
41 DisplayCompositor* display_compositor, 30 DisplayCompositor* display_compositor,
42 const cc::FrameSinkId& frame_sink_id, 31 const cc::FrameSinkId& frame_sink_id,
43 std::unique_ptr<cc::Display> display, 32 std::unique_ptr<cc::Display> display,
44 cc::mojom::MojoCompositorFrameSinkRequest request, 33 cc::mojom::MojoCompositorFrameSinkRequest request,
45 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, 34 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
46 cc::mojom::MojoCompositorFrameSinkClientPtr client); 35 cc::mojom::MojoCompositorFrameSinkClientPtr client);
47 36
48 ~GpuCompositorFrameSink() override; 37 ~GpuCompositorFrameSink() override;
49 38
50 // cc::mojom::MojoCompositorFrameSink: 39 // cc::mojom::MojoCompositorFrameSink:
51 void SetNeedsBeginFrame(bool needs_begin_frame) override; 40 void SetNeedsBeginFrame(bool needs_begin_frame) override;
52 void SubmitCompositorFrame(const cc::LocalFrameId& local_frame_id, 41 void SubmitCompositorFrame(const cc::LocalFrameId& local_frame_id,
53 cc::CompositorFrame frame) override; 42 cc::CompositorFrame frame) override;
54 43
55 // cc::mojom::MojoCompositorFrameSinkPrivate: 44 // cc::mojom::MojoCompositorFrameSinkPrivate:
56 void AddChildFrameSink(const cc::FrameSinkId& child_frame_sink_id) override; 45 void AddChildFrameSink(const cc::FrameSinkId& child_frame_sink_id) override;
57 void RemoveChildFrameSink( 46 void RemoveChildFrameSink(
58 const cc::FrameSinkId& child_frame_sink_id) override; 47 const cc::FrameSinkId& child_frame_sink_id) override;
59 48
60 private: 49 private:
61 void DidReceiveCompositorFrameAck(); 50 // cc::CompositorFrameSinkSupportClient implementation:
62 51 void DidReceiveCompositorFrameAck() override;
63 // cc::DisplayClient implementation.
64 void DisplayOutputSurfaceLost() override;
65 void DisplayWillDrawAndSwap(bool will_draw_and_swap,
66 const cc::RenderPassList& render_passes) override;
67 void DisplayDidDrawAndSwap() override;
68
69 // cc::SurfaceFactoryClient implementation.
70 void ReturnResources(const cc::ReturnedResourceArray& resources) override;
71 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override;
72
73 // cc::BeginFrameObserver implementation.
74 void OnBeginFrame(const cc::BeginFrameArgs& args) override; 52 void OnBeginFrame(const cc::BeginFrameArgs& args) override;
75 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; 53 void ReclaimResources(const cc::ReturnedResourceArray& resources) override;
76 void OnBeginFrameSourcePausedChanged(bool paused) override;
77
78 void UpdateNeedsBeginFramesInternal();
79 54
80 void OnClientConnectionLost(); 55 void OnClientConnectionLost();
81 void OnPrivateConnectionLost(); 56 void OnPrivateConnectionLost();
82 57
83 const cc::FrameSinkId frame_sink_id_; 58 DisplayCompositor* const display_compositor_;
84 59
85 DisplayCompositor* const display_compositor_; // owns this. 60 cc::CompositorFrameSinkSupport support_;
86
87 // GpuCompositorFrameSink holds a cc::Display if it created with
88 // non-null gpu::SurfaceHandle. In the window server, the display root
89 // window's CompositorFrameSink will have a valid gpu::SurfaceHandle.
90 std::unique_ptr<cc::Display> display_;
91
92 cc::LocalFrameId local_frame_id_;
93 cc::SurfaceFactory surface_factory_;
94 // Counts the number of CompositorFrames that have been submitted and have not
95 // yet received an ACK.
96 int ack_pending_count_ = 0;
97 cc::ReturnedResourceArray surface_returned_resources_;
98 61
99 bool client_connection_lost_ = false; 62 bool client_connection_lost_ = false;
100 bool private_connection_lost_ = false; 63 bool private_connection_lost_ = false;
101 64
102 // The begin frame source being observered. Null if none.
103 cc::BeginFrameSource* begin_frame_source_ = nullptr;
104
105 // The last begin frame args generated by the begin frame source.
106 cc::BeginFrameArgs last_begin_frame_args_;
107
108 // Whether a request for begin frames has been issued.
109 bool needs_begin_frame_ = false;
110
111 // Whether or not a frame observer has been added.
112 bool added_frame_observer_ = false;
113
114 cc::mojom::MojoCompositorFrameSinkClientPtr client_; 65 cc::mojom::MojoCompositorFrameSinkClientPtr client_;
115 mojo::Binding<cc::mojom::MojoCompositorFrameSink> binding_; 66 mojo::Binding<cc::mojom::MojoCompositorFrameSink> binding_;
116 mojo::Binding<cc::mojom::MojoCompositorFrameSinkPrivate> private_binding_; 67 mojo::Binding<cc::mojom::MojoCompositorFrameSinkPrivate> private_binding_;
117 68
118 base::WeakPtrFactory<GpuCompositorFrameSink> weak_factory_;
119
120 DISALLOW_COPY_AND_ASSIGN(GpuCompositorFrameSink); 69 DISALLOW_COPY_AND_ASSIGN(GpuCompositorFrameSink);
121 }; 70 };
122 71
123 } // namespace ui 72 } // namespace ui
124 73
125 #endif // SERVICES_UI_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_ 74 #endif // SERVICES_UI_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698