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

Unified Diff: ui/aura/window.cc

Issue 15001027: [Aura] Added Support for rendering software compositor frames as cc::TextureLayers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: ui/aura/window.cc
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index 5160bf6c34fbd23f33c5f943d2a8fa9b325b5ba3..79fb08335af443bd9fad03fad266a7d883afbe86 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -34,6 +34,15 @@
namespace aura {
+namespace {
+
+void MailboxReleaseCallback(base::SharedMemory* shared_memory,
+ unsigned sync_point, bool lost_resource) {
+ delete shared_memory;
+}
+
+} // 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());
@@ -160,6 +172,27 @@ ui::Layer* Window::RecreateLayer() {
// crbug.com/175211.
if (delegate_ && old_texture)
layer_->SetExternalTexture(old_texture);
+ else if (old_mailbox.IsValid()) {
piman 2013/06/05 00:30:55 nit: both sides of the else should have brackets i
slavi 2013/06/06 23:02:47 Done.
+ DCHECK(old_mailbox.IsSharedMemory());
+
+ const size_t size = old_mailbox.shared_memory_size_in_bytes();
+ scoped_ptr<base::SharedMemory> new_buffer(new base::SharedMemory);
+ new_buffer->CreateAndMapAnonymous(size);
+
+ const base::SharedMemoryHandle old_handle =
+ base::SharedMemory::DuplicateHandle(old_mailbox.handle());
+ base::SharedMemory old_buffer(old_handle, false);
piman 2013/06/05 00:30:55 What if, instead of just the handle, we also passe
slavi 2013/06/06 23:02:47 Done.
+ old_buffer.Map(size);
+ if (old_buffer.memory() && new_buffer->memory()) {
+ memcpy(new_buffer->memory(), old_buffer.memory(), size);
+ cc::TextureMailbox::ReleaseCallback callback =
+ base::Bind(MailboxReleaseCallback, new_buffer.release());
piman 2013/06/05 00:30:55 nit: you can use Passed(new_buffer), and make Mail
slavi 2013/06/06 23:02:47 Done.
+ cc::TextureMailbox new_mailbox(new_buffer->handle(),
+ old_mailbox.shared_memory_size(),
+ callback);
+ layer_->SetTextureMailbox(new_mailbox, mailbox_scale_factor);
+ }
+ }
UpdateLayerName(name_);
layer_->SetFillsBoundsOpaquely(!transparent_);
@@ -313,10 +346,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);

Powered by Google App Engine
This is Rietveld 408576698