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

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

Issue 2388753003: Introduce cc::LocalFrameId and use in SurfaceFactory (Closed)
Patch Set: Fix exo_unittests 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
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 const cc::FrameSinkId& frame_sink_id, 22 const cc::FrameSinkId& frame_sink_id,
23 mojo::InterfaceRequest<Surface> request, 23 mojo::InterfaceRequest<Surface> request,
24 mojom::SurfaceClientPtr client) 24 mojom::SurfaceClientPtr client)
25 : frame_sink_id_(frame_sink_id), 25 : frame_sink_id_(frame_sink_id),
26 manager_(manager), 26 manager_(manager),
27 surface_id_allocator_(frame_sink_id_),
28 surface_factory_(frame_sink_id_, manager_->GetSurfaceManager(), this), 27 surface_factory_(frame_sink_id_, manager_->GetSurfaceManager(), this),
29 client_(std::move(client)), 28 client_(std::move(client)),
30 binding_(this, std::move(request)) { 29 binding_(this, std::move(request)) {
31 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager(); 30 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager();
32 surface_manager->RegisterFrameSinkId(frame_sink_id_); 31 surface_manager->RegisterFrameSinkId(frame_sink_id_);
33 surface_manager->RegisterSurfaceFactoryClient(frame_sink_id_, this); 32 surface_manager->RegisterSurfaceFactoryClient(frame_sink_id_, this);
34 } 33 }
35 34
36 ServerWindowSurface::~ServerWindowSurface() { 35 ServerWindowSurface::~ServerWindowSurface() {
37 // SurfaceFactory's destructor will attempt to return resources which will 36 // SurfaceFactory's destructor will attempt to return resources which will
38 // call back into here and access |client_| so we should destroy 37 // call back into here and access |client_| so we should destroy
39 // |surface_factory_|'s resources early on. 38 // |surface_factory_|'s resources early on.
40 surface_factory_.DestroyAll(); 39 surface_factory_.DestroyAll();
41 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager(); 40 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager();
42 surface_manager->UnregisterSurfaceFactoryClient(frame_sink_id_); 41 surface_manager->UnregisterSurfaceFactoryClient(frame_sink_id_);
43 surface_manager->InvalidateFrameSinkId(frame_sink_id_); 42 surface_manager->InvalidateFrameSinkId(frame_sink_id_);
44 } 43 }
45 44
46 void ServerWindowSurface::SubmitCompositorFrame( 45 void ServerWindowSurface::SubmitCompositorFrame(
47 cc::CompositorFrame frame, 46 cc::CompositorFrame frame,
48 const SubmitCompositorFrameCallback& callback) { 47 const SubmitCompositorFrameCallback& callback) {
49 gfx::Size frame_size = 48 gfx::Size frame_size =
50 frame.delegated_frame_data->render_pass_list[0]->output_rect.size(); 49 frame.delegated_frame_data->render_pass_list[0]->output_rect.size();
51 // If the size of the CompostiorFrame has changed then destroy the existing 50 // If the size of the CompostiorFrame has changed then destroy the existing
52 // Surface and create a new one of the appropriate size. 51 // Surface and create a new one of the appropriate size.
53 if (surface_id_.is_null() || frame_size != last_submitted_frame_size_) { 52 if (local_frame_id_.is_null() || frame_size != last_submitted_frame_size_) {
54 // Rendering of the topmost frame happens in two phases. First the frame 53 // Rendering of the topmost frame happens in two phases. First the frame
55 // is generated and submitted, and a later date it is actually drawn. 54 // is generated and submitted, and a later date it is actually drawn.
56 // During the time the frame is generated and drawn we can't destroy the 55 // During the time the frame is generated and drawn we can't destroy the
57 // surface, otherwise when drawn you get an empty surface. To deal with 56 // surface, otherwise when drawn you get an empty surface. To deal with
58 // this we schedule destruction via the delegate. The delegate will call 57 // this we schedule destruction via the delegate. The delegate will call
59 // us back when we're not waiting on a frame to be drawn (which may be 58 // us back when we're not waiting on a frame to be drawn (which may be
60 // synchronously). 59 // synchronously).
61 if (!surface_id_.is_null()) { 60 if (!local_frame_id_.is_null()) {
62 surfaces_scheduled_for_destruction_.insert(surface_id_); 61 surfaces_scheduled_for_destruction_.insert(local_frame_id_);
63 window()->delegate()->ScheduleSurfaceDestruction(window()); 62 window()->delegate()->ScheduleSurfaceDestruction(window());
64 } 63 }
65 surface_id_ = surface_id_allocator_.GenerateId(); 64 local_frame_id_ = surface_id_allocator_.GenerateId();
66 surface_factory_.Create(surface_id_); 65 surface_factory_.Create(local_frame_id_);
67 } 66 }
68 may_contain_video_ = frame.metadata.may_contain_video; 67 may_contain_video_ = frame.metadata.may_contain_video;
69 surface_factory_.SubmitCompositorFrame(surface_id_, std::move(frame), 68 surface_factory_.SubmitCompositorFrame(local_frame_id_, std::move(frame),
70 callback); 69 callback);
71 last_submitted_frame_size_ = frame_size; 70 last_submitted_frame_size_ = frame_size;
72 window()->delegate()->OnScheduleWindowPaint(window()); 71 window()->delegate()->OnScheduleWindowPaint(window());
73 } 72 }
74 73
74 cc::SurfaceId ServerWindowSurface::GetSurfaceId() const {
75 return cc::SurfaceId(frame_sink_id_, local_frame_id_);
76 }
77
75 void ServerWindowSurface::DestroySurfacesScheduledForDestruction() { 78 void ServerWindowSurface::DestroySurfacesScheduledForDestruction() {
76 std::set<cc::SurfaceId> surfaces; 79 std::set<cc::LocalFrameId> surfaces;
77 surfaces.swap(surfaces_scheduled_for_destruction_); 80 surfaces.swap(surfaces_scheduled_for_destruction_);
78 for (auto& id : surfaces) 81 for (auto& id : surfaces)
79 surface_factory_.Destroy(id); 82 surface_factory_.Destroy(id);
80 } 83 }
81 84
82 ServerWindow* ServerWindowSurface::window() { 85 ServerWindow* ServerWindowSurface::window() {
83 return manager_->window(); 86 return manager_->window();
84 } 87 }
85 88
86 void ServerWindowSurface::ReturnResources( 89 void ServerWindowSurface::ReturnResources(
87 const cc::ReturnedResourceArray& resources) { 90 const cc::ReturnedResourceArray& resources) {
88 if (!client_ || !base::MessageLoop::current()) 91 if (!client_ || !base::MessageLoop::current())
89 return; 92 return;
90 client_->ReturnResources(mojo::Array<cc::ReturnedResource>::From(resources)); 93 client_->ReturnResources(mojo::Array<cc::ReturnedResource>::From(resources));
91 } 94 }
92 95
93 void ServerWindowSurface::SetBeginFrameSource( 96 void ServerWindowSurface::SetBeginFrameSource(
94 cc::BeginFrameSource* begin_frame_source) { 97 cc::BeginFrameSource* begin_frame_source) {
95 // TODO(tansell): Implement this. 98 // TODO(tansell): Implement this.
96 } 99 }
97 100
98 } // namespace ws 101 } // namespace ws
99 } // namespace ui 102 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698