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

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

Issue 2493223002: Change exo::SurfaceFactoryOwner to exo::ExoCompositorFrameSink (Closed)
Patch Set: Moved CompositorFrameSink implementation details in to CompositorFrameSinkSupport; addressed commen… 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/gamepad_unittest.cc » ('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 CompositorFrameSinkHolder::CompositorFrameSinkHolder(
15 cc::mojom::MojoCompositorFrameSinkPtr compositor_frame_sink,
16 base::WeakPtr<Surface> surface,
17 cc::mojom::MojoCompositorFrameSinkClientRequest request)
18 : compositor_frame_sink_(std::move(compositor_frame_sink)),
19 surface_(surface),
20 begin_frame_source_(base::MakeUnique<cc::ExternalBeginFrameSource>(this)),
21 binding_(this, std::move(request)) {}
22
23 bool CompositorFrameSinkHolder::HasReleaseCallbacks(cc::ResourceId id) {
24 return release_callbacks_.count(id);
25 }
26
27 bool CompositorFrameSinkHolder::IsReleaseCallbacksEmpty() {
28 return release_callbacks_.size() == 0;
29 }
30
31 void CompositorFrameSinkHolder::AddResourceReleaseCallback(
32 cc::ResourceId id,
33 std::unique_ptr<cc::SingleReleaseCallback> callback) {
34 release_callbacks_[id] = std::make_pair(this, std::move(callback));
35 }
36
37 void CompositorFrameSinkHolder::ActivateFrameCallbacks(
38 std::list<FrameCallback>& frame_callbacks) {
39 active_frame_callbacks_.splice(active_frame_callbacks_.end(),
40 frame_callbacks);
41 }
42
43 void CompositorFrameSinkHolder::CancelFrameCallbacks() {
44 // Call pending frame callbacks with a null frame time to indicate that they
45 // have been cancelled.
46 for (const auto& frame_callback : active_frame_callbacks_)
47 frame_callback.Run(base::TimeTicks());
48 }
49
50 void CompositorFrameSinkHolder::EvictFrame() {
Fady Samuel 2016/12/06 20:14:40 How about just providing an accessor to cc::mojom:
Alex Z. 2016/12/06 21:09:38 Done.
51 compositor_frame_sink_->EvictFrame();
52 }
53
54 void CompositorFrameSinkHolder::UpdateNeedsBeginFrame() {
55 if (!begin_frame_source_)
56 return;
57
58 bool needs_begin_frame = !active_frame_callbacks_.empty();
59 if (needs_begin_frame == needs_begin_frame_)
60 return;
61
62 needs_begin_frame_ = needs_begin_frame;
63 OnNeedsBeginFrames(needs_begin_frame_);
64 }
65
66 void CompositorFrameSinkHolder::SetNeedsBeginFrame(bool needs_begin_frame) {
67 needs_begin_frame_ = needs_begin_frame;
68 OnNeedsBeginFrames(needs_begin_frame);
69 }
70
71 void CompositorFrameSinkHolder::SubmitCompositorFrame(
72 const cc::LocalFrameId& local_frame_id,
73 cc::CompositorFrame frame) {
74 if (compositor_frame_sink_) {
75 compositor_frame_sink_->SubmitCompositorFrame(local_frame_id,
76 std::move(frame));
77 }
78 }
79
80 ////////////////////////////////////////////////////////////////////////////////
81 // cc::mojom::MojoCompositorFrameSinkClient overrides:
82
83 void CompositorFrameSinkHolder::DidReceiveCompositorFrameAck() {
84 // TODO(staraz): Implement this
85 }
86
87 void CompositorFrameSinkHolder::OnBeginFrame(const cc::BeginFrameArgs& args) {
88 while (!active_frame_callbacks_.empty()) {
89 active_frame_callbacks_.front().Run(args.frame_time);
90 active_frame_callbacks_.pop_front();
91 }
92 begin_frame_source_->OnBeginFrame(args);
93 }
94
95 void CompositorFrameSinkHolder::ReclaimResources(
96 const cc::ReturnedResourceArray& resources) {
97 scoped_refptr<CompositorFrameSinkHolder> holder(this);
98 for (auto& resource : resources) {
99 auto it = release_callbacks_.find(resource.id);
100 DCHECK(it != release_callbacks_.end());
101 it->second.second->Run(resource.sync_token, resource.lost);
102 release_callbacks_.erase(it);
103 }
104 }
105
106 ////////////////////////////////////////////////////////////////////////////////
107 // cc::BeginFrameObserver:
108 const cc::BeginFrameArgs& CompositorFrameSinkHolder::LastUsedBeginFrameArgs()
109 const {
110 return last_begin_frame_args_;
111 }
112
113 void CompositorFrameSinkHolder::OnBeginFrameSourcePausedChanged(bool paused) {}
114
115 ////////////////////////////////////////////////////////////////////////////////
116 // ExoComopositorFrameSink, private:
117
118 CompositorFrameSinkHolder::~CompositorFrameSinkHolder() {}
119
120 void CompositorFrameSinkHolder::WillDrawSurface() {
121 if (surface_)
122 surface_->WillDraw();
123
124 UpdateNeedsBeginFrame();
125 }
126
127 ////////////////////////////////////////////////////////////////////////////////
128 // cc::ExternalBeginFrameSouceClient:
129 void CompositorFrameSinkHolder::OnNeedsBeginFrames(bool needs_begin_frames) {
130 compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames);
131 }
132 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/compositor_frame_sink_holder.h ('k') | components/exo/gamepad_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698