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

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

Issue 2584953002: exo::CompositorFrameSinkHolder's release callbacks hold ref (Closed)
Patch Set: Removed unrelated changes Created 3 years, 12 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/exo/compositor_frame_sink_holder.h" 5 #include "components/exo/compositor_frame_sink_holder.h"
6 6
7 #include "cc/resources/returned_resource.h" 7 #include "cc/resources/returned_resource.h"
8 #include "components/exo/surface.h" 8 #include "components/exo/surface.h"
9 9
10 namespace exo { 10 namespace exo {
11 11
12 namespace {
13 void RunSingleReleaseCallback(cc::SingleReleaseCallback* callback,
reveman 2016/12/20 16:34:28 Can you bind cc::SingleReleaseCallback::Run direct
Alex Z. 2016/12/20 17:54:01 This wrapper is now needed for holding a reference
14 const gpu::SyncToken& sync_token,
15 bool is_lost) {
16 callback->Run(sync_token, is_lost);
17 }
18 } // namespace
19
12 //////////////////////////////////////////////////////////////////////////////// 20 ////////////////////////////////////////////////////////////////////////////////
13 // CompositorFrameSinkHolder, public: 21 // CompositorFrameSinkHolder, public:
14 22
15 CompositorFrameSinkHolder::CompositorFrameSinkHolder( 23 CompositorFrameSinkHolder::CompositorFrameSinkHolder(
16 Surface* surface, 24 Surface* surface,
17 std::unique_ptr<CompositorFrameSink> frame_sink, 25 std::unique_ptr<CompositorFrameSink> frame_sink,
18 cc::mojom::MojoCompositorFrameSinkClientRequest request) 26 cc::mojom::MojoCompositorFrameSinkClientRequest request)
19 : surface_(surface), 27 : surface_(surface),
20 frame_sink_(std::move(frame_sink)), 28 frame_sink_(std::move(frame_sink)),
21 begin_frame_source_(base::MakeUnique<cc::ExternalBeginFrameSource>(this)), 29 begin_frame_source_(base::MakeUnique<cc::ExternalBeginFrameSource>(this)),
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 void CompositorFrameSinkHolder::OnBeginFrame(const cc::BeginFrameArgs& args) { 81 void CompositorFrameSinkHolder::OnBeginFrame(const cc::BeginFrameArgs& args) {
74 while (!active_frame_callbacks_.empty()) { 82 while (!active_frame_callbacks_.empty()) {
75 active_frame_callbacks_.front().Run(args.frame_time); 83 active_frame_callbacks_.front().Run(args.frame_time);
76 active_frame_callbacks_.pop_front(); 84 active_frame_callbacks_.pop_front();
77 } 85 }
78 begin_frame_source_->OnBeginFrame(args); 86 begin_frame_source_->OnBeginFrame(args);
79 } 87 }
80 88
81 void CompositorFrameSinkHolder::ReclaimResources( 89 void CompositorFrameSinkHolder::ReclaimResources(
82 const cc::ReturnedResourceArray& resources) { 90 const cc::ReturnedResourceArray& resources) {
91 scoped_refptr<CompositorFrameSinkHolder> compositor_frame_sink_holder;
reveman 2016/12/20 16:34:28 This shouldn't be needed anymore, right?
Alex Z. 2016/12/20 17:54:01 CompositorFrameSinkHolder still gets destroyed too
83 for (auto& resource : resources) { 92 for (auto& resource : resources) {
84 auto it = release_callbacks_.find(resource.id); 93 auto it = release_callbacks_.find(resource.id);
85 DCHECK(it != release_callbacks_.end()); 94 DCHECK(it != release_callbacks_.end());
86 std::unique_ptr<cc::SingleReleaseCallback> callback = 95 compositor_frame_sink_holder = std::move(it->second.first);
87 std::move(it->second.second); 96 auto closure =
reveman 2016/12/20 16:34:28 nit: no need for this temporary variable. pass the
Alex Z. 2016/12/20 17:54:01 Done.
97 base::Bind(&RunSingleReleaseCallback, it->second.second.get(),
reveman 2016/12/20 16:34:28 it->second.second.get() shouldn't work. The callba
98 resource.sync_token, resource.lost);
99 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure);
reveman 2016/12/20 16:34:28 What if the message loop is shutdown before this g
Alex Z. 2016/12/20 17:54:01 It seems no matter how we invoke the Callback::Run
88 release_callbacks_.erase(it); 100 release_callbacks_.erase(it);
89 callback->Run(resource.sync_token, resource.lost);
90 } 101 }
91 } 102 }
92 103
93 void CompositorFrameSinkHolder::WillDrawSurface() { 104 void CompositorFrameSinkHolder::WillDrawSurface() {
94 if (surface_) 105 if (surface_)
95 surface_->WillDraw(); 106 surface_->WillDraw();
96 107
97 UpdateNeedsBeginFrame(); 108 UpdateNeedsBeginFrame();
98 } 109 }
99 110
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 144
134 bool needs_begin_frame = !active_frame_callbacks_.empty(); 145 bool needs_begin_frame = !active_frame_callbacks_.empty();
135 if (needs_begin_frame == needs_begin_frame_) 146 if (needs_begin_frame == needs_begin_frame_)
136 return; 147 return;
137 148
138 needs_begin_frame_ = needs_begin_frame; 149 needs_begin_frame_ = needs_begin_frame;
139 OnNeedsBeginFrames(needs_begin_frame_); 150 OnNeedsBeginFrames(needs_begin_frame_);
140 } 151 }
141 152
142 } // namespace exo 153 } // namespace exo
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698