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

Side by Side Diff: components/display_compositor/display_compositor.cc

Issue 2688593002: WIP: Towards merging OffscreenCanvas and Mus code
Patch Set: Fix reflector unit test Created 3 years, 10 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 | « components/display_compositor/display_compositor.h ('k') | content/browser/BUILD.gn » ('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 2017 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 #include "components/display_compositor/display_compositor.h"
6
7 #include "cc/base/switches.h"
8 #include "cc/surfaces/surface.h"
9 #include "components/display_compositor/gpu_offscreen_compositor_frame_sink.h"
10 #include "mojo/public/cpp/bindings/strong_binding.h"
11
12 namespace display_compositor {
13
14 DisplayCompositor::DisplayCompositor()
15 : surface_manager_(cc::SurfaceManager::LifetimeType::SEQUENCES),
16 binding_(this) {
17 surface_manager_.AddObserver(this);
18 }
19
20 DisplayCompositor::DisplayCompositor(
21 cc::mojom::DisplayCompositorRequest request,
22 cc::mojom::DisplayCompositorClientPtr client)
23 : surface_manager_(cc::SurfaceManager::LifetimeType::SEQUENCES),
24 client_(std::move(client)),
25 binding_(this, std::move(request)) {
26 surface_manager_.AddObserver(this);
27 }
28
29 DisplayCompositor::~DisplayCompositor() {
30 DCHECK(thread_checker_.CalledOnValidThread());
31 surface_manager_.RemoveObserver(this);
32 }
33
34 void DisplayCompositor::Bind(cc::mojom::DisplayCompositorRequest request,
35 cc::mojom::DisplayCompositorClientPtr client) {
36 binding_.Bind(std::move(request));
37 client_ = std::move(client);
38 }
39
40 void DisplayCompositor::OnClientConnectionLost(
41 const cc::FrameSinkId& frame_sink_id,
42 bool destroy_compositor_frame_sink) {
43 DCHECK(thread_checker_.CalledOnValidThread());
44 if (destroy_compositor_frame_sink)
45 DestroyCompositorFrameSink(frame_sink_id);
46 // TODO(fsamuel): Tell the display compositor host that the client connection
47 // has been lost so that it can drop its private connection and allow a new
48 // client instance to create a new CompositorFrameSink.
49 }
50
51 void DisplayCompositor::OnPrivateConnectionLost(
52 const cc::FrameSinkId& frame_sink_id,
53 bool destroy_compositor_frame_sink) {
54 DCHECK(thread_checker_.CalledOnValidThread());
55 if (destroy_compositor_frame_sink)
56 DestroyCompositorFrameSink(frame_sink_id);
57 }
58
59 void DisplayCompositor::CreateDisplayCompositorFrameSink(
60 const cc::FrameSinkId& frame_sink_id,
61 gpu::SurfaceHandle surface_handle,
62 cc::mojom::MojoCompositorFrameSinkAssociatedRequest request,
63 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
64 cc::mojom::MojoCompositorFrameSinkClientPtr client,
65 cc::mojom::DisplayPrivateAssociatedRequest display_private_request) {
66 DCHECK(thread_checker_.CalledOnValidThread());
67 DCHECK_NE(surface_handle, gpu::kNullSurfaceHandle);
68 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id));
69 // TODO(fsamuel, kylechar): Implement this.
70 NOTREACHED();
71 }
72
73 void DisplayCompositor::CreateOffscreenCompositorFrameSink(
74 const cc::FrameSinkId& frame_sink_id,
75 cc::mojom::MojoCompositorFrameSinkRequest request,
76 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
77 cc::mojom::MojoCompositorFrameSinkClientPtr client) {
78 DCHECK(thread_checker_.CalledOnValidThread());
79 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id));
80
81 compositor_frame_sinks_[frame_sink_id] =
82 base::MakeUnique<GpuOffscreenCompositorFrameSink>(
83 this, &surface_manager_, frame_sink_id, std::move(request),
84 std::move(private_request), std::move(client));
85 }
86
87 void DisplayCompositor::DestroyCompositorFrameSink(cc::FrameSinkId sink_id) {
88 compositor_frame_sinks_.erase(sink_id);
89 }
90
91 void DisplayCompositor::OnSurfaceCreated(const cc::SurfaceInfo& surface_info) {
92 DCHECK(thread_checker_.CalledOnValidThread());
93 DCHECK_GT(surface_info.device_scale_factor(), 0.0f);
94
95 if (client_)
96 client_->OnSurfaceCreated(surface_info);
97 }
98
99 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id,
100 bool* changed) {}
101
102 } // namespace ui
OLDNEW
« no previous file with comments | « components/display_compositor/display_compositor.h ('k') | content/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698