Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: services/ui/ws/server_window_surface.cc

Issue 2166423002: ui::ContextFactory should not create SurfaceIdAllocators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Dana's nit Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/surfaces/display_compositor.cc ('k') | ui/compositor/compositor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « services/ui/surfaces/display_compositor.cc ('k') | ui/compositor/compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698