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

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

Issue 2493223002: Change exo::SurfaceFactoryOwner to exo::ExoCompositorFrameSink (Closed)
Patch Set: Override DesktopMediaListAshTest::TearDown() to reset list_ Created 4 years 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 | « components/exo/compositor_frame_sink_holder.h ('k') | components/exo/surface.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 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/compositor_frame_sink_holder.h"
6
7 #include "cc/resources/returned_resource.h"
8 #include "components/exo/surface.h"
9
10 namespace exo {
11
12 ////////////////////////////////////////////////////////////////////////////////
13 // CompositorFrameSinkHolder, public:
14
15 CompositorFrameSinkHolder::CompositorFrameSinkHolder(
16 Surface* surface,
17 std::unique_ptr<CompositorFrameSink> frame_sink,
18 cc::mojom::MojoCompositorFrameSinkClientRequest request)
19 : surface_(surface),
20 frame_sink_(std::move(frame_sink)),
21 begin_frame_source_(base::MakeUnique<cc::ExternalBeginFrameSource>(this)),
22 binding_(this, std::move(request)),
23 weak_factory_(this) {
24 surface_->AddSurfaceObserver(this);
25 }
26
27 bool CompositorFrameSinkHolder::HasReleaseCallbackForResource(
28 cc::ResourceId id) {
29 return release_callbacks_.find(id) != release_callbacks_.end();
30 }
31
32 void CompositorFrameSinkHolder::AddResourceReleaseCallback(
33 cc::ResourceId id,
34 std::unique_ptr<cc::SingleReleaseCallback> callback) {
35 release_callbacks_[id] = std::make_pair(this, std::move(callback));
36 }
37
38 void CompositorFrameSinkHolder::ActivateFrameCallbacks(
39 std::list<FrameCallback>* frame_callbacks) {
40 active_frame_callbacks_.splice(active_frame_callbacks_.end(),
41 *frame_callbacks);
42 UpdateNeedsBeginFrame();
43 }
44
45 void CompositorFrameSinkHolder::CancelFrameCallbacks() {
46 // Call pending frame callbacks with a null frame time to indicate that they
47 // have been cancelled.
48 for (const auto& frame_callback : active_frame_callbacks_)
49 frame_callback.Run(base::TimeTicks());
50 }
51
52 void CompositorFrameSinkHolder::SetNeedsBeginFrame(bool needs_begin_frame) {
53 needs_begin_frame_ = needs_begin_frame;
54 OnNeedsBeginFrames(needs_begin_frame);
55 }
56
57 void CompositorFrameSinkHolder::Satisfy(const cc::SurfaceSequence& sequence) {
58 frame_sink_->Satisfy(sequence);
59 }
60
61 void CompositorFrameSinkHolder::Require(const cc::SurfaceId& id,
62 const cc::SurfaceSequence& sequence) {
63 frame_sink_->Require(id.local_frame_id(), sequence);
64 }
65
66 ////////////////////////////////////////////////////////////////////////////////
67 // cc::mojom::MojoCompositorFrameSinkClient overrides:
68
69 void CompositorFrameSinkHolder::DidReceiveCompositorFrameAck() {
70 // TODO(staraz): Implement this
71 }
72
73 void CompositorFrameSinkHolder::OnBeginFrame(const cc::BeginFrameArgs& args) {
74 while (!active_frame_callbacks_.empty()) {
75 active_frame_callbacks_.front().Run(args.frame_time);
76 active_frame_callbacks_.pop_front();
77 }
78 begin_frame_source_->OnBeginFrame(args);
79 }
80
81 void CompositorFrameSinkHolder::ReclaimResources(
82 const cc::ReturnedResourceArray& resources) {
83 for (auto& resource : resources) {
84 auto it = release_callbacks_.find(resource.id);
85 DCHECK(it != release_callbacks_.end());
86 std::unique_ptr<cc::SingleReleaseCallback> callback =
87 std::move(it->second.second);
88 release_callbacks_.erase(it);
89 callback->Run(resource.sync_token, resource.lost);
90 }
91 }
92
93 void CompositorFrameSinkHolder::WillDrawSurface() {
94 if (surface_)
95 surface_->WillDraw();
96
97 UpdateNeedsBeginFrame();
98 }
99
100 ////////////////////////////////////////////////////////////////////////////////
101 // cc::BeginFrameObserver overrides:
102
103 const cc::BeginFrameArgs& CompositorFrameSinkHolder::LastUsedBeginFrameArgs()
104 const {
105 return last_begin_frame_args_;
106 }
107
108 void CompositorFrameSinkHolder::OnBeginFrameSourcePausedChanged(bool paused) {}
109
110 ////////////////////////////////////////////////////////////////////////////////
111 // cc::ExternalBeginFrameSouceClient overrides:
112
113 void CompositorFrameSinkHolder::OnNeedsBeginFrames(bool needs_begin_frames) {
114 frame_sink_->SetNeedsBeginFrame(needs_begin_frames);
115 }
116
117 ////////////////////////////////////////////////////////////////////////////////
118 // SurfaceObserver overrides:
119
120 void CompositorFrameSinkHolder::OnSurfaceDestroying(Surface* surface) {
121 surface_->RemoveSurfaceObserver(this);
122 surface_ = nullptr;
123 }
124
125 ////////////////////////////////////////////////////////////////////////////////
126 // ExoComopositorFrameSink, private:
127
128 CompositorFrameSinkHolder::~CompositorFrameSinkHolder() {}
129
130 void CompositorFrameSinkHolder::UpdateNeedsBeginFrame() {
131 if (!begin_frame_source_)
132 return;
133
134 bool needs_begin_frame = !active_frame_callbacks_.empty();
135 if (needs_begin_frame == needs_begin_frame_)
136 return;
137
138 needs_begin_frame_ = needs_begin_frame;
139 OnNeedsBeginFrames(needs_begin_frame_);
140 }
141
142 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/compositor_frame_sink_holder.h ('k') | components/exo/surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698