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" |
11 #include "components/mus/public/cpp/view_surface.h" | 11 #include "components/mus/public/cpp/view_surface.h" |
12 #include "mojo/converters/surfaces/surfaces_type_converters.h" | 12 #include "mojo/converters/surfaces/surfaces_type_converters.h" |
13 | 13 |
14 namespace mojo { | 14 namespace mojo { |
15 | 15 |
16 OutputSurfaceMojo::OutputSurfaceMojo( | 16 OutputSurfaceMojo::OutputSurfaceMojo( |
17 const scoped_refptr<cc::ContextProvider>& context_provider, | 17 const scoped_refptr<cc::ContextProvider>& context_provider, |
18 scoped_ptr<mus::ViewSurface> surface) | 18 scoped_ptr<mojo::ViewSurface> surface) |
19 : cc::OutputSurface(context_provider), surface_(surface.Pass()) { | 19 : cc::OutputSurface(context_provider), |
| 20 surface_(surface.Pass()) { |
20 capabilities_.delegated_rendering = true; | 21 capabilities_.delegated_rendering = true; |
21 capabilities_.max_frames_pending = 1; | 22 capabilities_.max_frames_pending = 1; |
22 } | 23 } |
23 | 24 |
24 OutputSurfaceMojo::~OutputSurfaceMojo() { | 25 OutputSurfaceMojo::~OutputSurfaceMojo() { |
25 } | 26 } |
26 | 27 |
27 bool OutputSurfaceMojo::BindToClient(cc::OutputSurfaceClient* client) { | 28 bool OutputSurfaceMojo::BindToClient(cc::OutputSurfaceClient* client) { |
28 surface_->BindToThread(); | 29 surface_->BindToThread(); |
29 surface_->set_client(this); | 30 surface_->set_client(this); |
30 return cc::OutputSurface::BindToClient(client); | 31 return cc::OutputSurface::BindToClient(client); |
31 } | 32 } |
32 | 33 |
33 void OutputSurfaceMojo::SwapBuffers(cc::CompositorFrame* frame) { | 34 void OutputSurfaceMojo::SwapBuffers(cc::CompositorFrame* frame) { |
34 // TODO(fsamuel, rjkroege): We should probably throttle compositor frames. | 35 // TODO(fsamuel, rjkroege): We should probably throttle compositor frames. |
35 surface_->SubmitCompositorFrame(mojo::CompositorFrame::From(*frame)); | 36 surface_->SubmitCompositorFrame(mojo::CompositorFrame::From(*frame)); |
36 | 37 |
37 client_->DidSwapBuffers(); | 38 client_->DidSwapBuffers(); |
38 client_->DidSwapBuffersComplete(); | 39 client_->DidSwapBuffersComplete(); |
39 } | 40 } |
40 | 41 |
41 void OutputSurfaceMojo::OnResourcesReturned( | 42 void OutputSurfaceMojo::OnResourcesReturned( |
42 mus::ViewSurface* surface, | 43 mojo::ViewSurface* surface, |
43 mojo::Array<mojo::ReturnedResourcePtr> resources) { | 44 mojo::Array<mojo::ReturnedResourcePtr> resources) { |
44 cc::CompositorFrameAck cfa; | 45 cc::CompositorFrameAck cfa; |
45 cfa.resources = resources.To<cc::ReturnedResourceArray>(); | 46 cfa.resources = resources.To<cc::ReturnedResourceArray>(); |
46 ReclaimResources(&cfa); | 47 ReclaimResources(&cfa); |
47 } | 48 } |
48 | 49 |
49 } // namespace mojo | 50 } // namespace mojo |
OLD | NEW |