| 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 "mojo/cc/output_surface_mojo.h" | 5 #include "mojo/cc/output_surface_mojo.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_ack.h" | 9 #include "cc/output/compositor_frame_ack.h" |
| 10 #include "cc/output/output_surface_client.h" | 10 #include "cc/output/output_surface_client.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 OutputSurfaceMojo::~OutputSurfaceMojo() { | 24 OutputSurfaceMojo::~OutputSurfaceMojo() { |
| 25 } | 25 } |
| 26 | 26 |
| 27 bool OutputSurfaceMojo::BindToClient(cc::OutputSurfaceClient* client) { | 27 bool OutputSurfaceMojo::BindToClient(cc::OutputSurfaceClient* client) { |
| 28 surface_->BindToThread(); | 28 surface_->BindToThread(); |
| 29 surface_->set_client(this); | 29 surface_->set_client(this); |
| 30 return cc::OutputSurface::BindToClient(client); | 30 return cc::OutputSurface::BindToClient(client); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void OutputSurfaceMojo::DetachFromClient() { |
| 34 surface_.reset(); |
| 35 cc::OutputSurface::DetachFromClient(); |
| 36 } |
| 37 |
| 33 void OutputSurfaceMojo::SwapBuffers(cc::CompositorFrame* frame) { | 38 void OutputSurfaceMojo::SwapBuffers(cc::CompositorFrame* frame) { |
| 34 // TODO(fsamuel, rjkroege): We should probably throttle compositor frames. | 39 // TODO(fsamuel, rjkroege): We should probably throttle compositor frames. |
| 35 client_->DidSwapBuffers(); | 40 client_->DidSwapBuffers(); |
| 36 // OutputSurfaceMojo owns ViewSurface, and so if OutputSurfaceMojo is | 41 // OutputSurfaceMojo owns ViewSurface, and so if OutputSurfaceMojo is |
| 37 // destroyed then SubmitCompositorFrame's callback will never get called. | 42 // destroyed then SubmitCompositorFrame's callback will never get called. |
| 38 // Thus, base::Unretained is safe here. | 43 // Thus, base::Unretained is safe here. |
| 39 surface_->SubmitCompositorFrame( | 44 surface_->SubmitCompositorFrame( |
| 40 mojo::CompositorFrame::From(*frame), | 45 mojo::CompositorFrame::From(*frame), |
| 41 base::Bind(&OutputSurfaceMojo::SwapBuffersComplete, | 46 base::Bind(&OutputSurfaceMojo::SwapBuffersComplete, |
| 42 base::Unretained(this))); | 47 base::Unretained(this))); |
| 43 } | 48 } |
| 44 | 49 |
| 45 void OutputSurfaceMojo::OnResourcesReturned( | 50 void OutputSurfaceMojo::OnResourcesReturned( |
| 46 mus::ViewSurface* surface, | 51 mus::ViewSurface* surface, |
| 47 mojo::Array<mojo::ReturnedResourcePtr> resources) { | 52 mojo::Array<mojo::ReturnedResourcePtr> resources) { |
| 48 cc::CompositorFrameAck cfa; | 53 cc::CompositorFrameAck cfa; |
| 49 cfa.resources = resources.To<cc::ReturnedResourceArray>(); | 54 cfa.resources = resources.To<cc::ReturnedResourceArray>(); |
| 50 ReclaimResources(&cfa); | 55 ReclaimResources(&cfa); |
| 51 } | 56 } |
| 52 | 57 |
| 53 void OutputSurfaceMojo::SwapBuffersComplete() { | 58 void OutputSurfaceMojo::SwapBuffersComplete() { |
| 54 client_->DidSwapBuffersComplete(); | 59 client_->DidSwapBuffersComplete(); |
| 55 } | 60 } |
| 56 | 61 |
| 57 } // namespace mojo | 62 } // namespace mojo |
| OLD | NEW |