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

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

Issue 2768563002: Move DisplayCompositor code to new component. (Closed)
Patch Set: Rebase. Created 3 years, 8 months 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
« no previous file with comments | « services/ui/surfaces/BUILD.gn ('k') | services/ui/surfaces/display_compositor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_SURFACES_DISPLAY_COMPOSITOR_H_
6 #define SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_
7
8 #include <stdint.h>
9
10 #include <memory>
11 #include <unordered_map>
12 #include <vector>
13
14 #include "base/macros.h"
15 #include "base/threading/thread_checker.h"
16 #include "cc/ipc/display_compositor.mojom.h"
17 #include "cc/surfaces/frame_sink_id.h"
18 #include "cc/surfaces/local_surface_id.h"
19 #include "cc/surfaces/surface_id.h"
20 #include "cc/surfaces/surface_manager.h"
21 #include "cc/surfaces/surface_observer.h"
22 #include "components/display_compositor/gpu_compositor_frame_sink_delegate.h"
23 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
24 #include "gpu/ipc/common/surface_handle.h"
25 #include "gpu/ipc/in_process_command_buffer.h"
26 #include "ipc/ipc_channel_handle.h"
27 #include "mojo/public/cpp/bindings/binding.h"
28
29 namespace gpu {
30 class GpuMemoryBufferManager;
31 class ImageFactory;
32 }
33
34 namespace cc {
35 class Display;
36 class SyntheticBeginFrameSource;
37 }
38
39 namespace display_compositor {
40 class GpuCompositorFrameSink;
41 }
42
43 namespace ui {
44
45 // The DisplayCompositor object is an object global to the Window Server app
46 // that holds the SurfaceServer and allocates new Surfaces namespaces.
47 // This object lives on the main thread of the Window Server.
48 // TODO(rjkroege, fsamuel): This object will need to change to support multiple
49 // displays.
50 class DisplayCompositor
51 : public cc::SurfaceObserver,
52 public display_compositor::GpuCompositorFrameSinkDelegate,
53 public cc::mojom::DisplayCompositor {
54 public:
55 DisplayCompositor(
56 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service,
57 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager,
58 gpu::ImageFactory* image_factory,
59 cc::mojom::DisplayCompositorRequest request,
60 cc::mojom::DisplayCompositorClientPtr client);
61 ~DisplayCompositor() override;
62
63 cc::SurfaceManager* manager() { return &manager_; }
64
65 // cc::mojom::DisplayCompositor implementation:
66 void CreateRootCompositorFrameSink(
67 const cc::FrameSinkId& frame_sink_id,
68 gpu::SurfaceHandle surface_handle,
69 cc::mojom::MojoCompositorFrameSinkAssociatedRequest request,
70 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
71 cc::mojom::MojoCompositorFrameSinkClientPtr client,
72 cc::mojom::DisplayPrivateAssociatedRequest display_private_request)
73 override;
74 void CreateCompositorFrameSink(
75 const cc::FrameSinkId& frame_sink_id,
76 cc::mojom::MojoCompositorFrameSinkRequest request,
77 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
78 cc::mojom::MojoCompositorFrameSinkClientPtr client) override;
79 void RegisterFrameSinkHierarchy(
80 const cc::FrameSinkId& parent_frame_sink_id,
81 const cc::FrameSinkId& child_frame_sink_id) override;
82 void UnregisterFrameSinkHierarchy(
83 const cc::FrameSinkId& parent_frame_sink_id,
84 const cc::FrameSinkId& child_frame_sink_id) override;
85 void DropTemporaryReference(const cc::SurfaceId& surface_id) override;
86
87 private:
88 std::unique_ptr<cc::Display> CreateDisplay(
89 const cc::FrameSinkId& frame_sink_id,
90 gpu::SurfaceHandle surface_handle,
91 cc::SyntheticBeginFrameSource* begin_frame_source);
92
93 // It is necessary to pass |frame_sink_id| by value because the id
94 // is owned by the GpuCompositorFrameSink in the map. When the sink is
95 // removed from the map, |frame_sink_id| would also be destroyed if it were a
96 // reference. But the map can continue to iterate and try to use it. Passing
97 // by value avoids this.
98 void DestroyCompositorFrameSink(cc::FrameSinkId frame_sink_id);
99
100 // cc::SurfaceObserver implementation.
101 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override;
102 void OnSurfaceDamaged(const cc::SurfaceId& surface_id,
103 bool* changed) override;
104
105 // display_compositor::GpuCompositorFrameSinkDelegate implementation.
106 void OnClientConnectionLost(const cc::FrameSinkId& frame_sink_id,
107 bool destroy_compositor_frame_sink) override;
108 void OnPrivateConnectionLost(const cc::FrameSinkId& frame_sink_id,
109 bool destroy_compositor_frame_sink) override;
110
111 // SurfaceManager should be the first object constructed and the last object
112 // destroyed in order to ensure that all other objects that depend on it have
113 // access to a valid pointer for the entirety of their liftimes.
114 cc::SurfaceManager manager_;
115
116 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service_;
117 std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager_;
118 gpu::ImageFactory* image_factory_;
119
120 std::unordered_map<cc::FrameSinkId,
121 std::unique_ptr<cc::mojom::MojoCompositorFrameSink>,
122 cc::FrameSinkIdHash>
123 compositor_frame_sinks_;
124
125 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
126
127 base::ThreadChecker thread_checker_;
128
129 cc::mojom::DisplayCompositorClientPtr client_;
130 mojo::Binding<cc::mojom::DisplayCompositor> binding_;
131
132 DISALLOW_COPY_AND_ASSIGN(DisplayCompositor);
133 };
134
135 } // namespace ui
136
137 #endif // SERVICES_UI_SURFACES_DISPLAY_COMPOSITOR_H_
OLDNEW
« no previous file with comments | « services/ui/surfaces/BUILD.gn ('k') | services/ui/surfaces/display_compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698