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_manager.h" | 5 #include "components/mus/ws/server_window_surface_manager.h" |
6 | 6 |
7 #include "components/mus/ws/server_window.h" | 7 #include "components/mus/ws/server_window.h" |
8 #include "components/mus/ws/server_window_delegate.h" | 8 #include "components/mus/ws/server_window_delegate.h" |
9 #include "components/mus/ws/server_window_surface.h" | 9 #include "components/mus/ws/server_window_surface.h" |
10 | 10 |
11 namespace mus { | 11 namespace mus { |
12 namespace ws { | 12 namespace ws { |
13 | 13 |
14 ServerWindowSurfaceManager::ServerWindowSurfaceManager(ServerWindow* window) | 14 ServerWindowSurfaceManager::ServerWindowSurfaceManager(ServerWindow* window) |
15 : window_(window), | 15 : window_(window), |
16 surface_id_allocator_(WindowIdToTransportId(window->id())), | 16 surface_id_allocator_(WindowIdToTransportId(window->id())), |
17 waiting_for_initial_frames_( | 17 waiting_for_initial_frames_( |
18 window_->properties().count(mus::mojom::kWaitForUnderlay_Property) > | 18 window_->properties().count(mus::mojom::kWaitForUnderlay_Property) > |
19 0) {} | 19 0) {} |
20 | 20 |
21 ServerWindowSurfaceManager::~ServerWindowSurfaceManager() {} | 21 ServerWindowSurfaceManager::~ServerWindowSurfaceManager() {} |
22 | 22 |
23 bool ServerWindowSurfaceManager::ShouldDraw() { | 23 bool ServerWindowSurfaceManager::ShouldDraw() { |
24 if (!waiting_for_initial_frames_) | 24 if (!waiting_for_initial_frames_) |
25 return true; | 25 return true; |
26 | 26 |
27 waiting_for_initial_frames_ = | 27 waiting_for_initial_frames_ = |
28 !IsSurfaceReadyAndNonEmpty(mojom::SURFACE_TYPE_DEFAULT) || | 28 !IsSurfaceReadyAndNonEmpty(mojom::SurfaceType::DEFAULT) || |
29 !IsSurfaceReadyAndNonEmpty(mojom::SURFACE_TYPE_UNDERLAY); | 29 !IsSurfaceReadyAndNonEmpty(mojom::SurfaceType::UNDERLAY); |
30 return !waiting_for_initial_frames_; | 30 return !waiting_for_initial_frames_; |
31 } | 31 } |
32 | 32 |
33 void ServerWindowSurfaceManager::CreateSurface( | 33 void ServerWindowSurfaceManager::CreateSurface( |
34 mojom::SurfaceType surface_type, | 34 mojom::SurfaceType surface_type, |
35 mojo::InterfaceRequest<mojom::Surface> request, | 35 mojo::InterfaceRequest<mojom::Surface> request, |
36 mojom::SurfaceClientPtr client) { | 36 mojom::SurfaceClientPtr client) { |
37 type_to_surface_map_[surface_type] = make_scoped_ptr(new ServerWindowSurface( | 37 type_to_surface_map_[surface_type] = make_scoped_ptr(new ServerWindowSurface( |
38 this, surface_type, std::move(request), std::move(client))); | 38 this, surface_type, std::move(request), std::move(client))); |
39 } | 39 } |
40 | 40 |
41 ServerWindowSurface* ServerWindowSurfaceManager::GetDefaultSurface() { | 41 ServerWindowSurface* ServerWindowSurfaceManager::GetDefaultSurface() { |
42 return GetSurfaceByType(mojom::SURFACE_TYPE_DEFAULT); | 42 return GetSurfaceByType(mojom::SurfaceType::DEFAULT); |
43 } | 43 } |
44 | 44 |
45 ServerWindowSurface* ServerWindowSurfaceManager::GetUnderlaySurface() { | 45 ServerWindowSurface* ServerWindowSurfaceManager::GetUnderlaySurface() { |
46 return GetSurfaceByType(mojom::SURFACE_TYPE_UNDERLAY); | 46 return GetSurfaceByType(mojom::SurfaceType::UNDERLAY); |
47 } | 47 } |
48 | 48 |
49 ServerWindowSurface* ServerWindowSurfaceManager::GetSurfaceByType( | 49 ServerWindowSurface* ServerWindowSurfaceManager::GetSurfaceByType( |
50 mojom::SurfaceType type) { | 50 mojom::SurfaceType type) { |
51 auto iter = type_to_surface_map_.find(type); | 51 auto iter = type_to_surface_map_.find(type); |
52 return iter == type_to_surface_map_.end() ? nullptr : iter->second.get(); | 52 return iter == type_to_surface_map_.end() ? nullptr : iter->second.get(); |
53 } | 53 } |
54 | 54 |
55 bool ServerWindowSurfaceManager::HasSurfaceOfType(mojom::SurfaceType type) { | 55 bool ServerWindowSurfaceManager::HasSurfaceOfType(mojom::SurfaceType type) { |
56 return type_to_surface_map_.count(type) > 0; | 56 return type_to_surface_map_.count(type) > 0; |
(...skipping 11 matching lines...) Expand all Loading... |
68 return last_submitted_frame_size.width() >= window_->bounds().width() && | 68 return last_submitted_frame_size.width() >= window_->bounds().width() && |
69 last_submitted_frame_size.height() >= window_->bounds().height(); | 69 last_submitted_frame_size.height() >= window_->bounds().height(); |
70 } | 70 } |
71 | 71 |
72 cc::SurfaceId ServerWindowSurfaceManager::GenerateId() { | 72 cc::SurfaceId ServerWindowSurfaceManager::GenerateId() { |
73 return surface_id_allocator_.GenerateId(); | 73 return surface_id_allocator_.GenerateId(); |
74 } | 74 } |
75 | 75 |
76 } // namespace ws | 76 } // namespace ws |
77 } // namespace mus | 77 } // namespace mus |
OLD | NEW |