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

Side by Side Diff: components/mus/ws/server_window_surface_manager.cc

Issue 1673783004: Hook up BeginFrameSource to SurfaceFactoryClient via SurfaceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile Created 4 years, 9 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 "components/mus/ws/server_window_surface_manager.h" 5 #include "components/mus/ws/server_window_surface_manager.h"
6 6
7 #include "components/mus/surfaces/surfaces_state.h"
7 #include "components/mus/ws/server_window.h" 8 #include "components/mus/ws/server_window.h"
8 #include "components/mus/ws/server_window_delegate.h" 9 #include "components/mus/ws/server_window_delegate.h"
9 #include "components/mus/ws/server_window_surface.h" 10 #include "components/mus/ws/server_window_surface.h"
10 11
11 namespace mus { 12 namespace mus {
12 namespace ws { 13 namespace ws {
13 14
14 ServerWindowSurfaceManager::ServerWindowSurfaceManager(ServerWindow* window) 15 ServerWindowSurfaceManager::ServerWindowSurfaceManager(ServerWindow* window)
15 : window_(window), 16 : window_(window),
16 surface_id_allocator_(WindowIdToTransportId(window->id())), 17 surface_id_allocator_(WindowIdToTransportId(window->id())),
(...skipping 10 matching lines...) Expand all
27 waiting_for_initial_frames_ = 28 waiting_for_initial_frames_ =
28 !IsSurfaceReadyAndNonEmpty(mojom::SurfaceType::DEFAULT) || 29 !IsSurfaceReadyAndNonEmpty(mojom::SurfaceType::DEFAULT) ||
29 !IsSurfaceReadyAndNonEmpty(mojom::SurfaceType::UNDERLAY); 30 !IsSurfaceReadyAndNonEmpty(mojom::SurfaceType::UNDERLAY);
30 return !waiting_for_initial_frames_; 31 return !waiting_for_initial_frames_;
31 } 32 }
32 33
33 void ServerWindowSurfaceManager::CreateSurface( 34 void ServerWindowSurfaceManager::CreateSurface(
34 mojom::SurfaceType surface_type, 35 mojom::SurfaceType surface_type,
35 mojo::InterfaceRequest<mojom::Surface> request, 36 mojo::InterfaceRequest<mojom::Surface> request,
36 mojom::SurfaceClientPtr client) { 37 mojom::SurfaceClientPtr client) {
37 type_to_surface_map_[surface_type] = make_scoped_ptr(new ServerWindowSurface( 38 scoped_ptr<ServerWindowSurface> surface(new ServerWindowSurface(
38 this, surface_type, std::move(request), std::move(client))); 39 this, surface_type, std::move(request), std::move(client)));
40 if (!HasAnySurface()) {
41 // Only one SurfaceFactoryClient can be registered per surface id namespace,
42 // so register the first one. Since all surfaces created by this manager
43 // represent the same window, the begin frame source can be shared by
44 // all surfaces created here.
45 surface->RegisterForBeginFrames();
46 }
47 type_to_surface_map_[surface_type] = std::move(surface);
39 } 48 }
40 49
41 ServerWindowSurface* ServerWindowSurfaceManager::GetDefaultSurface() { 50 ServerWindowSurface* ServerWindowSurfaceManager::GetDefaultSurface() {
42 return GetSurfaceByType(mojom::SurfaceType::DEFAULT); 51 return GetSurfaceByType(mojom::SurfaceType::DEFAULT);
43 } 52 }
44 53
45 ServerWindowSurface* ServerWindowSurfaceManager::GetUnderlaySurface() { 54 ServerWindowSurface* ServerWindowSurfaceManager::GetUnderlaySurface() {
46 return GetSurfaceByType(mojom::SurfaceType::UNDERLAY); 55 return GetSurfaceByType(mojom::SurfaceType::UNDERLAY);
47 } 56 }
48 57
49 ServerWindowSurface* ServerWindowSurfaceManager::GetSurfaceByType( 58 ServerWindowSurface* ServerWindowSurfaceManager::GetSurfaceByType(
50 mojom::SurfaceType type) { 59 mojom::SurfaceType type) {
51 auto iter = type_to_surface_map_.find(type); 60 auto iter = type_to_surface_map_.find(type);
52 return iter == type_to_surface_map_.end() ? nullptr : iter->second.get(); 61 return iter == type_to_surface_map_.end() ? nullptr : iter->second.get();
53 } 62 }
54 63
55 bool ServerWindowSurfaceManager::HasSurfaceOfType(mojom::SurfaceType type) { 64 bool ServerWindowSurfaceManager::HasSurfaceOfType(
65 mojom::SurfaceType type) const {
56 return type_to_surface_map_.count(type) > 0; 66 return type_to_surface_map_.count(type) > 0;
57 } 67 }
58 68
69 bool ServerWindowSurfaceManager::HasAnySurface() {
70 return !GetDefaultSurface() && !GetUnderlaySurface();
71 }
72
73 cc::SurfaceManager* ServerWindowSurfaceManager::GetSurfaceManager() {
74 return window()->delegate()->GetSurfacesState()->manager();
75 }
76
59 bool ServerWindowSurfaceManager::IsSurfaceReadyAndNonEmpty( 77 bool ServerWindowSurfaceManager::IsSurfaceReadyAndNonEmpty(
60 mojom::SurfaceType type) const { 78 mojom::SurfaceType type) const {
61 auto iter = type_to_surface_map_.find(type); 79 auto iter = type_to_surface_map_.find(type);
62 if (iter == type_to_surface_map_.end()) 80 if (iter == type_to_surface_map_.end())
63 return false; 81 return false;
64 if (iter->second->last_submitted_frame_size().IsEmpty()) 82 if (iter->second->last_submitted_frame_size().IsEmpty())
65 return false; 83 return false;
66 const gfx::Size& last_submitted_frame_size = 84 const gfx::Size& last_submitted_frame_size =
67 iter->second->last_submitted_frame_size(); 85 iter->second->last_submitted_frame_size();
68 return last_submitted_frame_size.width() >= window_->bounds().width() && 86 return last_submitted_frame_size.width() >= window_->bounds().width() &&
69 last_submitted_frame_size.height() >= window_->bounds().height(); 87 last_submitted_frame_size.height() >= window_->bounds().height();
70 } 88 }
71 89
72 cc::SurfaceId ServerWindowSurfaceManager::GenerateId() { 90 cc::SurfaceId ServerWindowSurfaceManager::GenerateId() {
73 return surface_id_allocator_.GenerateId(); 91 return surface_id_allocator_.GenerateId();
74 } 92 }
75 93
76 } // namespace ws 94 } // namespace ws
77 } // namespace mus 95 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698