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 "components/mus/ws/server_window_surface.h" | 5 #include "components/mus/ws/server_window_surface.h" |
6 | 6 |
7 #include "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
8 #include "cc/quads/shared_quad_state.h" | 8 #include "cc/quads/shared_quad_state.h" |
9 #include "cc/quads/surface_draw_quad.h" | 9 #include "cc/quads/surface_draw_quad.h" |
10 #include "components/mus/surfaces/surfaces_state.h" | 10 #include "components/mus/surfaces/surfaces_state.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 } // namespace | 25 } // namespace |
26 | 26 |
27 ServerWindowSurface::ServerWindowSurface( | 27 ServerWindowSurface::ServerWindowSurface( |
28 ServerWindowSurfaceManager* manager, | 28 ServerWindowSurfaceManager* manager, |
29 mojom::SurfaceType surface_type, | 29 mojom::SurfaceType surface_type, |
30 mojo::InterfaceRequest<Surface> request, | 30 mojo::InterfaceRequest<Surface> request, |
31 mojom::SurfaceClientPtr client) | 31 mojom::SurfaceClientPtr client) |
32 : manager_(manager), | 32 : manager_(manager), |
33 surface_type_(surface_type), | 33 surface_type_(surface_type), |
34 surface_id_(manager->GenerateId()), | 34 surface_id_(manager->GenerateId()), |
35 surface_factory_(manager_->window() | 35 surface_factory_(manager_->GetSurfaceManager(), this), |
36 ->delegate() | |
37 ->GetSurfacesState() | |
38 ->manager(), | |
39 this), | |
40 client_(std::move(client)), | 36 client_(std::move(client)), |
41 binding_(this, std::move(request)) { | 37 binding_(this, std::move(request)), |
| 38 registered_surface_factory_client_(false) { |
42 surface_factory_.Create(surface_id_); | 39 surface_factory_.Create(surface_id_); |
43 } | 40 } |
44 | 41 |
45 ServerWindowSurface::~ServerWindowSurface() { | 42 ServerWindowSurface::~ServerWindowSurface() { |
46 // SurfaceFactory's destructor will attempt to return resources which will | 43 // SurfaceFactory's destructor will attempt to return resources which will |
47 // call back into here and access |client_| so we should destroy | 44 // call back into here and access |client_| so we should destroy |
48 // |surface_factory_|'s resources early on. | 45 // |surface_factory_|'s resources early on. |
49 surface_factory_.DestroyAll(); | 46 surface_factory_.DestroyAll(); |
| 47 |
| 48 if (registered_surface_factory_client_) { |
| 49 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager(); |
| 50 surface_manager->UnregisterSurfaceFactoryClient(manager_->id_namespace()); |
| 51 } |
50 } | 52 } |
51 | 53 |
52 void ServerWindowSurface::SubmitCompositorFrame( | 54 void ServerWindowSurface::SubmitCompositorFrame( |
53 mojom::CompositorFramePtr frame, | 55 mojom::CompositorFramePtr frame, |
54 const SubmitCompositorFrameCallback& callback) { | 56 const SubmitCompositorFrameCallback& callback) { |
55 gfx::Size frame_size = frame->passes[0]->output_rect.To<gfx::Rect>().size(); | 57 gfx::Size frame_size = frame->passes[0]->output_rect.To<gfx::Rect>().size(); |
56 if (!surface_id_.is_null()) { | 58 if (!surface_id_.is_null()) { |
57 // If the size of the CompostiorFrame has changed then destroy the existing | 59 // If the size of the CompostiorFrame has changed then destroy the existing |
58 // Surface and create a new one of the appropriate size. | 60 // Surface and create a new one of the appropriate size. |
59 if (frame_size != last_submitted_frame_size_) { | 61 if (frame_size != last_submitted_frame_size_) { |
(...skipping 17 matching lines...) Expand all Loading... |
77 last_submitted_frame_size_ = frame_size; | 79 last_submitted_frame_size_ = frame_size; |
78 } | 80 } |
79 | 81 |
80 void ServerWindowSurface::DestroySurfacesScheduledForDestruction() { | 82 void ServerWindowSurface::DestroySurfacesScheduledForDestruction() { |
81 std::set<cc::SurfaceId> surfaces; | 83 std::set<cc::SurfaceId> surfaces; |
82 surfaces.swap(surfaces_scheduled_for_destruction_); | 84 surfaces.swap(surfaces_scheduled_for_destruction_); |
83 for (auto& id : surfaces) | 85 for (auto& id : surfaces) |
84 surface_factory_.Destroy(id); | 86 surface_factory_.Destroy(id); |
85 } | 87 } |
86 | 88 |
| 89 void ServerWindowSurface::RegisterForBeginFrames() { |
| 90 DCHECK(!registered_surface_factory_client_); |
| 91 registered_surface_factory_client_ = true; |
| 92 cc::SurfaceManager* surface_manager = manager_->GetSurfaceManager(); |
| 93 surface_manager->RegisterSurfaceFactoryClient(manager_->id_namespace(), this); |
| 94 } |
| 95 |
87 ServerWindow* ServerWindowSurface::window() { | 96 ServerWindow* ServerWindowSurface::window() { |
88 return manager_->window(); | 97 return manager_->window(); |
89 } | 98 } |
90 | 99 |
91 scoped_ptr<cc::CompositorFrame> ServerWindowSurface::ConvertCompositorFrame( | 100 scoped_ptr<cc::CompositorFrame> ServerWindowSurface::ConvertCompositorFrame( |
92 const mojom::CompositorFramePtr& input) { | 101 const mojom::CompositorFramePtr& input) { |
93 referenced_window_ids_.clear(); | 102 referenced_window_ids_.clear(); |
94 return ConvertToCompositorFrame(input, this); | 103 return ConvertToCompositorFrame(input, this); |
95 } | 104 } |
96 | 105 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 155 |
147 void ServerWindowSurface::ReturnResources( | 156 void ServerWindowSurface::ReturnResources( |
148 const cc::ReturnedResourceArray& resources) { | 157 const cc::ReturnedResourceArray& resources) { |
149 if (!client_) | 158 if (!client_) |
150 return; | 159 return; |
151 client_->ReturnResources( | 160 client_->ReturnResources( |
152 mojo::Array<mojom::ReturnedResourcePtr>::From(resources)); | 161 mojo::Array<mojom::ReturnedResourcePtr>::From(resources)); |
153 } | 162 } |
154 | 163 |
155 void ServerWindowSurface::SetBeginFrameSource( | 164 void ServerWindowSurface::SetBeginFrameSource( |
156 cc::SurfaceId surface_id, | |
157 cc::BeginFrameSource* begin_frame_source) { | 165 cc::BeginFrameSource* begin_frame_source) { |
158 // TODO(tansell): Implement this. | 166 // TODO(tansell): Implement this. |
159 } | 167 } |
160 | 168 |
161 } // namespace ws | 169 } // namespace ws |
162 } // namespace mus | 170 } // namespace mus |
OLD | NEW |