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

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: Fixed DuplicateHandle on Windows. 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..dced7bd292ae73a5f4a83b33f093fe503e4a62e1 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())
+ 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));
}
@@ -66,7 +69,7 @@ TextureLayer::~TextureLayer() {
layer_tree_host()->StopRateLimiter(client_->Context3d());
}
if (own_mailbox_)
- texture_mailbox_.RunReleaseCallback(texture_mailbox_.sync_point(), false);
+ mailbox_.RunReleaseCallback(mailbox_.sync_point(), false);
}
void TextureLayer::ClearClient() {
@@ -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(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;
+ mailbox_.RunReleaseCallback(mailbox_.sync_point(), false);
+ 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_ || mailbox_.IsValid()) &&
!context_lost_ && Layer::DrawsContent();
}
@@ -189,7 +191,7 @@ void TextureLayer::Update(ResourceUpdateQueue* queue,
} else {
texture_id_ = client_->PrepareTexture(queue);
}
- context_lost_ =
+ context_lost_ = client_->Context3d() &&
danakj 2013/05/23 15:34:32 Can you DCHECK that Context3d() is not NULL when t
slavi 2013/05/28 18:55:13 Done.
client_->Context3d()->getGraphicsResetStatusARB() != GL_NO_ERROR;
}
@@ -207,12 +209,17 @@ 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, mailbox_.callback());
+ if (mailbox_.IsTexture()) {
+ texture_layer->SetTextureMailbox(TextureMailbox(
+ mailbox_.name(), callback, mailbox_.sync_point()));
+ } else if (mailbox_.IsSharedMemory()) {
+ texture_layer->SetTextureMailbox(TextureMailbox(
+ mailbox_.handle(), mailbox_.size(), callback));
+ } else {
+ texture_layer->SetTextureMailbox(TextureMailbox());
danakj 2013/05/23 15:34:33 DCHECK that the texture_mailbox_ is not valid?
slavi 2013/05/28 18:55:13 Done.
+ }
own_mailbox_ = false;
} else {
texture_layer->set_texture_id(texture_id_);

Powered by Google App Engine
This is Rietveld 408576698