OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ws/server_window_surface.h" | 5 #include "services/ui/ws/server_window_surface.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
9 #include "cc/quads/shared_quad_state.h" | 9 #include "cc/quads/shared_quad_state.h" |
10 #include "cc/quads/surface_draw_quad.h" | 10 #include "cc/quads/surface_draw_quad.h" |
11 #include "services/ui/surfaces/surfaces_state.h" | 11 #include "services/ui/surfaces/surfaces_state.h" |
12 #include "services/ui/ws/server_window.h" | 12 #include "services/ui/ws/server_window.h" |
13 #include "services/ui/ws/server_window_delegate.h" | 13 #include "services/ui/ws/server_window_delegate.h" |
14 #include "services/ui/ws/server_window_surface_manager.h" | 14 #include "services/ui/ws/server_window_surface_manager.h" |
15 | 15 |
16 namespace ui { | 16 namespace ui { |
17 namespace ws { | 17 namespace ws { |
18 | 18 |
19 ServerWindowSurface::ServerWindowSurface( | 19 ServerWindowSurface::ServerWindowSurface( |
20 ServerWindowSurfaceManager* manager, | 20 ServerWindowSurfaceManager* manager, |
21 mojo::InterfaceRequest<Surface> request, | 21 mojo::InterfaceRequest<Surface> request, |
22 mojom::SurfaceClientPtr client) | 22 mojom::SurfaceClientPtr client) |
23 : manager_(manager), | 23 : manager_(manager), |
24 surface_id_allocator_( | 24 surface_id_allocator_( |
25 manager->window()->delegate()->GetSurfacesState()->next_client_id()), | 25 manager->window()->delegate()->GetSurfacesState()->next_client_id()), |
26 surface_factory_(manager_->GetSurfaceManager(), this), | 26 surface_factory_(manager_->GetSurfaceManager(), this), |
27 client_(std::move(client)), | 27 client_(std::move(client)), |
28 binding_(this, std::move(request)) { | 28 binding_(this, std::move(request)) { |
29 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager(); | 29 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager(); |
30 surface_id_allocator_.RegisterSurfaceClientId(surface_manager); | 30 surface_manager->RegisterSurfaceClientId(surface_id_allocator_.client_id()); |
31 surface_manager->RegisterSurfaceFactoryClient( | 31 surface_manager->RegisterSurfaceFactoryClient( |
32 surface_id_allocator_.client_id(), this); | 32 surface_id_allocator_.client_id(), this); |
33 } | 33 } |
34 | 34 |
35 ServerWindowSurface::~ServerWindowSurface() { | 35 ServerWindowSurface::~ServerWindowSurface() { |
36 // SurfaceFactory's destructor will attempt to return resources which will | 36 // SurfaceFactory's destructor will attempt to return resources which will |
37 // call back into here and access |client_| so we should destroy | 37 // call back into here and access |client_| so we should destroy |
38 // |surface_factory_|'s resources early on. | 38 // |surface_factory_|'s resources early on. |
39 surface_factory_.DestroyAll(); | 39 surface_factory_.DestroyAll(); |
40 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager(); | 40 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager(); |
41 surface_manager->UnregisterSurfaceFactoryClient( | 41 surface_manager->UnregisterSurfaceFactoryClient( |
42 surface_id_allocator_.client_id()); | 42 surface_id_allocator_.client_id()); |
| 43 surface_manager->InvalidateSurfaceClientId(surface_id_allocator_.client_id()); |
43 } | 44 } |
44 | 45 |
45 void ServerWindowSurface::SubmitCompositorFrame( | 46 void ServerWindowSurface::SubmitCompositorFrame( |
46 cc::CompositorFrame frame, | 47 cc::CompositorFrame frame, |
47 const SubmitCompositorFrameCallback& callback) { | 48 const SubmitCompositorFrameCallback& callback) { |
48 gfx::Size frame_size = | 49 gfx::Size frame_size = |
49 frame.delegated_frame_data->render_pass_list[0]->output_rect.size(); | 50 frame.delegated_frame_data->render_pass_list[0]->output_rect.size(); |
50 // If the size of the CompostiorFrame has changed then destroy the existing | 51 // If the size of the CompostiorFrame has changed then destroy the existing |
51 // Surface and create a new one of the appropriate size. | 52 // Surface and create a new one of the appropriate size. |
52 if (surface_id_.is_null() || frame_size != last_submitted_frame_size_) { | 53 if (surface_id_.is_null() || frame_size != last_submitted_frame_size_) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 client_->ReturnResources(mojo::Array<cc::ReturnedResource>::From(resources)); | 89 client_->ReturnResources(mojo::Array<cc::ReturnedResource>::From(resources)); |
89 } | 90 } |
90 | 91 |
91 void ServerWindowSurface::SetBeginFrameSource( | 92 void ServerWindowSurface::SetBeginFrameSource( |
92 cc::BeginFrameSource* begin_frame_source) { | 93 cc::BeginFrameSource* begin_frame_source) { |
93 // TODO(tansell): Implement this. | 94 // TODO(tansell): Implement this. |
94 } | 95 } |
95 | 96 |
96 } // namespace ws | 97 } // namespace ws |
97 } // namespace ui | 98 } // namespace ui |
OLD | NEW |