 Chromium Code Reviews
 Chromium Code Reviews Issue 2676353002:
  MojoCompositorFrameSinkPrivate should support copy requests  (Closed)
    
  
    Issue 2676353002:
  MojoCompositorFrameSinkPrivate should support copy requests  (Closed) 
  | Index: cc/surfaces/compositor_frame_sink_support.cc | 
| diff --git a/cc/surfaces/compositor_frame_sink_support.cc b/cc/surfaces/compositor_frame_sink_support.cc | 
| index 95222ed1defc2354e69faf20ac12300a4b439b61..4887b71d916a4e8aff3e8b2a208e2cab9603d2f3 100644 | 
| --- a/cc/surfaces/compositor_frame_sink_support.cc | 
| +++ b/cc/surfaces/compositor_frame_sink_support.cc | 
| @@ -179,4 +179,34 @@ void CompositorFrameSinkSupport::UpdateNeedsBeginFramesInternal() { | 
| begin_frame_source_->RemoveObserver(this); | 
| } | 
| +void CompositorFrameSinkSupport::RequestCopyOfSurface( | 
| + std::unique_ptr<CopyOutputRequest> request) { | 
| + request->set_result_callback( | 
| + base::Bind(&CompositorFrameSinkSupport::OnTextureReceived, | 
| + weak_factory_.GetWeakPtr(), request->result_callback())); | 
| + surface_factory_.RequestCopyOfSurface(std::move(request)); | 
| +} | 
| + | 
| +void CompositorFrameSinkSupport::ReleaseCopyOfSurface( | 
| + const gpu::Mailbox& mailbox, | 
| + const gpu::SyncToken& sync_token, | 
| + bool is_lost) { | 
| + auto callback_iter = release_callbacks_.find(mailbox); | 
| + if (!release_callbacks_.count(mailbox)) { | 
| + DLOG(ERROR) << "Attempted to delete a mailbox that does not exist"; | 
| + return; | 
| + } | 
| + callback_iter->second->Run(sync_token, is_lost); | 
| + release_callbacks_.erase(callback_iter); | 
| +} | 
| + | 
| +void CompositorFrameSinkSupport::OnTextureReceived( | 
| + CopyOutputRequest::CopyOutputRequestCallback callback, | 
| + std::unique_ptr<CopyOutputResult> result) { | 
| + DCHECK(result->HasTexture()); | 
| + DCHECK(!release_callbacks_.count(result->mailbox())); | 
| + release_callbacks_[result->mailbox()] = result->TakeReleaseCallback(); | 
| + 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
 | 
| +} | 
| + | 
| } // namespace cc |