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

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: Created 7 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 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 35956b0b7947d0640ab352307af04a8009d3da61..a3c7ccc0199a8ebcd71df2f5aa6f496cf0d12340 100644
--- a/cc/layers/texture_layer.cc
+++ b/cc/layers/texture_layer.cc
@@ -12,24 +12,27 @@
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())
piman 2013/05/28 20:58:57 nit: braces needed. I'm not sure that this new for
slavi 2013/05/29 18:31:48 Done.
+ 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 +146,12 @@ 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.Equals(texture_mailbox_));
// 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 +176,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 +186,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 +213,18 @@ 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());
+ if (texture_mailbox_.IsTexture()) {
+ texture_layer->SetTextureMailbox(TextureMailbox(
+ texture_mailbox_.name(), callback, texture_mailbox_.sync_point()));
+ } else if (texture_mailbox_.IsSharedMemory()) {
+ texture_layer->SetTextureMailbox(TextureMailbox(
+ texture_mailbox_.handle(), texture_mailbox_.size(), callback));
+ } else {
+ DCHECK(!texture_mailbox_.IsValid());
+ texture_layer->SetTextureMailbox(TextureMailbox());
+ }
piman 2013/05/28 20:58:57 It seems that this whole block could be simplified
slavi 2013/05/29 18:31:48 Done.
own_mailbox_ = false;
} else {
texture_layer->set_texture_id(texture_id_);

Powered by Google App Engine
This is Rietveld 408576698