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

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:
40 void EvictFrame() override;
51 void SetNeedsBeginFrame(bool needs_begin_frame) override; 41 void SetNeedsBeginFrame(bool needs_begin_frame) override;
52 void SubmitCompositorFrame(const cc::LocalFrameId& local_frame_id, 42 void SubmitCompositorFrame(const cc::LocalFrameId& local_frame_id,
53 cc::CompositorFrame frame) override; 43 cc::CompositorFrame frame) override;
54 void EvictFrame() override;
55 44
56 // cc::mojom::MojoCompositorFrameSinkPrivate: 45 // cc::mojom::MojoCompositorFrameSinkPrivate:
57 void AddChildFrameSink(const cc::FrameSinkId& child_frame_sink_id) override; 46 void AddChildFrameSink(const cc::FrameSinkId& child_frame_sink_id) override;
58 void RemoveChildFrameSink( 47 void RemoveChildFrameSink(
59 const cc::FrameSinkId& child_frame_sink_id) override; 48 const cc::FrameSinkId& child_frame_sink_id) override;
60 49
61 private: 50 private:
62 void DidReceiveCompositorFrameAck(); 51 // cc::CompositorFrameSinkSupportClient implementation:
63 52 void DidReceiveCompositorFrameAck() override;
64 // cc::DisplayClient implementation.
65 void DisplayOutputSurfaceLost() override;
66 void DisplayWillDrawAndSwap(bool will_draw_and_swap,
67 const cc::RenderPassList& render_passes) override;
68 void DisplayDidDrawAndSwap() override;
69
70 // cc::SurfaceFactoryClient implementation.
71 void ReturnResources(const cc::ReturnedResourceArray& resources) override;
72 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override;
73
74 // cc::BeginFrameObserver implementation.
75 void OnBeginFrame(const cc::BeginFrameArgs& args) override; 53 void OnBeginFrame(const cc::BeginFrameArgs& args) override;
76 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; 54 void ReclaimResources(const cc::ReturnedResourceArray& resources) override;
77 void OnBeginFrameSourcePausedChanged(bool paused) override; 55 void WillDrawSurface() override;
78
79 void UpdateNeedsBeginFramesInternal();
80 56
81 void OnClientConnectionLost(); 57 void OnClientConnectionLost();
82 void OnPrivateConnectionLost(); 58 void OnPrivateConnectionLost();
83 59
84 const cc::FrameSinkId frame_sink_id_; 60 DisplayCompositor* const display_compositor_;
85 61
86 DisplayCompositor* const display_compositor_; // owns this. 62 cc::CompositorFrameSinkSupport support_;
87
88 // GpuCompositorFrameSink holds a cc::Display if it created with
89 // non-null gpu::SurfaceHandle. In the window server, the display root
90 // window's CompositorFrameSink will have a valid gpu::SurfaceHandle.
91 std::unique_ptr<cc::Display> display_;
92
93 cc::LocalFrameId local_frame_id_;
94 cc::SurfaceFactory surface_factory_;
95 // Counts the number of CompositorFrames that have been submitted and have not
96 // yet received an ACK.
97 int ack_pending_count_ = 0;
98 cc::ReturnedResourceArray surface_returned_resources_;
99 63
100 bool client_connection_lost_ = false; 64 bool client_connection_lost_ = false;
101 bool private_connection_lost_ = false; 65 bool private_connection_lost_ = false;
102 66
103 // The begin frame source being observered. Null if none.
104 cc::BeginFrameSource* begin_frame_source_ = nullptr;
105
106 // The last begin frame args generated by the begin frame source.
107 cc::BeginFrameArgs last_begin_frame_args_;
108
109 // Whether a request for begin frames has been issued.
110 bool needs_begin_frame_ = false;
111
112 // Whether or not a frame observer has been added.
113 bool added_frame_observer_ = false;
114
115 cc::mojom::MojoCompositorFrameSinkClientPtr client_; 67 cc::mojom::MojoCompositorFrameSinkClientPtr client_;
116 mojo::Binding<cc::mojom::MojoCompositorFrameSink> binding_; 68 mojo::Binding<cc::mojom::MojoCompositorFrameSink> binding_;
117 mojo::Binding<cc::mojom::MojoCompositorFrameSinkPrivate> private_binding_; 69 mojo::Binding<cc::mojom::MojoCompositorFrameSinkPrivate> private_binding_;
118 70
119 base::WeakPtrFactory<GpuCompositorFrameSink> weak_factory_;
120
121 DISALLOW_COPY_AND_ASSIGN(GpuCompositorFrameSink); 71 DISALLOW_COPY_AND_ASSIGN(GpuCompositorFrameSink);
122 }; 72 };
123 73
124 } // namespace ui 74 } // namespace ui
125 75
126 #endif // SERVICES_UI_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_ 76 #endif // SERVICES_UI_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_
OLDNEW
« no previous file with comments | « cc/surfaces/compositor_frame_sink_support_client.h ('k') | services/ui/surfaces/gpu_compositor_frame_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698