Chromium Code Reviews| 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. |
| 55 surface_->SubmitCompositorFrame( | 55 surface_->SubmitCompositorFrame( |
| 56 std::move(frame), base::Bind(&CompositorFrameSink::SwapBuffersComplete, | 56 std::move(frame), |
| 57 base::Unretained(this))); | 57 base::Bind(&CompositorFrameSink::SubmitCompositorFrameAck, |
|
sky
2016/10/11 02:43:25
Any idea why this doesn't supply client_ directly?
danakj
2016/10/13 22:02:48
In similar cases its to use a weakptr but no reaso
| |
| 58 base::Unretained(this))); | |
| 58 } | 59 } |
| 59 | 60 |
| 60 void CompositorFrameSink::OnResourcesReturned( | 61 void CompositorFrameSink::OnResourcesReturned( |
| 61 ui::WindowSurface* surface, | 62 ui::WindowSurface* surface, |
| 62 mojo::Array<cc::ReturnedResource> resources) { | 63 mojo::Array<cc::ReturnedResource> resources) { |
| 63 client_->ReclaimResources(resources.To<cc::ReturnedResourceArray>()); | 64 client_->ReclaimResources(resources.To<cc::ReturnedResourceArray>()); |
| 64 } | 65 } |
| 65 | 66 |
| 66 void CompositorFrameSink::SwapBuffersComplete() { | 67 void CompositorFrameSink::SubmitCompositorFrameAck() { |
| 67 client_->DidSwapBuffersComplete(); | 68 client_->DidReceiveCompositorFrameAck(); |
| 68 } | 69 } |
| 69 | 70 |
| 70 } // namespace ui | 71 } // namespace ui |
| OLD | NEW |