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

Side by Side Diff: components/mus/gpu/display_compositor/compositor_frame_sink_impl.cc

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

Powered by Google App Engine
This is Rietveld 408576698