| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "services/ui/public/cpp/compositor_frame_sink.h" | 5 #include "services/ui/public/cpp/compositor_frame_sink.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
| 9 #include "cc/output/compositor_frame_sink_client.h" | 9 #include "cc/output/compositor_frame_sink_client.h" |
| 10 #include "gpu/ipc/client/gpu_channel_host.h" | 10 #include "gpu/ipc/client/gpu_channel_host.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 return true; | 41 return true; |
| 42 } | 42 } |
| 43 | 43 |
| 44 void CompositorFrameSink::DetachFromClient() { | 44 void CompositorFrameSink::DetachFromClient() { |
| 45 client_->SetBeginFrameSource(nullptr); | 45 client_->SetBeginFrameSource(nullptr); |
| 46 begin_frame_source_.reset(); | 46 begin_frame_source_.reset(); |
| 47 surface_.reset(); | 47 surface_.reset(); |
| 48 cc::CompositorFrameSink::DetachFromClient(); | 48 cc::CompositorFrameSink::DetachFromClient(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void CompositorFrameSink::SwapBuffers(cc::CompositorFrame frame) { | 51 void CompositorFrameSink::SubmitCompositorFrame(cc::CompositorFrame frame) { |
| 52 // CompositorFrameSink owns WindowSurface, and so if CompositorFrameSink is | 52 // CompositorFrameSink owns WindowSurface, and so if CompositorFrameSink is |
| 53 // destroyed then SubmitCompositorFrame's callback will never get called. | 53 // destroyed then SubmitCompositorFrame's callback will never get called. |
| 54 // Thus, base::Unretained is safe here. | 54 // Thus, base::Unretained is safe here as |client_| is valid as long as |this| |
| 55 // is. |
| 55 surface_->SubmitCompositorFrame( | 56 surface_->SubmitCompositorFrame( |
| 56 std::move(frame), base::Bind(&CompositorFrameSink::SwapBuffersComplete, | 57 std::move(frame), |
| 57 base::Unretained(this))); | 58 base::Bind(&cc::CompositorFrameSinkClient::DidReceiveCompositorFrameAck, |
| 59 base::Unretained(client_))); |
| 58 } | 60 } |
| 59 | 61 |
| 60 void CompositorFrameSink::OnResourcesReturned( | 62 void CompositorFrameSink::OnResourcesReturned( |
| 61 ui::WindowSurface* surface, | 63 ui::WindowSurface* surface, |
| 62 const cc::ReturnedResourceArray& resources) { | 64 const cc::ReturnedResourceArray& resources) { |
| 63 client_->ReclaimResources(resources); | 65 client_->ReclaimResources(resources); |
| 64 } | 66 } |
| 65 | 67 |
| 66 void CompositorFrameSink::SwapBuffersComplete() { | |
| 67 client_->DidSwapBuffersComplete(); | |
| 68 } | |
| 69 | |
| 70 } // namespace ui | 68 } // namespace ui |
| OLD | NEW |