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

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

Issue 2481263002: Introduce Display Compositor mojo interface. Use InProcessContextProvider. (Closed)
Patch Set: Speculative fix for android build issue 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 #include "services/ui/surfaces/display_compositor.h" 5 #include "services/ui/surfaces/display_compositor.h"
6 6
7 #include "cc/output/in_process_context_provider.h"
7 #include "cc/surfaces/surface.h" 8 #include "cc/surfaces/surface.h"
9 #include "gpu/command_buffer/client/shared_memory_limits.h"
10 #include "gpu/ipc/gpu_in_process_thread_service.h"
11 #include "mojo/public/cpp/bindings/strong_binding.h"
12 #include "services/ui/surfaces/gpu_compositor_frame_sink.h"
8 13
9 namespace ui { 14 namespace ui {
10 15
11 DisplayCompositor::DisplayCompositor( 16 DisplayCompositor::DisplayCompositor(
17 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service,
18 std::unique_ptr<MusGpuMemoryBufferManager> gpu_memory_buffer_manager,
19 gpu::ImageFactory* image_factory,
12 cc::mojom::DisplayCompositorClientPtr client) 20 cc::mojom::DisplayCompositorClientPtr client)
13 : client_(std::move(client)) { 21 : gpu_service_(std::move(gpu_service)),
22 gpu_memory_buffer_manager_(std::move(gpu_memory_buffer_manager)),
23 image_factory_(image_factory),
24 client_(std::move(client)) {
14 manager_.AddObserver(this); 25 manager_.AddObserver(this);
15 } 26 }
16 27
28 void DisplayCompositor::CreateCompositorFrameSink(
29 const cc::FrameSinkId& frame_sink_id,
30 gpu::SurfaceHandle surface_handle,
31 cc::mojom::MojoCompositorFrameSinkRequest request,
32 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
33 cc::mojom::MojoCompositorFrameSinkClientPtr client) {
34 // We cannot create more than one CompositorFrameSink with a given
35 // |frame_sink_id|.
36 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id));
37 scoped_refptr<cc::InProcessContextProvider> context_provider;
38 if (surface_handle != gpu::kNullSurfaceHandle) {
39 context_provider = new cc::InProcessContextProvider(
40 gpu_service_, surface_handle, gpu_memory_buffer_manager_.get(),
41 image_factory_, gpu::SharedMemoryLimits(),
42 nullptr /* shared_context */);
43 }
44 compositor_frame_sinks_[frame_sink_id] =
45 base::MakeUnique<GpuCompositorFrameSink>(
46 this, frame_sink_id, surface_handle, gpu_memory_buffer_manager_.get(),
47 std::move(context_provider), std::move(request),
48 std::move(private_request), std::move(client));
49 }
50
17 void DisplayCompositor::AddRootSurfaceReference(const cc::SurfaceId& child_id) { 51 void DisplayCompositor::AddRootSurfaceReference(const cc::SurfaceId& child_id) {
18 AddSurfaceReference(manager_.GetRootSurfaceId(), child_id); 52 AddSurfaceReference(manager_.GetRootSurfaceId(), child_id);
19 } 53 }
20 54
21 void DisplayCompositor::AddSurfaceReference(const cc::SurfaceId& parent_id, 55 void DisplayCompositor::AddSurfaceReference(const cc::SurfaceId& parent_id,
22 const cc::SurfaceId& child_id) { 56 const cc::SurfaceId& child_id) {
23 auto vector_iter = temp_references_.find(child_id.frame_sink_id()); 57 auto vector_iter = temp_references_.find(child_id.frame_sink_id());
24 58
25 // If there are no temporary references for the FrameSinkId then we can just 59 // If there are no temporary references for the FrameSinkId then we can just
26 // add reference and return. 60 // add reference and return.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 const cc::FrameSinkId& frame_sink_id = map_entry.first; 120 const cc::FrameSinkId& frame_sink_id = map_entry.first;
87 for (auto& local_frame_id : map_entry.second) { 121 for (auto& local_frame_id : map_entry.second) {
88 manager_.RemoveSurfaceReference( 122 manager_.RemoveSurfaceReference(
89 manager_.GetRootSurfaceId(), 123 manager_.GetRootSurfaceId(),
90 cc::SurfaceId(frame_sink_id, local_frame_id)); 124 cc::SurfaceId(frame_sink_id, local_frame_id));
91 } 125 }
92 } 126 }
93 manager_.RemoveObserver(this); 127 manager_.RemoveObserver(this);
94 } 128 }
95 129
130 void DisplayCompositor::OnCompositorFrameSinkClientConnectionLost(
131 const cc::FrameSinkId& frame_sink_id,
132 bool destroy_compositor_frame_sink) {
133 if (destroy_compositor_frame_sink)
134 compositor_frame_sinks_.erase(frame_sink_id);
135 // TODO(fsamuel): Tell the display compositor host that the client connection
136 // has been lost so that it can drop its private connection and allow a new
137 // client instance to create a new CompositorFrameSink.
138 }
139
140 void DisplayCompositor::OnCompositorFrameSinkPrivateConnectionLost(
141 const cc::FrameSinkId& frame_sink_id,
142 bool destroy_compositor_frame_sink) {
143 if (destroy_compositor_frame_sink)
144 compositor_frame_sinks_.erase(frame_sink_id);
145 }
146
96 void DisplayCompositor::OnSurfaceCreated(const cc::SurfaceId& surface_id, 147 void DisplayCompositor::OnSurfaceCreated(const cc::SurfaceId& surface_id,
97 const gfx::Size& frame_size, 148 const gfx::Size& frame_size,
98 float device_scale_factor) { 149 float device_scale_factor) {
99 // We can get into a situation where multiple CompositorFrames arrive for a 150 // We can get into a situation where multiple CompositorFrames arrive for a
100 // CompositorFrameSink before the DisplayCompositorClient can add any 151 // CompositorFrameSink before the DisplayCompositorClient can add any
101 // references for the frame. When the second frame with a new size arrives, 152 // references for the frame. When the second frame with a new size arrives,
102 // the first will be destroyed and then if there are no references it will be 153 // the first will be destroyed and then if there are no references it will be
103 // deleted during surface GC. A temporary reference, removed when a real 154 // deleted during surface GC. A temporary reference, removed when a real
104 // reference is received, is added to prevent this from happening. 155 // reference is received, is added to prevent this from happening.
105 manager_.AddSurfaceReference(manager_.GetRootSurfaceId(), surface_id); 156 manager_.AddSurfaceReference(manager_.GetRootSurfaceId(), surface_id);
106 temp_references_[surface_id.frame_sink_id()].push_back( 157 temp_references_[surface_id.frame_sink_id()].push_back(
107 surface_id.local_frame_id()); 158 surface_id.local_frame_id());
108 159
109 if (client_) 160 if (client_)
110 client_->OnSurfaceCreated(surface_id, frame_size, device_scale_factor); 161 client_->OnSurfaceCreated(surface_id, frame_size, device_scale_factor);
111 } 162 }
112 163
113 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id, 164 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id,
114 bool* changed) {} 165 bool* changed) {}
115 166
116 } // namespace ui 167 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698