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

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

Issue 2703503002: WIP: move OffscreenCanvas into new display compositor
Patch Set: Refine connection lost 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
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 "components/display_compositor/gpu_compositor_frame_sink.h" 5 #include "components/display_compositor/gpu_compositor_frame_sink.h"
6 6
7 #include "cc/surfaces/surface_reference.h" 7 #include "cc/surfaces/surface_reference.h"
8 8
9 namespace display_compositor { 9 namespace display_compositor {
10 10
11 GpuCompositorFrameSink::GpuCompositorFrameSink( 11 GpuCompositorFrameSink::GpuCompositorFrameSink(
12 GpuCompositorFrameSinkDelegate* delegate, 12 GpuCompositorFrameSinkDelegate* delegate,
13 std::unique_ptr<cc::CompositorFrameSinkSupport> support, 13 std::unique_ptr<cc::CompositorFrameSinkSupport> support,
14 cc::mojom::MojoCompositorFrameSinkPrivateRequest
15 compositor_frame_sink_private_request,
16 cc::mojom::MojoCompositorFrameSinkClientPtr client) 14 cc::mojom::MojoCompositorFrameSinkClientPtr client)
17 : delegate_(delegate), 15 : delegate_(delegate),
18 support_(std::move(support)), 16 support_(std::move(support)),
19 client_(std::move(client)), 17 client_(std::move(client)) {}
20 compositor_frame_sink_private_binding_(
21 this,
22 std::move(compositor_frame_sink_private_request)) {
23 compositor_frame_sink_private_binding_.set_connection_error_handler(
24 base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost,
25 base::Unretained(this)));
26 }
27 18
28 GpuCompositorFrameSink::~GpuCompositorFrameSink() {} 19 GpuCompositorFrameSink::~GpuCompositorFrameSink() {}
29 20
30 void GpuCompositorFrameSink::EvictFrame() { 21 void GpuCompositorFrameSink::EvictFrame() {
31 support_->EvictFrame(); 22 support_->EvictFrame();
32 } 23 }
33 24
34 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) { 25 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) {
35 support_->SetNeedsBeginFrame(needs_begin_frame); 26 support_->SetNeedsBeginFrame(needs_begin_frame);
36 } 27 }
(...skipping 11 matching lines...) Expand all
48 39
49 void GpuCompositorFrameSink::Satisfy(const cc::SurfaceSequence& sequence) { 40 void GpuCompositorFrameSink::Satisfy(const cc::SurfaceSequence& sequence) {
50 support_->Satisfy(sequence); 41 support_->Satisfy(sequence);
51 } 42 }
52 43
53 void GpuCompositorFrameSink::DidReceiveCompositorFrameAck() { 44 void GpuCompositorFrameSink::DidReceiveCompositorFrameAck() {
54 if (client_) 45 if (client_)
55 client_->DidReceiveCompositorFrameAck(); 46 client_->DidReceiveCompositorFrameAck();
56 } 47 }
57 48
58 void GpuCompositorFrameSink::AddChildFrameSink(
59 const cc::FrameSinkId& child_frame_sink_id) {
60 support_->AddChildFrameSink(child_frame_sink_id);
61 }
62
63 void GpuCompositorFrameSink::RemoveChildFrameSink(
64 const cc::FrameSinkId& child_frame_sink_id) {
65 support_->RemoveChildFrameSink(child_frame_sink_id);
66 }
67
68 void GpuCompositorFrameSink::OnBeginFrame(const cc::BeginFrameArgs& args) { 49 void GpuCompositorFrameSink::OnBeginFrame(const cc::BeginFrameArgs& args) {
69 if (client_) 50 if (client_)
70 client_->OnBeginFrame(args); 51 client_->OnBeginFrame(args);
71 } 52 }
72 53
73 void GpuCompositorFrameSink::ReclaimResources( 54 void GpuCompositorFrameSink::ReclaimResources(
74 const cc::ReturnedResourceArray& resources) { 55 const cc::ReturnedResourceArray& resources) {
75 if (client_) 56 if (client_)
76 client_->ReclaimResources(resources); 57 client_->ReclaimResources(resources);
77 } 58 }
78 59
79 void GpuCompositorFrameSink::WillDrawSurface() { 60 void GpuCompositorFrameSink::WillDrawSurface() {
80 if (client_) 61 if (client_)
81 client_->WillDrawSurface(); 62 client_->WillDrawSurface();
82 } 63 }
83 64
84 void GpuCompositorFrameSink::OnClientConnectionLost() { 65 void GpuCompositorFrameSink::OnClientConnectionLost() {
85 client_connection_lost_ = true; 66 SetClientConnectionLost(true);
86 // Request destruction of |this| only if both connections are lost. 67 // Request destruction of |this| only if both connections are lost.
87 delegate_->OnClientConnectionLost(support_->frame_sink_id(), 68 delegate_->OnClientConnectionLost(support_->frame_sink_id(),
88 private_connection_lost_); 69 GetPrivateConnectionLost());
89 }
90
91 void GpuCompositorFrameSink::OnPrivateConnectionLost() {
92 private_connection_lost_ = true;
93 // Request destruction of |this| only if both connections are lost.
94 delegate_->OnPrivateConnectionLost(support_->frame_sink_id(),
95 client_connection_lost_);
96 } 70 }
97 71
98 } // namespace display_compositor 72 } // namespace display_compositor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698