OLD | NEW |
---|---|
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 "cc/surfaces/compositor_frame_sink_support.h" | 5 #include "cc/surfaces/compositor_frame_sink_support.h" |
6 | 6 |
7 #include "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
8 #include "cc/scheduler/begin_frame_source.h" | 8 #include "cc/scheduler/begin_frame_source.h" |
9 #include "cc/surfaces/compositor_frame_sink_support_client.h" | 9 #include "cc/surfaces/compositor_frame_sink_support_client.h" |
10 #include "cc/surfaces/display.h" | 10 #include "cc/surfaces/display.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 if (needs_begin_frame_ == added_frame_observer_) | 172 if (needs_begin_frame_ == added_frame_observer_) |
173 return; | 173 return; |
174 | 174 |
175 added_frame_observer_ = needs_begin_frame_; | 175 added_frame_observer_ = needs_begin_frame_; |
176 if (needs_begin_frame_) | 176 if (needs_begin_frame_) |
177 begin_frame_source_->AddObserver(this); | 177 begin_frame_source_->AddObserver(this); |
178 else | 178 else |
179 begin_frame_source_->RemoveObserver(this); | 179 begin_frame_source_->RemoveObserver(this); |
180 } | 180 } |
181 | 181 |
182 void CompositorFrameSinkSupport::RequestCopyOfSurface( | |
183 std::unique_ptr<CopyOutputRequest> request) { | |
184 request->set_result_callback( | |
185 base::Bind(&CompositorFrameSinkSupport::OnTextureReceived, | |
186 weak_factory_.GetWeakPtr(), request->result_callback())); | |
187 surface_factory_.RequestCopyOfSurface(std::move(request)); | |
188 } | |
189 | |
190 void CompositorFrameSinkSupport::ReleaseCopyOfSurface( | |
191 const gpu::Mailbox& mailbox, | |
192 const gpu::SyncToken& sync_token, | |
193 bool is_lost) { | |
194 auto callback_iter = release_callbacks_.find(mailbox); | |
195 if (!release_callbacks_.count(mailbox)) { | |
196 DLOG(ERROR) << "Attempted to delete a mailbox that does not exist"; | |
197 return; | |
198 } | |
199 callback_iter->second->Run(sync_token, is_lost); | |
200 release_callbacks_.erase(callback_iter); | |
201 } | |
202 | |
203 void CompositorFrameSinkSupport::OnTextureReceived( | |
204 CopyOutputRequest::CopyOutputRequestCallback callback, | |
205 std::unique_ptr<CopyOutputResult> result) { | |
206 DCHECK(result->HasTexture()); | |
207 DCHECK(!release_callbacks_.count(result->mailbox())); | |
208 release_callbacks_[result->mailbox()] = result->TakeReleaseCallback(); | |
209 callback.Run(std::move(result)); | |
danakj
2017/02/06 23:02:12
The result here should have a release callback to
Saman Sami
2017/02/06 23:09:54
I can't set the release callback here. Remember th
danakj
2017/02/06 23:24:08
There should be a release callback made when it co
danakj
2017/02/06 23:24:44
And if you don't do this here, how does the textur
| |
210 } | |
211 | |
182 } // namespace cc | 212 } // namespace cc |
OLD | NEW |