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

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

Issue 2768563002: Move DisplayCompositor code to new component. (Closed)
Patch Set: Rebase. Created 3 years, 9 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
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 #include "components/display_compositor/gpu_compositor_frame_sink.h"
6
7 namespace display_compositor {
8
9 GpuCompositorFrameSink::GpuCompositorFrameSink(
10 GpuCompositorFrameSinkDelegate* delegate,
11 cc::SurfaceManager* surface_manager,
12 const cc::FrameSinkId& frame_sink_id,
13 cc::mojom::MojoCompositorFrameSinkRequest request,
14 cc::mojom::MojoCompositorFrameSinkPrivateRequest
15 compositor_frame_sink_private_request,
16 cc::mojom::MojoCompositorFrameSinkClientPtr client)
17 : delegate_(delegate),
18 support_(base::MakeUnique<cc::CompositorFrameSinkSupport>(
19 this,
20 surface_manager,
21 frame_sink_id,
22 false /* is_root */,
23 true /* handles_frame_sink_id_invalidation */,
24 true /* needs_sync_points */)),
25 client_(std::move(client)),
26 compositor_frame_sink_binding_(this, std::move(request)),
27 compositor_frame_sink_private_binding_(
28 this,
29 std::move(compositor_frame_sink_private_request)) {
30 compositor_frame_sink_binding_.set_connection_error_handler(base::Bind(
31 &GpuCompositorFrameSink::OnClientConnectionLost, base::Unretained(this)));
32 compositor_frame_sink_private_binding_.set_connection_error_handler(
33 base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost,
34 base::Unretained(this)));
35 }
36
37 GpuCompositorFrameSink::~GpuCompositorFrameSink() {}
38
39 void GpuCompositorFrameSink::EvictFrame() {
40 support_->EvictFrame();
41 }
42
43 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) {
44 support_->SetNeedsBeginFrame(needs_begin_frame);
45 }
46
47 void GpuCompositorFrameSink::SubmitCompositorFrame(
48 const cc::LocalSurfaceId& local_surface_id,
49 cc::CompositorFrame frame) {
50 support_->SubmitCompositorFrame(local_surface_id, std::move(frame));
51 }
52
53 void GpuCompositorFrameSink::DidReceiveCompositorFrameAck() {
54 if (client_)
55 client_->DidReceiveCompositorFrameAck();
56 }
57
58 void GpuCompositorFrameSink::ClaimTemporaryReference(
59 const cc::SurfaceId& surface_id) {
60 support_->ClaimTemporaryReference(surface_id);
61 }
62
63 void GpuCompositorFrameSink::RequestCopyOfSurface(
64 std::unique_ptr<cc::CopyOutputRequest> request) {
65 support_->RequestCopyOfSurface(std::move(request));
66 }
67
68 void GpuCompositorFrameSink::OnBeginFrame(const cc::BeginFrameArgs& args) {
69 if (client_)
70 client_->OnBeginFrame(args);
71 }
72
73 void GpuCompositorFrameSink::ReclaimResources(
74 const cc::ReturnedResourceArray& resources) {
75 if (client_)
76 client_->ReclaimResources(resources);
77 }
78
79 void GpuCompositorFrameSink::WillDrawSurface(
80 const cc::LocalSurfaceId& local_surface_id,
81 const gfx::Rect& damage_rect) {
82 if (client_)
83 client_->WillDrawSurface(local_surface_id, damage_rect);
84 }
85
86 void GpuCompositorFrameSink::OnClientConnectionLost() {
87 client_connection_lost_ = true;
88 // Request destruction of |this| only if both connections are lost.
89 delegate_->OnClientConnectionLost(support_->frame_sink_id(),
90 private_connection_lost_);
91 }
92
93 void GpuCompositorFrameSink::OnPrivateConnectionLost() {
94 private_connection_lost_ = true;
95 // Request destruction of |this| only if both connections are lost.
96 delegate_->OnPrivateConnectionLost(support_->frame_sink_id(),
97 client_connection_lost_);
98 }
99
100 } // namespace display_compositor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698