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

Side by Side Diff: services/ui/ws/display_client_compositor_frame_sink.cc

Issue 2890913002: Add CompositorFrameSinkClientBinding To Be Used By FrameGenerator (Closed)
Patch Set: Remove redundant SetNeedsBeginFrame Created 3 years, 7 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/ws/display_client_compositor_frame_sink.h ('k') | services/ui/ws/frame_generator.h » ('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 "services/ui/ws/display_client_compositor_frame_sink.h"
6
7 #include "base/threading/thread_checker.h"
8 #include "cc/output/compositor_frame_sink_client.h"
9
10 namespace ui {
11 namespace ws {
12
13 DisplayClientCompositorFrameSink::DisplayClientCompositorFrameSink(
14 const cc::FrameSinkId& frame_sink_id,
15 cc::mojom::MojoCompositorFrameSinkAssociatedPtr compositor_frame_sink,
16 cc::mojom::DisplayPrivateAssociatedPtr display_private,
17 cc::mojom::MojoCompositorFrameSinkClientRequest client_request)
18 : cc::CompositorFrameSink(nullptr, nullptr, nullptr, nullptr),
19 compositor_frame_sink_(std::move(compositor_frame_sink)),
20 client_binding_(this, std::move(client_request)),
21 display_private_(std::move(display_private)),
22 frame_sink_id_(frame_sink_id) {}
23
24 DisplayClientCompositorFrameSink::~DisplayClientCompositorFrameSink() {}
25
26 bool DisplayClientCompositorFrameSink::BindToClient(
27 cc::CompositorFrameSinkClient* client) {
28 if (!cc::CompositorFrameSink::BindToClient(client))
29 return false;
30 DCHECK(!thread_checker_);
31 thread_checker_ = base::MakeUnique<base::ThreadChecker>();
32
33 begin_frame_source_ = base::MakeUnique<cc::ExternalBeginFrameSource>(this);
34
35 client->SetBeginFrameSource(begin_frame_source_.get());
36 return true;
37 }
38
39 void DisplayClientCompositorFrameSink::DetachFromClient() {
40 client_->SetBeginFrameSource(nullptr);
41 begin_frame_source_.reset();
42 cc::CompositorFrameSink::DetachFromClient();
43 }
44
45 void DisplayClientCompositorFrameSink::SubmitCompositorFrame(
46 cc::CompositorFrame frame) {
47 DCHECK(thread_checker_->CalledOnValidThread());
48 if (!compositor_frame_sink_)
49 return;
50
51 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber,
52 frame.metadata.begin_frame_ack.sequence_number);
53
54 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size();
55
56 if (!local_surface_id_.is_valid() ||
57 frame_size != last_submitted_frame_size_) {
58 local_surface_id_ = id_allocator_.GenerateId();
59 display_private_->ResizeDisplay(frame_size);
60 }
61 display_private_->SetLocalSurfaceId(local_surface_id_,
62 frame.metadata.device_scale_factor);
63 compositor_frame_sink_->SubmitCompositorFrame(local_surface_id_,
64 std::move(frame));
65 last_submitted_frame_size_ = frame_size;
66 }
67
68 void DisplayClientCompositorFrameSink::DidReceiveCompositorFrameAck(
69 const cc::ReturnedResourceArray& resources) {
70 DCHECK(thread_checker_->CalledOnValidThread());
71 if (!client_)
72 return;
73 client_->ReclaimResources(resources);
74 client_->DidReceiveCompositorFrameAck();
75 }
76
77 void DisplayClientCompositorFrameSink::OnBeginFrame(
78 const cc::BeginFrameArgs& begin_frame_args) {
79 DCHECK(thread_checker_->CalledOnValidThread());
80 begin_frame_source_->OnBeginFrame(begin_frame_args);
81 }
82
83 void DisplayClientCompositorFrameSink::ReclaimResources(
84 const cc::ReturnedResourceArray& resources) {
85 DCHECK(thread_checker_->CalledOnValidThread());
86 if (!client_)
87 return;
88 client_->ReclaimResources(resources);
89 }
90
91 void DisplayClientCompositorFrameSink::OnNeedsBeginFrames(
92 bool needs_begin_frames) {
93 DCHECK(thread_checker_->CalledOnValidThread());
94 compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames);
95 }
96
97 void DisplayClientCompositorFrameSink::OnDidFinishFrame(
98 const cc::BeginFrameAck& ack) {
99 // If there was damage, the submitted CompositorFrame includes the ack.
100 if (!ack.has_damage)
101 compositor_frame_sink_->BeginFrameDidNotSwap(ack);
102 }
103
104 } // namespace ws
105 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/display_client_compositor_frame_sink.h ('k') | services/ui/ws/frame_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698