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