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

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

Issue 2383373002: Reduce SurfaceIdAllocator usage and tie SurfaceFactory to a single FrameSinkId (Closed)
Patch Set: Rebased Created 4 years, 2 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/ws/server_window_surface.h ('k') | ui/android/delegated_frame_host_android.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 "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/display_compositor.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 mojo::InterfaceRequest<Surface> request, 22 mojo::InterfaceRequest<Surface> request,
23 mojom::SurfaceClientPtr client) 23 mojom::SurfaceClientPtr client)
24 : manager_(manager), 24 : frame_sink_id_(manager->window()
25 surface_id_allocator_(cc::FrameSinkId(manager->window() 25 ->delegate()
26 ->delegate() 26 ->GetDisplayCompositor()
27 ->GetDisplayCompositor() 27 ->GenerateNextClientId(),
28 ->GenerateNextClientId(), 28 0),
29 0)), 29 manager_(manager),
30 surface_factory_(manager_->GetSurfaceManager(), this), 30 surface_id_allocator_(frame_sink_id_),
31 surface_factory_(frame_sink_id_, manager_->GetSurfaceManager(), this),
31 client_(std::move(client)), 32 client_(std::move(client)),
32 binding_(this, std::move(request)) { 33 binding_(this, std::move(request)) {
33 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager(); 34 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager();
34 surface_manager->RegisterFrameSinkId(surface_id_allocator_.frame_sink_id()); 35 surface_manager->RegisterFrameSinkId(frame_sink_id_);
35 surface_manager->RegisterSurfaceFactoryClient( 36 surface_manager->RegisterSurfaceFactoryClient(frame_sink_id_, this);
36 surface_id_allocator_.frame_sink_id(), this);
37 } 37 }
38 38
39 ServerWindowSurface::~ServerWindowSurface() { 39 ServerWindowSurface::~ServerWindowSurface() {
40 // SurfaceFactory's destructor will attempt to return resources which will 40 // SurfaceFactory's destructor will attempt to return resources which will
41 // call back into here and access |client_| so we should destroy 41 // call back into here and access |client_| so we should destroy
42 // |surface_factory_|'s resources early on. 42 // |surface_factory_|'s resources early on.
43 surface_factory_.DestroyAll(); 43 surface_factory_.DestroyAll();
44 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager(); 44 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager();
45 surface_manager->UnregisterSurfaceFactoryClient( 45 surface_manager->UnregisterSurfaceFactoryClient(frame_sink_id_);
46 surface_id_allocator_.frame_sink_id()); 46 surface_manager->InvalidateFrameSinkId(frame_sink_id_);
47 surface_manager->InvalidateFrameSinkId(surface_id_allocator_.frame_sink_id());
48 } 47 }
49 48
50 void ServerWindowSurface::SubmitCompositorFrame( 49 void ServerWindowSurface::SubmitCompositorFrame(
51 cc::CompositorFrame frame, 50 cc::CompositorFrame frame,
52 const SubmitCompositorFrameCallback& callback) { 51 const SubmitCompositorFrameCallback& callback) {
53 gfx::Size frame_size = 52 gfx::Size frame_size =
54 frame.delegated_frame_data->render_pass_list[0]->output_rect.size(); 53 frame.delegated_frame_data->render_pass_list[0]->output_rect.size();
55 // 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
56 // Surface and create a new one of the appropriate size. 55 // Surface and create a new one of the appropriate size.
57 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
94 client_->ReturnResources(mojo::Array<cc::ReturnedResource>::From(resources)); 93 client_->ReturnResources(mojo::Array<cc::ReturnedResource>::From(resources));
95 } 94 }
96 95
97 void ServerWindowSurface::SetBeginFrameSource( 96 void ServerWindowSurface::SetBeginFrameSource(
98 cc::BeginFrameSource* begin_frame_source) { 97 cc::BeginFrameSource* begin_frame_source) {
99 // TODO(tansell): Implement this. 98 // TODO(tansell): Implement this.
100 } 99 }
101 100
102 } // namespace ws 101 } // namespace ws
103 } // namespace ui 102 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/server_window_surface.h ('k') | ui/android/delegated_frame_host_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698