Chromium Code Reviews| Index: ui/aura/window.cc |
| diff --git a/ui/aura/window.cc b/ui/aura/window.cc |
| index 5160bf6c34fbd23f33c5f943d2a8fa9b325b5ba3..aa5bdabf156fc3ef76798246e36c7c69d32e0f76 100644 |
| --- a/ui/aura/window.cc |
| +++ b/ui/aura/window.cc |
| @@ -34,6 +34,15 @@ |
| namespace aura { |
| +namespace { |
| + |
| +void MailboxReleaseCallback(scoped_ptr<base::SharedMemory> shared_memory, |
| + unsigned sync_point, bool lost_resource) { |
| + shared_memory.reset(NULL); |
|
piman
2013/06/07 01:26:28
nit: same as in RWHVA you actually don't need this
slavi
2013/06/07 21:49:21
Done.
|
| +} |
| + |
| +} // namespace |
| + |
| Window::Window(WindowDelegate* delegate) |
| : type_(client::WINDOW_TYPE_UNKNOWN), |
| owned_by_parent_(true), |
| @@ -145,6 +154,9 @@ ui::Layer* Window::RecreateLayer() { |
| return NULL; |
| old_layer->set_delegate(NULL); |
| + float mailbox_scale_factor; |
| + cc::TextureMailbox old_mailbox = |
| + old_layer->GetTextureMailbox(&mailbox_scale_factor); |
| scoped_refptr<ui::Texture> old_texture = old_layer->external_texture(); |
| if (delegate_ && old_texture) |
| old_layer->SetExternalTexture(delegate_->CopyTexture()); |
| @@ -158,8 +170,26 @@ ui::Layer* Window::RecreateLayer() { |
| // Move the original texture to the new layer if the old layer has a |
| // texture and we could copy it into the old layer, |
| // crbug.com/175211. |
| - if (delegate_ && old_texture) |
| + if (delegate_ && old_texture) { |
| layer_->SetExternalTexture(old_texture); |
| + } else if (old_mailbox.IsSharedMemory()) { |
| + base::SharedMemory* old_buffer = old_mailbox.shared_memory(); |
| + const size_t size = old_mailbox.shared_memory_size_in_bytes(); |
| + |
| + scoped_ptr<base::SharedMemory> new_buffer(new base::SharedMemory); |
| + new_buffer->CreateAndMapAnonymous(size); |
| + |
| + if (old_buffer->memory() && new_buffer->memory()) { |
| + memcpy(new_buffer->memory(), old_buffer->memory(), size); |
| + base::SharedMemory* new_buffer_raw_ptr = new_buffer.get(); |
| + cc::TextureMailbox::ReleaseCallback callback = |
| + base::Bind(MailboxReleaseCallback, Passed(new_buffer.Pass())); |
| + cc::TextureMailbox new_mailbox(new_buffer_raw_ptr, |
| + old_mailbox.shared_memory_size(), |
| + callback); |
| + layer_->SetTextureMailbox(new_mailbox, mailbox_scale_factor); |
| + } |
| + } |
| UpdateLayerName(name_); |
| layer_->SetFillsBoundsOpaquely(!transparent_); |
| @@ -313,10 +343,6 @@ void Window::SchedulePaintInRect(const gfx::Rect& rect) { |
| } |
| } |
| -void Window::SetExternalTexture(ui::Texture* texture) { |
| - layer_->SetExternalTexture(texture); |
| -} |
| - |
| void Window::SetDefaultParentByRootWindow(RootWindow* root_window, |
| const gfx::Rect& bounds_in_screen) { |
| DCHECK(root_window); |