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

Unified Diff: cc/layers/texture_layer.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: Removed SharedMemory::DuplicateHandle. 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: cc/layers/texture_layer.cc
diff --git a/cc/layers/texture_layer.cc b/cc/layers/texture_layer.cc
index 4266718daaec2b885b96292fdc85fed6e34199a7..d043e95bda59b893f89afb93028fbce7ac1f26a9 100644
--- a/cc/layers/texture_layer.cc
+++ b/cc/layers/texture_layer.cc
@@ -12,24 +12,28 @@
namespace cc {
-static void RunCallbackOnMainThread(
+namespace {
+
+void RunCallback(
const TextureMailbox::ReleaseCallback& callback,
unsigned sync_point,
bool lost_resource) {
callback.Run(sync_point, lost_resource);
}
-static void PostCallbackToMainThread(
- Thread* main_thread,
+void PostCallbackToThread(
+ Thread* thread,
const TextureMailbox::ReleaseCallback& callback,
unsigned sync_point,
bool lost_resource) {
- main_thread->PostTask(base::Bind(&RunCallbackOnMainThread,
- callback,
- sync_point,
- lost_resource));
+ if (!callback.is_null()) {
+ thread->PostTask(base::Bind(&RunCallback, callback,
+ sync_point, lost_resource));
+ }
}
+} // namespace
+
scoped_refptr<TextureLayer> TextureLayer::Create(TextureLayerClient* client) {
return scoped_refptr<TextureLayer>(new TextureLayer(client, false));
}
@@ -143,13 +147,14 @@ void TextureLayer::SetTextureId(unsigned id) {
void TextureLayer::SetTextureMailbox(const TextureMailbox& mailbox) {
DCHECK(uses_mailbox_);
- DCHECK(mailbox.IsEmpty() || !mailbox.Equals(texture_mailbox_));
+ DCHECK(!mailbox.IsValid() ||
+ mailbox.IsSharedMemory() ||
piman 2013/06/07 01:26:28 In which case do you need to call SetTextureMailbo
slavi 2013/06/07 21:49:21 This check was failing after tab detach/reattach.
piman 2013/06/07 23:29:59 What this means is that detaching/reattaching a ta
+ !mailbox.ContainsMailbox(texture_mailbox_.name()));
// If we never commited the mailbox, we need to release it here
if (own_mailbox_)
texture_mailbox_.RunReleaseCallback(texture_mailbox_.sync_point(), false);
texture_mailbox_ = mailbox;
own_mailbox_ = true;
-
SetNeedsCommit();
}
@@ -174,7 +179,7 @@ void TextureLayer::SetLayerTreeHost(LayerTreeHost* host) {
}
bool TextureLayer::DrawsContent() const {
- return (client_ || texture_id_ || !texture_mailbox_.IsEmpty()) &&
+ return (client_ || texture_id_ || texture_mailbox_.IsValid()) &&
!context_lost_ && Layer::DrawsContent();
}
@@ -184,12 +189,16 @@ void TextureLayer::Update(ResourceUpdateQueue* queue,
if (client_) {
if (uses_mailbox_) {
TextureMailbox mailbox;
- if (client_->PrepareTextureMailbox(&mailbox))
+ if (client_->PrepareTextureMailbox(&mailbox)) {
+ if (mailbox.IsTexture())
+ DCHECK(client_->Context3d());
SetTextureMailbox(mailbox);
+ }
} else {
+ DCHECK(client_->Context3d());
texture_id_ = client_->PrepareTexture(queue);
}
- context_lost_ =
+ context_lost_ = client_->Context3d() &&
client_->Context3d()->getGraphicsResetStatusARB() != GL_NO_ERROR;
}
@@ -207,12 +216,10 @@ void TextureLayer::PushPropertiesTo(LayerImpl* layer) {
texture_layer->set_premultiplied_alpha(premultiplied_alpha_);
if (uses_mailbox_ && own_mailbox_) {
Thread* main_thread = layer_tree_host()->proxy()->MainThread();
- TextureMailbox::ReleaseCallback callback;
- if (!texture_mailbox_.IsEmpty())
- callback = base::Bind(
- &PostCallbackToMainThread, main_thread, texture_mailbox_.callback());
- texture_layer->SetTextureMailbox(TextureMailbox(
- texture_mailbox_.name(), callback, texture_mailbox_.sync_point()));
+ TextureMailbox::ReleaseCallback callback = base::Bind(
+ &PostCallbackToThread, main_thread, texture_mailbox_.callback());
+ texture_layer->SetTextureMailbox(
+ texture_mailbox_.CopyWithNewCallback(callback));
own_mailbox_ = false;
} else {
texture_layer->set_texture_id(texture_id_);

Powered by Google App Engine
This is Rietveld 408576698