summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorsenorblanco@chromium.org <senorblanco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-15 04:55:06 +0000
committersenorblanco@chromium.org <senorblanco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-15 04:55:06 +0000
commit69f4e1876a18ada0f81db1bb008618a2719af93d (patch)
treedf2062354f4f2bd5eb5e5158c37bbe2cdff8fb7c /cc
parent608aef021712c105cca15d18f918a3487ee4e573 (diff)
downloadchromium_src-69f4e1876a18ada0f81db1bb008618a2719af93d.zip
chromium_src-69f4e1876a18ada0f81db1bb008618a2719af93d.tar.gz
chromium_src-69f4e1876a18ada0f81db1bb008618a2719af93d.tar.bz2
Revert "cc: Don't return mailboxes if the TextureLayer is removed from the tree."
It's causing asserts on GPU layout tests, e.g., virtual/gpu/fast/canvas/canvas-currentColor.html. BUG=249535 TBR=piman Review URL: https://codereview.chromium.org/17143002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206559 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/layers/texture_layer.cc56
-rw-r--r--cc/layers/texture_layer.h21
-rw-r--r--cc/layers/texture_layer_impl.cc2
-rw-r--r--cc/layers/texture_layer_unittest.cc21
4 files changed, 22 insertions, 78 deletions
diff --git a/cc/layers/texture_layer.cc b/cc/layers/texture_layer.cc
index a6022dd..d099631 100644
--- a/cc/layers/texture_layer.cc
+++ b/cc/layers/texture_layer.cc
@@ -55,7 +55,7 @@ TextureLayer::TextureLayer(TextureLayerClient* client, bool uses_mailbox)
context_lost_(false),
content_committed_(false),
texture_id_(0),
- needs_set_mailbox_(false) {
+ own_mailbox_(false) {
vertex_opacity_[0] = 1.0f;
vertex_opacity_[1] = 1.0f;
vertex_opacity_[2] = 1.0f;
@@ -69,6 +69,8 @@ TextureLayer::~TextureLayer() {
if (rate_limit_context_ && client_)
layer_tree_host()->StopRateLimiter(client_->Context3d());
}
+ if (own_mailbox_)
+ texture_mailbox_.RunReleaseCallback(texture_mailbox_.sync_point(), false);
}
void TextureLayer::ClearClient() {
@@ -145,10 +147,13 @@ void TextureLayer::SetTextureId(unsigned id) {
void TextureLayer::SetTextureMailbox(const TextureMailbox& mailbox) {
DCHECK(uses_mailbox_);
- DCHECK(!mailbox.IsValid() || !holder_ || !mailbox.Equals(holder_->mailbox()));
- // If we never commited the mailbox, we need to release it here.
- holder_ = mailbox.IsValid() ? new MailboxHolder(mailbox) : NULL;
- needs_set_mailbox_ = true;
+ if (own_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();
}
@@ -169,16 +174,11 @@ void TextureLayer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) {
void TextureLayer::SetLayerTreeHost(LayerTreeHost* host) {
if (texture_id_ && layer_tree_host() && host != layer_tree_host())
layer_tree_host()->AcquireLayerTextures();
- // If we're removed from the tree, the TextureLayerImpl will be destroyed, and
- // we will need to set the mailbox again on a new TextureLayerImpl the next
- // time we push.
- if (!host && uses_mailbox_ && holder_)
- needs_set_mailbox_ = true;
Layer::SetLayerTreeHost(host);
}
bool TextureLayer::DrawsContent() const {
- return (client_ || texture_id_ || holder_.get()) &&
+ return (client_ || texture_id_ || texture_mailbox_.IsValid()) &&
!context_lost_ && Layer::DrawsContent();
}
@@ -213,18 +213,13 @@ void TextureLayer::PushPropertiesTo(LayerImpl* layer) {
texture_layer->set_uv_bottom_right(uv_bottom_right_);
texture_layer->set_vertex_opacity(vertex_opacity_);
texture_layer->set_premultiplied_alpha(premultiplied_alpha_);
- if (uses_mailbox_ && needs_set_mailbox_) {
- TextureMailbox texture_mailbox;
- if (holder_) {
- Thread* main_thread = layer_tree_host()->proxy()->MainThread();
- TextureMailbox::ReleaseCallback callback = base::Bind(
- &PostCallbackToThread,
- main_thread,
- base::Bind(&MailboxHolder::Return, holder_));
- texture_mailbox = holder_->mailbox().CopyWithNewCallback(callback);
- }
- texture_layer->SetTextureMailbox(texture_mailbox);
- needs_set_mailbox_ = false;
+ if (uses_mailbox_ && own_mailbox_) {
+ Thread* main_thread = layer_tree_host()->proxy()->MainThread();
+ 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_);
}
@@ -242,19 +237,4 @@ bool TextureLayer::CanClipSelf() const {
return true;
}
-TextureLayer::MailboxHolder::MailboxHolder(const TextureMailbox& mailbox)
- : mailbox_(mailbox),
- sync_point_(mailbox.sync_point()),
- is_lost_(false) {
-}
-
-TextureLayer::MailboxHolder::~MailboxHolder() {
- mailbox_.RunReleaseCallback(sync_point_, is_lost_);
-}
-
-void TextureLayer::MailboxHolder::Return(unsigned sync_point, bool is_lost) {
- sync_point_ = sync_point;
- is_lost_ = is_lost;
-}
-
} // namespace cc
diff --git a/cc/layers/texture_layer.h b/cc/layers/texture_layer.h
index e050533..6de1ea49 100644
--- a/cc/layers/texture_layer.h
+++ b/cc/layers/texture_layer.h
@@ -84,23 +84,6 @@ class CC_EXPORT TextureLayer : public Layer {
virtual ~TextureLayer();
private:
- class MailboxHolder : public base::RefCounted<MailboxHolder> {
- public:
- explicit MailboxHolder(const TextureMailbox& mailbox);
-
- const TextureMailbox& mailbox() const { return mailbox_; }
- void Return(unsigned sync_point, bool is_lost);
-
- private:
- friend class base::RefCounted<MailboxHolder>;
- ~MailboxHolder();
-
- TextureMailbox mailbox_;
- unsigned sync_point_;
- bool is_lost_;
- DISALLOW_COPY_AND_ASSIGN(MailboxHolder);
- };
-
TextureLayerClient* client_;
bool uses_mailbox_;
@@ -115,8 +98,8 @@ class CC_EXPORT TextureLayer : public Layer {
bool content_committed_;
unsigned texture_id_;
- scoped_refptr<MailboxHolder> holder_;
- bool needs_set_mailbox_;
+ TextureMailbox texture_mailbox_;
+ bool own_mailbox_;
DISALLOW_COPY_AND_ASSIGN(TextureLayer);
};
diff --git a/cc/layers/texture_layer_impl.cc b/cc/layers/texture_layer_impl.cc
index 3ded0c9..ad28757 100644
--- a/cc/layers/texture_layer_impl.cc
+++ b/cc/layers/texture_layer_impl.cc
@@ -34,6 +34,8 @@ TextureLayerImpl::~TextureLayerImpl() { FreeTextureMailbox(); }
void TextureLayerImpl::SetTextureMailbox(const TextureMailbox& mailbox) {
DCHECK(uses_mailbox_);
+ if (own_mailbox_)
+ DCHECK(!mailbox.IsValid() || !mailbox.Equals(texture_mailbox_));
FreeTextureMailbox();
texture_mailbox_ = mailbox;
own_mailbox_ = true;
diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc
index d6201fa..021265b 100644
--- a/cc/layers/texture_layer_unittest.cc
+++ b/cc/layers/texture_layer_unittest.cc
@@ -413,27 +413,6 @@ class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
break;
case 7:
EXPECT_EQ(4, callback_count_);
- // Restore a mailbox for the next step.
- SetMailbox('5');
- break;
- case 8:
- // Case #5: remove layer from tree. Callback should *not* be called, the
- // mailbox is returned to the main thread.
- EXPECT_EQ(4, callback_count_);
- layer_->RemoveFromParent();
- break;
- case 9:
- // Mailbox was released to the main thread, task was posted, but won't
- // execute until this DidCommit returns.
- // TODO(piman): fix this.
- EXPECT_EQ(4, callback_count_);
- layer_tree_host()->SetNeedsCommit();
- break;
- case 10:
- EXPECT_EQ(4, callback_count_);
- // Resetting the mailbox will call the callback now.
- layer_->SetTextureMailbox(TextureMailbox());
- EXPECT_EQ(5, callback_count_);
EndTest();
break;
default: