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::DeleteMailbox(const gpu::Mailbox& mailbox, |
| 191 const gpu::SyncToken& sync_token, |
| 192 bool is_lost) { |
| 193 auto callback_iter = release_callbacks_.find(mailbox); |
| 194 if (!release_callbacks_.count(mailbox)) { |
| 195 DLOG(ERROR) << "Attempted to delete a mailbox that does not exist"; |
| 196 return; |
| 197 } |
| 198 callback_iter->second->Run(sync_token, is_lost); |
| 199 release_callbacks_.erase(callback_iter); |
| 200 } |
| 201 |
| 202 void CompositorFrameSinkSupport::OnTextureReceived( |
| 203 CopyOutputRequest::CopyOutputRequestCallback callback, |
| 204 std::unique_ptr<CopyOutputResult> result) { |
| 205 DCHECK(result->HasTexture()); |
| 206 DCHECK(!release_callbacks_.count(result->mailbox())); |
| 207 release_callbacks_[result->mailbox()] = result->TakeReleaseCallback(); |
| 208 callback.Run(std::move(result)); |
| 209 } |
| 210 |
182 } // namespace cc | 211 } // namespace cc |
OLD | NEW |