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

Side by Side Diff: services/ui/gpu/display_compositor/compositor_frame_sink_impl.cc

Issue 2441093002: Delete dead (and obsolete) display compositor API (Closed)
Patch Set: Created 4 years, 1 month 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 2016 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/gpu/display_compositor/compositor_frame_sink_impl.h"
6
7 #include "cc/ipc/compositor_frame.mojom.h"
8 #include "cc/surfaces/surface_factory.h"
9 #include "services/ui/gpu/display_compositor/compositor_frame_sink_delegate.h"
10
11 namespace ui {
12 namespace gpu {
13
14 CompositorFrameSinkImpl::CompositorFrameSinkImpl(
15 CompositorFrameSinkDelegate* delegate,
16 int sink_id,
17 const scoped_refptr<DisplayCompositor>& surfaces_state,
18 mojo::InterfaceRequest<mojom::CompositorFrameSink> request,
19 mojom::CompositorFrameSinkClientPtr client)
20 : delegate_(delegate),
21 surfaces_state_(surfaces_state),
22 sink_id_(sink_id),
23 begin_frame_source_(nullptr),
24 needs_begin_frame_(false),
25 factory_(surfaces_state->manager(), this),
26 client_(std::move(client)),
27 binding_(this, std::move(request)) {
28 DCHECK(delegate_);
29 binding_.set_connection_error_handler(base::Bind(
30 &CompositorFrameSinkImpl::OnConnectionLost, base::Unretained(this)));
31 }
32
33 CompositorFrameSinkImpl::~CompositorFrameSinkImpl() {}
34
35 void CompositorFrameSinkImpl::SetNeedsBeginFrame(bool needs_begin_frame) {
36 if (needs_begin_frame_ == needs_begin_frame)
37 return;
38
39 needs_begin_frame_ = needs_begin_frame;
40 if (begin_frame_source_) {
41 if (needs_begin_frame_)
42 begin_frame_source_->AddObserver(this);
43 else
44 begin_frame_source_->RemoveObserver(this);
45 }
46 }
47
48 void CompositorFrameSinkImpl::SubmitCompositorFrame(
49 cc::CompositorFrame compositor_frame,
50 const SubmitCompositorFrameCallback& callback) {
51 gfx::Size frame_size =
52 compositor_frame.delegated_frame_data->render_pass_list.back()
53 ->output_rect.size();
54 if (frame_size.IsEmpty() || frame_size != last_submitted_frame_size_) {
55 if (!surface_id_.is_null())
56 factory_.Destroy(surface_id_);
57 // TODO(fsamuel): The allocator should live on CompositorFrameSinkFactory.
58 surface_id_ = delegate_->GenerateSurfaceId();
59 factory_.Create(surface_id_);
60 last_submitted_frame_size_ = frame_size;
61 }
62 factory_.SubmitCompositorFrame(surface_id_, std::move(compositor_frame),
63 callback);
64 }
65
66 void CompositorFrameSinkImpl::ReturnResources(
67 const cc::ReturnedResourceArray& resources) {
68 if (!client_)
69 return;
70
71 client_->ReturnResources(mojo::Array<cc::ReturnedResource>::From(resources));
72 }
73
74 void CompositorFrameSinkImpl::WillDrawSurface(const cc::SurfaceId& surface_id,
75 const gfx::Rect& damage_rect) {
76 NOTIMPLEMENTED();
77 }
78
79 void CompositorFrameSinkImpl::SetBeginFrameSource(
80 cc::BeginFrameSource* begin_frame_source) {
81 begin_frame_source_ = begin_frame_source;
82 }
83
84 void CompositorFrameSinkImpl::OnBeginFrame(const cc::BeginFrameArgs& args) {
85 // TODO(fsamuel): Implement this.
86 }
87
88 const cc::BeginFrameArgs& CompositorFrameSinkImpl::LastUsedBeginFrameArgs()
89 const {
90 // TODO(fsamuel): Implement this.
91 return last_used_begin_frame_args_;
92 }
93
94 void CompositorFrameSinkImpl::OnBeginFrameSourcePausedChanged(bool paused) {
95 // TODO(fsamuel): Implement this.
96 }
97
98 void CompositorFrameSinkImpl::OnConnectionLost() {
99 delegate_->CompositorFrameSinkConnectionLost(sink_id_);
100 }
101
102 } // namespace gpu
103 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698