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

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

Issue 2430653002: Mus+Ash: Towards Unifying CompositorFrameSink terminology (Closed)
Patch Set: Fix bitmap_uploader 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 cc::mojom::MojoCompositorFrameSinkRequest request,
24 mojom::SurfaceClientPtr client) 24 cc::mojom::MojoCompositorFrameSinkClientPtr client)
25 : frame_sink_id_(frame_sink_id), 25 : frame_sink_id_(frame_sink_id),
26 manager_(manager), 26 manager_(manager),
27 surface_factory_(frame_sink_id_, manager_->GetSurfaceManager(), this), 27 surface_factory_(frame_sink_id_, 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 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager(); 30 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager();
31 surface_manager->RegisterFrameSinkId(frame_sink_id_); 31 surface_manager->RegisterFrameSinkId(frame_sink_id_);
32 surface_manager->RegisterSurfaceFactoryClient(frame_sink_id_, this); 32 surface_manager->RegisterSurfaceFactoryClient(frame_sink_id_, this);
33 surface_sequence_generator_.set_frame_sink_id(frame_sink_id_); 33 surface_sequence_generator_.set_frame_sink_id(frame_sink_id_);
34 } 34 }
35 35
36 ServerWindowSurface::~ServerWindowSurface() { 36 ServerWindowSurface::~ServerWindowSurface() {
37 // SurfaceFactory's destructor will attempt to return resources which will 37 // SurfaceFactory's destructor will attempt to return resources which will
38 // call back into here and access |client_| so we should destroy 38 // call back into here and access |client_| so we should destroy
39 // |surface_factory_|'s resources early on. 39 // |surface_factory_|'s resources early on.
40 surface_factory_.DestroyAll(); 40 surface_factory_.DestroyAll();
41 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager(); 41 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager();
42 surface_manager->UnregisterSurfaceFactoryClient(frame_sink_id_); 42 surface_manager->UnregisterSurfaceFactoryClient(frame_sink_id_);
43 surface_manager->InvalidateFrameSinkId(frame_sink_id_); 43 surface_manager->InvalidateFrameSinkId(frame_sink_id_);
44 } 44 }
45 45
46 void ServerWindowSurface::SubmitCompositorFrame( 46 void ServerWindowSurface::SetNeedsBeginFrame(bool needs_begin_frame) {
rjkroege 2016/10/20 21:33:18 if it works without it, then why is it needed? Wha
Fady Samuel 2016/10/20 23:04:10 We don't use unified BeginFrame in Mus yet. staraz
47 cc::CompositorFrame frame, 47 // TODO(fsamuel): Implement this.
48 const SubmitCompositorFrameCallback& callback) { 48 }
49
50 void ServerWindowSurface::SubmitCompositorFrame(cc::CompositorFrame frame) {
49 gfx::Size frame_size = 51 gfx::Size frame_size =
50 frame.delegated_frame_data->render_pass_list[0]->output_rect.size(); 52 frame.delegated_frame_data->render_pass_list[0]->output_rect.size();
51 // If the size of the CompostiorFrame has changed then destroy the existing 53 // If the size of the CompostiorFrame has changed then destroy the existing
52 // Surface and create a new one of the appropriate size. 54 // Surface and create a new one of the appropriate size.
53 if (local_frame_id_.is_null() || frame_size != last_submitted_frame_size_) { 55 if (local_frame_id_.is_null() || frame_size != last_submitted_frame_size_) {
54 if (!local_frame_id_.is_null()) 56 if (!local_frame_id_.is_null())
55 surface_factory_.Destroy(local_frame_id_); 57 surface_factory_.Destroy(local_frame_id_);
56 local_frame_id_ = surface_id_allocator_.GenerateId(); 58 local_frame_id_ = surface_id_allocator_.GenerateId();
57 surface_factory_.Create(local_frame_id_); 59 surface_factory_.Create(local_frame_id_);
58 } 60 }
59 may_contain_video_ = frame.metadata.may_contain_video; 61 may_contain_video_ = frame.metadata.may_contain_video;
60 surface_factory_.SubmitCompositorFrame(local_frame_id_, std::move(frame), 62 surface_factory_.SubmitCompositorFrame(
61 callback); 63 local_frame_id_, std::move(frame),
64 base::Bind(&ServerWindowSurface::DidReceiveCompositorFrameAck,
65 base::Unretained(this)));
62 last_submitted_frame_size_ = frame_size; 66 last_submitted_frame_size_ = frame_size;
63 window()->delegate()->OnScheduleWindowPaint(window()); 67 window()->delegate()->OnScheduleWindowPaint(window());
64 } 68 }
65 69
66 cc::SurfaceId ServerWindowSurface::GetSurfaceId() const { 70 cc::SurfaceId ServerWindowSurface::GetSurfaceId() const {
67 if (local_frame_id_.is_null()) 71 if (local_frame_id_.is_null())
68 return cc::SurfaceId(); 72 return cc::SurfaceId();
69 return cc::SurfaceId(frame_sink_id_, local_frame_id_); 73 return cc::SurfaceId(frame_sink_id_, local_frame_id_);
70 } 74 }
71 75
72 cc::SurfaceSequence ServerWindowSurface::CreateSurfaceSequence() { 76 cc::SurfaceSequence ServerWindowSurface::CreateSurfaceSequence() {
73 return surface_sequence_generator_.CreateSurfaceSequence(); 77 return surface_sequence_generator_.CreateSurfaceSequence();
74 } 78 }
75 79
76 ServerWindow* ServerWindowSurface::window() { 80 ServerWindow* ServerWindowSurface::window() {
77 return manager_->window(); 81 return manager_->window();
78 } 82 }
79 83
84 void ServerWindowSurface::DidReceiveCompositorFrameAck() {
rjkroege 2016/10/20 21:33:18 You are deleting ServerWindowSurface in a subseque
Fady Samuel 2016/10/20 23:04:10 Not quite. ServerWindowSurface => ServerWindowComp
85 if (!client_ || !base::MessageLoop::current())
86 return;
87 client_->DidReceiveCompositorFrameAck();
88 }
89
80 void ServerWindowSurface::ReturnResources( 90 void ServerWindowSurface::ReturnResources(
81 const cc::ReturnedResourceArray& resources) { 91 const cc::ReturnedResourceArray& resources) {
82 if (!client_ || !base::MessageLoop::current()) 92 if (!client_ || !base::MessageLoop::current())
83 return; 93 return;
84 client_->ReturnResources(mojo::Array<cc::ReturnedResource>::From(resources)); 94 client_->ReclaimResources(resources);
85 } 95 }
86 96
87 void ServerWindowSurface::SetBeginFrameSource( 97 void ServerWindowSurface::SetBeginFrameSource(
88 cc::BeginFrameSource* begin_frame_source) { 98 cc::BeginFrameSource* begin_frame_source) {
89 // TODO(tansell): Implement this. 99 // TODO(tansell): Implement this.
90 } 100 }
91 101
92 } // namespace ws 102 } // namespace ws
93 } // namespace ui 103 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698