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

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

Issue 2144733005: [WIP] cc: Plumb SurfaceId from clients Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ensure only SurfaceFactoy and tests can update hierarchy Created 4 years, 5 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
« no previous file with comments | « services/ui/ws/server_window_surface.cc ('k') | ui/compositor/compositor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_manager.h" 5 #include "services/ui/ws/server_window_surface_manager.h"
6 6
7 #include "services/ui/surfaces/surfaces_state.h" 7 #include "services/ui/surfaces/surfaces_state.h"
8 #include "services/ui/ws/server_window.h" 8 #include "services/ui/ws/server_window.h"
9 #include "services/ui/ws/server_window_delegate.h" 9 #include "services/ui/ws/server_window_delegate.h"
10 #include "services/ui/ws/server_window_surface.h" 10 #include "services/ui/ws/server_window_surface.h"
11 11
12 namespace ui { 12 namespace ui {
13 namespace ws { 13 namespace ws {
14 14
15 ServerWindowSurfaceManager::ServerWindowSurfaceManager(ServerWindow* window) 15 ServerWindowSurfaceManager::ServerWindowSurfaceManager(ServerWindow* window)
16 : window_(window), 16 : window_(window),
17 surface_id_allocator_( 17 surface_id_allocator_(
18 window->delegate()->GetSurfacesState()->next_client_id()), 18 window->delegate()->GetSurfacesState()->next_client_id()),
19 waiting_for_initial_frames_( 19 waiting_for_initial_frames_(
20 window_->properties().count(ui::mojom::kWaitForUnderlay_Property) > 20 window_->properties().count(ui::mojom::kWaitForUnderlay_Property) >
21 0) { 21 0) {
22 surface_id_allocator_.RegisterSurfaceClientId(GetSurfaceManager());
23 } 22 }
24 23
25 ServerWindowSurfaceManager::~ServerWindowSurfaceManager() { 24 ServerWindowSurfaceManager::~ServerWindowSurfaceManager() {
26 // Explicitly clear the type to surface manager so that this manager 25 // Explicitly clear the type to surface manager so that this manager
27 // is still valid prior during ~ServerWindowSurface. 26 // is still valid prior during ~ServerWindowSurface.
28 type_to_surface_map_.clear(); 27 type_to_surface_map_.clear();
29 } 28 }
30 29
31 bool ServerWindowSurfaceManager::ShouldDraw() { 30 bool ServerWindowSurfaceManager::ShouldDraw() {
32 if (!waiting_for_initial_frames_) 31 if (!waiting_for_initial_frames_)
33 return true; 32 return true;
34 33
35 waiting_for_initial_frames_ = 34 waiting_for_initial_frames_ =
36 !IsSurfaceReadyAndNonEmpty(mojom::SurfaceType::DEFAULT) || 35 !IsSurfaceReadyAndNonEmpty(mojom::SurfaceType::DEFAULT) ||
37 !IsSurfaceReadyAndNonEmpty(mojom::SurfaceType::UNDERLAY); 36 !IsSurfaceReadyAndNonEmpty(mojom::SurfaceType::UNDERLAY);
38 return !waiting_for_initial_frames_; 37 return !waiting_for_initial_frames_;
39 } 38 }
40 39
41 void ServerWindowSurfaceManager::CreateSurface( 40 void ServerWindowSurfaceManager::CreateSurface(
42 mojom::SurfaceType surface_type, 41 mojom::SurfaceType surface_type,
43 mojo::InterfaceRequest<mojom::Surface> request, 42 mojo::InterfaceRequest<mojom::Surface> request,
44 mojom::SurfaceClientPtr client) { 43 mojom::SurfaceClientPtr client) {
45 std::unique_ptr<ServerWindowSurface> surface( 44 std::unique_ptr<ServerWindowSurface> surface(
46 new ServerWindowSurface(this, std::move(request), std::move(client))); 45 new ServerWindowSurface(this, std::move(request), std::move(client)));
47 if (!HasAnySurface()) {
48 // Only one SurfaceFactoryClient can be registered per surface id namespace,
49 // so register the first one. Since all surfaces created by this manager
50 // represent the same window, the begin frame source can be shared by
51 // all surfaces created here.
52 surface->RegisterForBeginFrames();
53 }
54 type_to_surface_map_[surface_type] = std::move(surface); 46 type_to_surface_map_[surface_type] = std::move(surface);
55 } 47 }
56 48
57 ServerWindowSurface* ServerWindowSurfaceManager::GetDefaultSurface() const { 49 ServerWindowSurface* ServerWindowSurfaceManager::GetDefaultSurface() const {
58 return GetSurfaceByType(mojom::SurfaceType::DEFAULT); 50 return GetSurfaceByType(mojom::SurfaceType::DEFAULT);
59 } 51 }
60 52
61 ServerWindowSurface* ServerWindowSurfaceManager::GetUnderlaySurface() const { 53 ServerWindowSurface* ServerWindowSurfaceManager::GetUnderlaySurface() const {
62 return GetSurfaceByType(mojom::SurfaceType::UNDERLAY); 54 return GetSurfaceByType(mojom::SurfaceType::UNDERLAY);
63 } 55 }
(...skipping 29 matching lines...) Expand all
93 return last_submitted_frame_size.width() >= window_->bounds().width() && 85 return last_submitted_frame_size.width() >= window_->bounds().width() &&
94 last_submitted_frame_size.height() >= window_->bounds().height(); 86 last_submitted_frame_size.height() >= window_->bounds().height();
95 } 87 }
96 88
97 cc::SurfaceId ServerWindowSurfaceManager::GenerateId() { 89 cc::SurfaceId ServerWindowSurfaceManager::GenerateId() {
98 return surface_id_allocator_.GenerateId(); 90 return surface_id_allocator_.GenerateId();
99 } 91 }
100 92
101 } // namespace ws 93 } // namespace ws
102 } // namespace ui 94 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/server_window_surface.cc ('k') | ui/compositor/compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698