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

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

Issue 2369793002: WIP: Propagate SurfaceID up window tree hierarchy
Patch Set: Fix input events: EventDispatcher ignores container windows 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
« no previous file with comments | « services/ui/ws/server_window_surface_manager.h ('k') | services/ui/ws/window_finder.cc » ('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/display_compositor.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 frame_sink_id_(window->id().client_id, window->id().window_id),
17 waiting_for_initial_frames_( 18 waiting_for_initial_frames_(
18 window_->properties().count(ui::mojom::kWaitForUnderlay_Property) > 19 window_->properties().count(ui::mojom::kWaitForUnderlay_Property) >
19 0) { 20 0) {
21 surface_sequence_generator_.set_frame_sink_id(frame_sink_id_);
20 } 22 }
21 23
22 ServerWindowSurfaceManager::~ServerWindowSurfaceManager() { 24 ServerWindowSurfaceManager::~ServerWindowSurfaceManager() {
23 // Explicitly clear the type to surface manager so that this manager 25 // Explicitly clear the type to surface manager so that this manager
24 // is still valid prior during ~ServerWindowSurface. 26 // is still valid prior during ~ServerWindowSurface.
25 type_to_surface_map_.clear(); 27 type_to_surface_map_.clear();
26 } 28 }
27 29
28 bool ServerWindowSurfaceManager::ShouldDraw() { 30 bool ServerWindowSurfaceManager::ShouldDraw() {
29 if (!waiting_for_initial_frames_) 31 if (!waiting_for_initial_frames_)
30 return true; 32 return true;
31 33
32 waiting_for_initial_frames_ = 34 waiting_for_initial_frames_ =
33 !IsSurfaceReadyAndNonEmpty(mojom::SurfaceType::DEFAULT) || 35 !IsSurfaceReadyAndNonEmpty(mojom::SurfaceType::DEFAULT) ||
34 !IsSurfaceReadyAndNonEmpty(mojom::SurfaceType::UNDERLAY); 36 !IsSurfaceReadyAndNonEmpty(mojom::SurfaceType::UNDERLAY);
35 return !waiting_for_initial_frames_; 37 return !waiting_for_initial_frames_;
36 } 38 }
37 39
38 void ServerWindowSurfaceManager::CreateSurface( 40 void ServerWindowSurfaceManager::CreateSurface(
39 mojom::SurfaceType surface_type, 41 mojom::SurfaceType surface_type,
40 mojo::InterfaceRequest<mojom::Surface> request, 42 mojo::InterfaceRequest<mojom::Surface> request,
41 mojom::SurfaceClientPtr client) { 43 mojom::SurfaceClientPtr client) {
44 cc::FrameSinkId id = frame_sink_id_;
45 // TODO(fsamuel): For non-default surfaces let's give them a unique ID that's
46 // different.
47 if (surface_type != mojom::SurfaceType::DEFAULT) {
48 // TODO(fsamuel): HUGE HACK!
49 id = cc::FrameSinkId(
50 100000000,
51 window_->delegate()->GetDisplayCompositor()->next_client_id());
52 }
53
42 std::unique_ptr<ServerWindowSurface> surface( 54 std::unique_ptr<ServerWindowSurface> surface(
43 new ServerWindowSurface(this, std::move(request), std::move(client))); 55 new ServerWindowSurface(this, id, std::move(request), std::move(client)));
44 type_to_surface_map_[surface_type] = std::move(surface); 56 type_to_surface_map_[surface_type] = std::move(surface);
45 } 57 }
46 58
59 cc::SurfaceSequence ServerWindowSurfaceManager::CreateSurfaceSequence() {
60 return surface_sequence_generator_.CreateSurfaceSequence();
61 }
62
63 void ServerWindowSurfaceManager::SatisfySurfaceSequence(
64 const cc::SurfaceSequence& sequence) {
65 std::vector<uint32_t> sequences;
66 sequences.push_back(sequence.sequence);
67 window_->delegate()->GetDisplayCompositor()->manager()->
68 DidSatisfySequences(sequence.frame_sink_id, &sequences);
69 }
70
47 ServerWindowSurface* ServerWindowSurfaceManager::GetDefaultSurface() const { 71 ServerWindowSurface* ServerWindowSurfaceManager::GetDefaultSurface() const {
48 return GetSurfaceByType(mojom::SurfaceType::DEFAULT); 72 return GetSurfaceByType(mojom::SurfaceType::DEFAULT);
49 } 73 }
50 74
51 ServerWindowSurface* ServerWindowSurfaceManager::GetUnderlaySurface() const { 75 ServerWindowSurface* ServerWindowSurfaceManager::GetUnderlaySurface() const {
52 return GetSurfaceByType(mojom::SurfaceType::UNDERLAY); 76 return GetSurfaceByType(mojom::SurfaceType::UNDERLAY);
53 } 77 }
54 78
55 ServerWindowSurface* ServerWindowSurfaceManager::GetSurfaceByType( 79 ServerWindowSurface* ServerWindowSurfaceManager::GetSurfaceByType(
56 mojom::SurfaceType type) const { 80 mojom::SurfaceType type) const {
57 auto iter = type_to_surface_map_.find(type); 81 auto iter = type_to_surface_map_.find(type);
58 return iter == type_to_surface_map_.end() ? nullptr : iter->second.get(); 82 return iter == type_to_surface_map_.end() ? nullptr : iter->second.get();
59 } 83 }
60 84
61 bool ServerWindowSurfaceManager::HasSurfaceOfType( 85 bool ServerWindowSurfaceManager::HasSurfaceOfType(
62 mojom::SurfaceType type) const { 86 mojom::SurfaceType type) const {
63 return type_to_surface_map_.count(type) > 0; 87 return type_to_surface_map_.count(type) > 0;
64 } 88 }
65 89
66 bool ServerWindowSurfaceManager::HasAnySurface() const { 90 bool ServerWindowSurfaceManager::HasAnySurface() const {
67 return GetDefaultSurface() || GetUnderlaySurface(); 91 return GetDefaultSurface() || GetUnderlaySurface();
68 } 92 }
69 93
70 cc::SurfaceManager* ServerWindowSurfaceManager::GetSurfaceManager() { 94 cc::SurfaceManager* ServerWindowSurfaceManager::GetSurfaceManager() {
71 return window()->delegate()->GetSurfacesState()->manager(); 95 return window()->delegate()->GetDisplayCompositor()->manager();
72 } 96 }
73 97
74 bool ServerWindowSurfaceManager::IsSurfaceReadyAndNonEmpty( 98 bool ServerWindowSurfaceManager::IsSurfaceReadyAndNonEmpty(
75 mojom::SurfaceType type) const { 99 mojom::SurfaceType type) const {
76 auto iter = type_to_surface_map_.find(type); 100 auto iter = type_to_surface_map_.find(type);
77 if (iter == type_to_surface_map_.end()) 101 if (iter == type_to_surface_map_.end())
78 return false; 102 return false;
79 if (iter->second->last_submitted_frame_size().IsEmpty()) 103 if (iter->second->last_submitted_frame_size().IsEmpty())
80 return false; 104 return false;
81 const gfx::Size& last_submitted_frame_size = 105 const gfx::Size& last_submitted_frame_size =
82 iter->second->last_submitted_frame_size(); 106 iter->second->last_submitted_frame_size();
83 return last_submitted_frame_size.width() >= window_->bounds().width() && 107 return last_submitted_frame_size.width() >= window_->bounds().width() &&
84 last_submitted_frame_size.height() >= window_->bounds().height(); 108 last_submitted_frame_size.height() >= window_->bounds().height();
85 } 109 }
86 110
87 } // namespace ws 111 } // namespace ws
88 } // namespace ui 112 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/server_window_surface_manager.h ('k') | services/ui/ws/window_finder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698