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

Side by Side Diff: ui/wm/core/window_util.cc

Issue 1992853002: Create a LayerDelegate for recreated layers to draw when their content is invalidated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « ui/wm/core/window_util.h ('k') | ui/wm/core/window_util_unittest.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/wm/core/window_util.h" 5 #include "ui/wm/core/window_util.h"
6 6
7 #include "ui/aura/window.h" 7 #include "ui/aura/window.h"
8 #include "ui/compositor/layer.h" 8 #include "ui/compositor/layer.h"
9 #include "ui/compositor/layer_tree_owner.h" 9 #include "ui/compositor/layer_tree_owner.h"
10 #include "ui/wm/core/transient_window_manager.h" 10 #include "ui/wm/core/transient_window_manager.h"
11 #include "ui/wm/public/activation_client.h" 11 #include "ui/wm/public/activation_client.h"
12 12
13 namespace { 13 namespace {
14 14
15 // Invokes RecreateLayer() on all the children of |to_clone|, adding the newly 15 // Invokes RecreateLayer() on all the children of |to_clone|, adding the newly
16 // cloned children to |parent|. 16 // cloned children to |parent|.
17 // 17 //
18 // WARNING: It is assumed that |parent| is ultimately owned by a LayerTreeOwner. 18 // WARNING: It is assumed that |parent| is ultimately owned by a LayerTreeOwner.
19 void CloneChildren(ui::Layer* to_clone, ui::Layer* parent) { 19 void CloneChildren(ui::Layer* to_clone,
20 ui::Layer* parent,
21 wm::LayerDelegateFactory* factory) {
20 typedef std::vector<ui::Layer*> Layers; 22 typedef std::vector<ui::Layer*> Layers;
21 // Make a copy of the children since RecreateLayer() mutates it. 23 // Make a copy of the children since RecreateLayer() mutates it.
22 Layers children(to_clone->children()); 24 Layers children(to_clone->children());
23 for (Layers::const_iterator i = children.begin(); i != children.end(); ++i) { 25 for (Layers::const_iterator i = children.begin(); i != children.end(); ++i) {
24 ui::LayerOwner* owner = (*i)->owner(); 26 ui::LayerOwner* owner = (*i)->owner();
25 ui::Layer* old_layer = owner ? owner->RecreateLayer().release() : NULL; 27 ui::Layer* old_layer = owner ? owner->RecreateLayer().release() : NULL;
26 if (old_layer) { 28 if (old_layer) {
29 if (factory && owner->layer()->delegate())
30 old_layer->set_delegate(
31 factory->CreateDelegate(owner->layer()->delegate()));
27 parent->Add(old_layer); 32 parent->Add(old_layer);
28 // RecreateLayer() moves the existing children to the new layer. Create a 33 // RecreateLayer() moves the existing children to the new layer. Create a
29 // copy of those. 34 // copy of those.
30 CloneChildren(owner->layer(), old_layer); 35 CloneChildren(owner->layer(), old_layer, factory);
31 } 36 }
32 } 37 }
33 } 38 }
34 39
35 } // namespace 40 } // namespace
36 41
37 namespace wm { 42 namespace wm {
38 43
39 void ActivateWindow(aura::Window* window) { 44 void ActivateWindow(aura::Window* window) {
40 DCHECK(window); 45 DCHECK(window);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 aura::client::GetActivationClient(window->GetRootWindow()); 78 aura::client::GetActivationClient(window->GetRootWindow());
74 return client ? client->GetActivatableWindow(window) : NULL; 79 return client ? client->GetActivatableWindow(window) : NULL;
75 } 80 }
76 81
77 aura::Window* GetToplevelWindow(aura::Window* window) { 82 aura::Window* GetToplevelWindow(aura::Window* window) {
78 aura::client::ActivationClient* client = 83 aura::client::ActivationClient* client =
79 aura::client::GetActivationClient(window->GetRootWindow()); 84 aura::client::GetActivationClient(window->GetRootWindow());
80 return client ? client->GetToplevelWindow(window) : NULL; 85 return client ? client->GetToplevelWindow(window) : NULL;
81 } 86 }
82 87
83 std::unique_ptr<ui::LayerTreeOwner> RecreateLayers(ui::LayerOwner* root) { 88 std::unique_ptr<ui::LayerTreeOwner> RecreateLayers(
89 ui::LayerOwner* root,
90 LayerDelegateFactory* factory) {
84 std::unique_ptr<ui::LayerTreeOwner> old_layer( 91 std::unique_ptr<ui::LayerTreeOwner> old_layer(
85 new ui::LayerTreeOwner(root->RecreateLayer().release())); 92 new ui::LayerTreeOwner(root->RecreateLayer().release()));
86 if (old_layer->root()) 93 if (old_layer->root()) {
87 CloneChildren(root->layer(), old_layer->root()); 94 if (factory) {
95 old_layer->root()->set_delegate(
96 factory->CreateDelegate(root->layer()->delegate()));
97 }
98 CloneChildren(root->layer(), old_layer->root(), factory);
99 }
88 return old_layer; 100 return old_layer;
89 } 101 }
90 102
91 aura::Window* GetTransientParent(aura::Window* window) { 103 aura::Window* GetTransientParent(aura::Window* window) {
92 return const_cast<aura::Window*>(GetTransientParent( 104 return const_cast<aura::Window*>(GetTransientParent(
93 const_cast<const aura::Window*>(window))); 105 const_cast<const aura::Window*>(window)));
94 } 106 }
95 107
96 const aura::Window* GetTransientParent(const aura::Window* window) { 108 const aura::Window* GetTransientParent(const aura::Window* window) {
97 const TransientWindowManager* manager = TransientWindowManager::Get(window); 109 const TransientWindowManager* manager = TransientWindowManager::Get(window);
(...skipping 21 matching lines...) Expand all
119 bool HasTransientAncestor(const aura::Window* window, 131 bool HasTransientAncestor(const aura::Window* window,
120 const aura::Window* ancestor) { 132 const aura::Window* ancestor) {
121 const aura::Window* transient_parent = GetTransientParent(window); 133 const aura::Window* transient_parent = GetTransientParent(window);
122 if (transient_parent == ancestor) 134 if (transient_parent == ancestor)
123 return true; 135 return true;
124 return transient_parent ? 136 return transient_parent ?
125 HasTransientAncestor(transient_parent, ancestor) : false; 137 HasTransientAncestor(transient_parent, ancestor) : false;
126 } 138 }
127 139
128 } // namespace wm 140 } // namespace wm
OLDNEW
« no previous file with comments | « ui/wm/core/window_util.h ('k') | ui/wm/core/window_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698