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

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

Issue 2582823002: WIP: Surface Synchronization System
Patch Set: Only create ClientSurfaceEmbedder if window is visible. Trash it otherwise. Created 3 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.h" 5 #include "services/ui/ws/server_window.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/debug/stack_trace.h"
10 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
11 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
12 #include "services/ui/common/transient_window_utils.h" 13 #include "services/ui/common/transient_window_utils.h"
13 #include "services/ui/public/interfaces/window_manager.mojom.h" 14 #include "services/ui/public/interfaces/window_manager.mojom.h"
14 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" 15 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h"
15 #include "services/ui/ws/server_window_delegate.h" 16 #include "services/ui/ws/server_window_delegate.h"
16 #include "services/ui/ws/server_window_observer.h" 17 #include "services/ui/ws/server_window_observer.h"
17 18
18 namespace ui { 19 namespace ui {
19 namespace ws { 20 namespace ws {
20 21
21 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, const WindowId& id) 22 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, const WindowId& id)
22 : ServerWindow(delegate, id, Properties()) {} 23 : ServerWindow(delegate, id, Properties(), cc::LocalFrameId()) {}
23 24
24 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, 25 ServerWindow::ServerWindow(ServerWindowDelegate* delegate,
25 const WindowId& id, 26 const WindowId& id,
26 const Properties& properties) 27 const Properties& properties,
28 const cc::LocalFrameId& local_frame_id)
27 : delegate_(delegate), 29 : delegate_(delegate),
28 id_(id), 30 id_(id),
31 local_frame_id_(local_frame_id),
29 parent_(nullptr), 32 parent_(nullptr),
30 stacking_target_(nullptr), 33 stacking_target_(nullptr),
31 transient_parent_(nullptr), 34 transient_parent_(nullptr),
32 is_modal_(false), 35 is_modal_(false),
33 visible_(false), 36 visible_(false),
34 cursor_id_(mojom::Cursor::CURSOR_NULL), 37 cursor_id_(mojom::Cursor::CURSOR_NULL),
35 non_client_cursor_id_(mojom::Cursor::CURSOR_NULL), 38 non_client_cursor_id_(mojom::Cursor::CURSOR_NULL),
36 opacity_(1), 39 opacity_(1),
37 can_focus_(true), 40 can_focus_(true),
38 can_accept_events_(true), 41 can_accept_events_(true),
39 properties_(properties), 42 properties_(properties),
40 // Don't notify newly added observers during notification. This causes 43 // Don't notify newly added observers during notification. This causes
41 // problems for code that adds an observer as part of an observer 44 // problems for code that adds an observer as part of an observer
42 // notification (such as ServerWindowDrawTracker). 45 // notification (such as ServerWindowDrawTracker).
43 observers_( 46 observers_(
44 base::ObserverList<ServerWindowObserver>::NOTIFY_EXISTING_ONLY) { 47 base::ObserverList<ServerWindowObserver>::NOTIFY_EXISTING_ONLY) {
45 DCHECK(delegate); // Must provide a delegate. 48 DCHECK(delegate); // Must provide a delegate.
49 fprintf(stderr, ">>>ServerWindow creation: %d\n", WindowIdToTransportId(id));
50 // if (WindowIdToTransportId(id) == 65566)
51 // base::debug::StackTrace().Print();
46 } 52 }
47 53
48 ServerWindow::~ServerWindow() { 54 ServerWindow::~ServerWindow() {
55 fprintf(stderr, ">>>~ServerWindow %s\n", GetDebugWindowInfo().c_str());
49 for (auto& observer : observers_) 56 for (auto& observer : observers_)
50 observer.OnWindowDestroying(this); 57 observer.OnWindowDestroying(this);
51 58
52 if (transient_parent_) 59 if (transient_parent_)
53 transient_parent_->RemoveTransientWindow(this); 60 transient_parent_->RemoveTransientWindow(this);
54 61
55 // Destroy transient children, only after we've removed ourselves from our 62 // Destroy transient children, only after we've removed ourselves from our
56 // parent, as destroying an active transient child may otherwise attempt to 63 // parent, as destroying an active transient child may otherwise attempt to
57 // refocus us. 64 // refocus us.
58 Windows transient_children(transient_children_); 65 Windows transient_children(transient_children_);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 child->Reorder(children_.front(), mojom::OrderDirection::BELOW); 175 child->Reorder(children_.front(), mojom::OrderDirection::BELOW);
169 } 176 }
170 177
171 void ServerWindow::StackChildAtTop(ServerWindow* child) { 178 void ServerWindow::StackChildAtTop(ServerWindow* child) {
172 // There's nothing to do if the child is already at the top. 179 // There's nothing to do if the child is already at the top.
173 if (children_.size() <= 1 || child == children_.back()) 180 if (children_.size() <= 1 || child == children_.back())
174 return; 181 return;
175 child->Reorder(children_.back(), mojom::OrderDirection::ABOVE); 182 child->Reorder(children_.back(), mojom::OrderDirection::ABOVE);
176 } 183 }
177 184
178 void ServerWindow::SetBounds(const gfx::Rect& bounds) { 185 void ServerWindow::SetBounds(const gfx::Rect& bounds,
179 if (bounds_ == bounds) 186 const cc::LocalFrameId& local_frame_id) {
180 return; 187 // if (bounds_ == bounds)
181 188 // return;
182 // TODO(fsamuel): figure out how will this work with CompositorFrames.
183 189
184 const gfx::Rect old_bounds = bounds_; 190 const gfx::Rect old_bounds = bounds_;
185 bounds_ = bounds; 191 bounds_ = bounds;
192 local_frame_id_ = local_frame_id;
193 fprintf(stderr, ">>>ServerWindow::SetBounds(Rect(%d, %d, %d, %d), %s\n",
194 bounds.x(), bounds.y(), bounds.width(), bounds.height(),
195 cc::SurfaceId(cc::FrameSinkId(WindowIdToTransportId(id()), 0),
196 local_frame_id)
197 .ToString()
198 .c_str());
186 for (auto& observer : observers_) 199 for (auto& observer : observers_)
187 observer.OnWindowBoundsChanged(this, old_bounds, bounds); 200 observer.OnWindowBoundsChanged(this, old_bounds, bounds, local_frame_id);
188 } 201 }
189 202
190 void ServerWindow::SetClientArea( 203 void ServerWindow::SetClientArea(
191 const gfx::Insets& insets, 204 const gfx::Insets& insets,
192 const std::vector<gfx::Rect>& additional_client_areas) { 205 const std::vector<gfx::Rect>& additional_client_areas) {
193 if (client_area_ == insets && 206 if (client_area_ == insets &&
194 additional_client_areas == additional_client_areas_) { 207 additional_client_areas == additional_client_areas_) {
195 return; 208 return;
196 } 209 }
197 210
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) 413 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
401 std::string ServerWindow::GetDebugWindowHierarchy() const { 414 std::string ServerWindow::GetDebugWindowHierarchy() const {
402 std::string result; 415 std::string result;
403 BuildDebugInfo(std::string(), &result); 416 BuildDebugInfo(std::string(), &result);
404 return result; 417 return result;
405 } 418 }
406 419
407 std::string ServerWindow::GetDebugWindowInfo() const { 420 std::string ServerWindow::GetDebugWindowInfo() const {
408 std::string name = GetName(); 421 std::string name = GetName();
409 return base::StringPrintf( 422 return base::StringPrintf(
410 "id=%s visible=%s bounds=%d,%d %dx%d %s", id_.ToString().c_str(), 423 "server_id: %d id=%s visible=%s bounds=%d,%d %dx%d %s",
424 WindowIdToTransportId(id_), id_.ToString().c_str(),
411 visible_ ? "true" : "false", bounds_.x(), bounds_.y(), bounds_.width(), 425 visible_ ? "true" : "false", bounds_.x(), bounds_.y(), bounds_.width(),
412 bounds_.height(), !name.empty() ? name.c_str() : "(no name)"); 426 bounds_.height(), !name.empty() ? name.c_str() : "(no name)");
413 } 427 }
414 428
415 void ServerWindow::BuildDebugInfo(const std::string& depth, 429 void ServerWindow::BuildDebugInfo(const std::string& depth,
416 std::string* result) const { 430 std::string* result) const {
417 *result += 431 *result +=
418 base::StringPrintf("%s%s\n", depth.c_str(), GetDebugWindowInfo().c_str()); 432 base::StringPrintf("%s%s\n", depth.c_str(), GetDebugWindowInfo().c_str());
419 for (const ServerWindow* child : children_) 433 for (const ServerWindow* child : children_)
420 child->BuildDebugInfo(depth + " ", result); 434 child->BuildDebugInfo(depth + " ", result);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 window->OnStackingChanged(); 490 window->OnStackingChanged();
477 } 491 }
478 492
479 // static 493 // static
480 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { 494 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) {
481 return &window->stacking_target_; 495 return &window->stacking_target_;
482 } 496 }
483 497
484 } // namespace ws 498 } // namespace ws
485 } // namespace ui 499 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698