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 "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
8 #include "cc/output/output_surface_client.h" | 8 #include "cc/output/output_surface_client.h" |
9 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" | 9 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" |
10 #include "mojo/services/public/cpp/surfaces/surfaces_type_converters.h" | 10 #include "mojo/services/public/cpp/surfaces/surfaces_type_converters.h" |
11 | 11 |
12 namespace mojo { | 12 namespace mojo { |
13 | 13 |
14 OutputSurfaceMojo::OutputSurfaceMojo( | 14 OutputSurfaceMojo::OutputSurfaceMojo( |
15 OutputSurfaceMojoClient* client, | |
16 const scoped_refptr<cc::ContextProvider>& context_provider, | 15 const scoped_refptr<cc::ContextProvider>& context_provider, |
17 SurfacePtr surface, | 16 SurfacePtr surface, |
18 uint32_t id_namespace) | 17 uint32_t id_namespace) |
19 : cc::OutputSurface(context_provider), | 18 : cc::OutputSurface(context_provider), |
20 output_surface_mojo_client_(client), | |
21 surface_(surface.Pass()), | 19 surface_(surface.Pass()), |
22 id_allocator_(id_namespace) { | 20 id_allocator_(id_namespace) { |
23 surface_.set_client(this); | 21 surface_.set_client(this); |
24 capabilities_.delegated_rendering = true; | |
25 capabilities_.max_frames_pending = 1; | |
26 } | 22 } |
27 | 23 |
28 OutputSurfaceMojo::~OutputSurfaceMojo() { | 24 OutputSurfaceMojo::~OutputSurfaceMojo() { |
29 } | 25 } |
30 | 26 |
31 void OutputSurfaceMojo::ReturnResources(Array<ReturnedResourcePtr> resources) { | 27 void OutputSurfaceMojo::ReturnResources(Array<ReturnedResourcePtr> resources) { |
32 } | 28 } |
33 | 29 |
34 void OutputSurfaceMojo::SwapBuffers(cc::CompositorFrame* frame) { | 30 void OutputSurfaceMojo::SwapBuffers(cc::CompositorFrame* frame) { |
35 gfx::Size frame_size = | 31 gfx::Size frame_size = |
36 frame->delegated_frame_data->render_pass_list.back()->output_rect.size(); | 32 frame->delegated_frame_data->render_pass_list.back()->output_rect.size(); |
37 if (frame_size != surface_size_) { | 33 if (frame_size != surface_size_) { |
38 if (!surface_id_.is_null()) { | 34 if (!surface_id_.is_null()) { |
39 surface_->DestroySurface(SurfaceId::From(surface_id_)); | 35 surface_->DestroySurface(SurfaceId::From(surface_id_)); |
40 } | 36 } |
41 surface_id_ = id_allocator_.GenerateId(); | 37 surface_id_ = id_allocator_.GenerateId(); |
42 surface_->CreateSurface(SurfaceId::From(surface_id_), | 38 surface_->CreateSurface(SurfaceId::From(surface_id_), |
43 Size::From(frame_size)); | 39 Size::From(frame_size)); |
44 output_surface_mojo_client_->DidCreateSurface(surface_id_); | |
45 surface_size_ = frame_size; | 40 surface_size_ = frame_size; |
46 } | 41 } |
47 | 42 |
48 surface_->SubmitFrame(SurfaceId::From(surface_id_), Frame::From(*frame)); | 43 surface_->SubmitFrame(SurfaceId::From(surface_id_), Frame::From(*frame)); |
49 | 44 |
50 client_->DidSwapBuffers(); | 45 client_->DidSwapBuffers(); |
51 client_->DidSwapBuffersComplete(); | 46 client_->DidSwapBuffersComplete(); |
52 } | 47 } |
53 | 48 |
54 } // namespace mojo | 49 } // namespace mojo |
OLD | NEW |