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

Side by Side Diff: components/exo/exo_compositor_frame_sink.cc

Issue 2493223002: Change exo::SurfaceFactoryOwner to exo::ExoCompositorFrameSink (Closed)
Patch Set: Added ExoCompositorFrameSink::SubmitCompositorFrame(). 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 "components/exo/exo_compositor_frame_sink.h"
6
7 #include "cc/surfaces/surface_manager.h"
8 #include "ui/aura/env.h"
9
10 namespace exo {
11
12 ////////////////////////////////////////////////////////////////////////////////
13 // ExoComopositorFrameSink, public:
14
15 ExoCompositorFrameSink::ExoCompositorFrameSink(
16 const cc::FrameSinkId& frame_sink_id,
17 cc::SurfaceManager* surface_manager)
18 : frame_sink_id_(frame_sink_id),
19 surface_manager_(surface_manager),
20 surface_factory_(frame_sink_id, surface_manager, this) {
21 surface_manager_->RegisterFrameSinkId(frame_sink_id_);
22 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this);
23 }
24
25 ////////////////////////////////////////////////////////////////////////////////
26 // cc::SurfaceFactoryClient overrides:
27
28 void ExoCompositorFrameSink::ReturnResources(
29 const cc::ReturnedResourceArray& resources) {
30 for (auto& resource : resources) {
31 auto it = release_callbacks_.find(resource.id);
32 DCHECK(it != release_callbacks_.end());
33 it->second.second->Run(resource.sync_token, resource.lost);
34 release_callbacks_.erase(it);
35 }
36 }
37
38 void ExoCompositorFrameSink::WillDrawSurface(const cc::LocalFrameId& id,
39 const gfx::Rect& damage_rect) {}
40
41 void ExoCompositorFrameSink::SetBeginFrameSource(
42 cc::BeginFrameSource* begin_frame_source) {
43 if (begin_frame_source_ && added_frame_observer_) {
44 begin_frame_source_->RemoveObserver(this);
45 added_frame_observer_ = false;
46 }
47 begin_frame_source_ = begin_frame_source;
48 UpdateNeedsBeginFrameInternal();
49 }
50
51 ////////////////////////////////////////////////////////////////////////////////
52 // To be cc::mojom::MojoCompositorFrameSink overrides:
53
54 void ExoCompositorFrameSink::SubmitCompositorFrame(cc::CompositorFrame frame) {
55 cc::LocalFrameId old_local_frame_id = local_frame_id_;
56 if (!local_frame_id_.is_valid() /* || needs_commit_to_new_surface_*/) {
Fady Samuel 2016/11/15 23:19:46 Remove commented out code.
Alex Z. 2016/12/07 21:13:43 Done.
57 local_frame_id_ = id_allocator_.GenerateId();
58 surface_factory_.Create(local_frame_id_);
59 }
60 // UpdateSurface(true); // surface_factory.SubmitCompositorFrame happens here
Fady Samuel 2016/11/15 23:19:46 Remove commented out code
Alex Z. 2016/12/07 21:13:43 Done.
61 surface_factory_.SubmitCompositorFrame(local_frame_id_, std::move(frame),
62 cc::SurfaceFactory::DrawCallback());
63 if (old_local_frame_id.is_valid() && old_local_frame_id != local_frame_id_) {
64 surface_factory_.SetPreviousFrameSurface(local_frame_id_,
65 old_local_frame_id);
66 surface_factory_.Destroy(old_local_frame_id);
67 }
68 }
69
70 ////////////////////////////////////////////////////////////////////////////////
71 // cc::BeginFrameObserver overrides:
72
73 void ExoCompositorFrameSink::OnBeginFrame(const cc::BeginFrameArgs& args) {
74 UpdateNeedsBeginFrameInternal();
75 last_begin_frame_args_ = args;
76 }
77
78 const cc::BeginFrameArgs& ExoCompositorFrameSink::LastUsedBeginFrameArgs()
79 const {
80 return last_begin_frame_args_;
81 }
82
83 void ExoCompositorFrameSink::OnBeginFrameSourcePausedChanged(bool paused) {}
84
85 ////////////////////////////////////////////////////////////////////////////////
86 // ExoComopositorFrameSink, private:
87
88 ExoCompositorFrameSink::~ExoCompositorFrameSink() {
89 if (surface_factory_.manager())
90 surface_factory_.manager()->InvalidateFrameSinkId(frame_sink_id_);
91
92 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id());
93 }
94
95 void ExoCompositorFrameSink::UpdateNeedsBeginFrameInternal() {
96 if (!begin_frame_source_)
97 return;
98
99 if (needs_begin_frame_ == added_frame_observer_)
100 return;
101
102 added_frame_observer_ = needs_begin_frame_;
103 if (needs_begin_frame_)
104 begin_frame_source_->AddObserver(this);
105 else
106 begin_frame_source_->RemoveObserver(this);
107 }
108
109 void ExoCompositorFrameSink::DidRecieveCompositorFrameAck() {
110 // TODO(staraz): Clean up resources
111 ack_pending_count_--;
112 }
113
114 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698