OLD | NEW |
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/aura/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 Env::GetInstance()->NotifyWindowInitialized(this); | 138 Env::GetInstance()->NotifyWindowInitialized(this); |
139 } | 139 } |
140 | 140 |
141 ui::Layer* Window::RecreateLayer() { | 141 ui::Layer* Window::RecreateLayer() { |
142 // Disconnect the old layer, but don't delete it. | 142 // Disconnect the old layer, but don't delete it. |
143 ui::Layer* old_layer = AcquireLayer(); | 143 ui::Layer* old_layer = AcquireLayer(); |
144 if (!old_layer) | 144 if (!old_layer) |
145 return NULL; | 145 return NULL; |
146 | 146 |
147 old_layer->set_delegate(NULL); | 147 old_layer->set_delegate(NULL); |
| 148 float mailbox_scale_factor; |
| 149 cc::TextureMailbox mailbox = |
| 150 old_layer->GetTextureMailbox(&mailbox_scale_factor); |
148 scoped_refptr<ui::Texture> old_texture = old_layer->external_texture(); | 151 scoped_refptr<ui::Texture> old_texture = old_layer->external_texture(); |
149 if (delegate_ && old_texture) | 152 if (delegate_ && old_texture) |
150 old_layer->SetExternalTexture(delegate_->CopyTexture()); | 153 old_layer->SetExternalTexture(delegate_->CopyTexture()); |
151 | 154 |
152 layer_ = new ui::Layer(old_layer->type()); | 155 layer_ = new ui::Layer(old_layer->type()); |
153 layer_owner_.reset(layer_); | 156 layer_owner_.reset(layer_); |
154 layer_->SetVisible(old_layer->visible()); | 157 layer_->SetVisible(old_layer->visible()); |
155 layer_->set_scale_content(old_layer->scale_content()); | 158 layer_->set_scale_content(old_layer->scale_content()); |
156 layer_->set_delegate(this); | 159 layer_->set_delegate(this); |
157 layer_->SetMasksToBounds(old_layer->GetMasksToBounds()); | 160 layer_->SetMasksToBounds(old_layer->GetMasksToBounds()); |
158 // Move the original texture to the new layer if the old layer has a | 161 // Move the original texture to the new layer if the old layer has a |
159 // texture and we could copy it into the old layer, | 162 // texture and we could copy it into the old layer, |
160 // crbug.com/175211. | 163 // crbug.com/175211. |
161 if (delegate_ && old_texture) | 164 if (delegate_ && old_texture) |
162 layer_->SetExternalTexture(old_texture); | 165 layer_->SetExternalTexture(old_texture); |
| 166 else if (mailbox.IsValid()) |
| 167 layer_->SetTextureMailbox(mailbox, mailbox_scale_factor); |
163 | 168 |
164 UpdateLayerName(name_); | 169 UpdateLayerName(name_); |
165 layer_->SetFillsBoundsOpaquely(!transparent_); | 170 layer_->SetFillsBoundsOpaquely(!transparent_); |
166 // Install new layer as a sibling of the old layer, stacked below it. | 171 // Install new layer as a sibling of the old layer, stacked below it. |
167 if (old_layer->parent()) { | 172 if (old_layer->parent()) { |
168 old_layer->parent()->Add(layer_); | 173 old_layer->parent()->Add(layer_); |
169 old_layer->parent()->StackBelow(layer_, old_layer); | 174 old_layer->parent()->StackBelow(layer_, old_layer); |
170 } | 175 } |
171 // Migrate all the child layers over to the new layer. Copy the list because | 176 // Migrate all the child layers over to the new layer. Copy the list because |
172 // the items are removed during iteration. | 177 // the items are removed during iteration. |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 return layer_->bounds(); | 311 return layer_->bounds(); |
307 } | 312 } |
308 | 313 |
309 void Window::SchedulePaintInRect(const gfx::Rect& rect) { | 314 void Window::SchedulePaintInRect(const gfx::Rect& rect) { |
310 if (layer_->SchedulePaint(rect)) { | 315 if (layer_->SchedulePaint(rect)) { |
311 FOR_EACH_OBSERVER( | 316 FOR_EACH_OBSERVER( |
312 WindowObserver, observers_, OnWindowPaintScheduled(this, rect)); | 317 WindowObserver, observers_, OnWindowPaintScheduled(this, rect)); |
313 } | 318 } |
314 } | 319 } |
315 | 320 |
316 void Window::SetExternalTexture(ui::Texture* texture) { | |
317 layer_->SetExternalTexture(texture); | |
318 } | |
319 | |
320 void Window::SetDefaultParentByRootWindow(RootWindow* root_window, | 321 void Window::SetDefaultParentByRootWindow(RootWindow* root_window, |
321 const gfx::Rect& bounds_in_screen) { | 322 const gfx::Rect& bounds_in_screen) { |
322 DCHECK(root_window); | 323 DCHECK(root_window); |
323 | 324 |
324 // Stacking clients are mandatory on RootWindow objects. | 325 // Stacking clients are mandatory on RootWindow objects. |
325 client::StackingClient* client = client::GetStackingClient(root_window); | 326 client::StackingClient* client = client::GetStackingClient(root_window); |
326 DCHECK(client); | 327 DCHECK(client); |
327 | 328 |
328 aura::Window* default_parent = client->GetDefaultParent( | 329 aura::Window* default_parent = client->GetDefaultParent( |
329 root_window, this, bounds_in_screen); | 330 root_window, this, bounds_in_screen); |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 bool contains_mouse = false; | 1101 bool contains_mouse = false; |
1101 if (IsVisible()) { | 1102 if (IsVisible()) { |
1102 RootWindow* root_window = GetRootWindow(); | 1103 RootWindow* root_window = GetRootWindow(); |
1103 contains_mouse = root_window && | 1104 contains_mouse = root_window && |
1104 ContainsPointInRoot(root_window->GetLastMouseLocationInRoot()); | 1105 ContainsPointInRoot(root_window->GetLastMouseLocationInRoot()); |
1105 } | 1106 } |
1106 return contains_mouse; | 1107 return contains_mouse; |
1107 } | 1108 } |
1108 | 1109 |
1109 } // namespace aura | 1110 } // namespace aura |
OLD | NEW |