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

Unified Diff: cc/layers/texture_layer.h

Issue 16888015: Reland r206537 - cc: Don't return mailboxes if the TextureLayer is removed from the tree. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix threading issues 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
« no previous file with comments | « no previous file | cc/layers/texture_layer.cc » ('j') | cc/layers/texture_layer.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/texture_layer.h
diff --git a/cc/layers/texture_layer.h b/cc/layers/texture_layer.h
index 6de1ea49efeee466ad273c2de98b89c817f01f99..5193fae45087b4174b35efdeca097acdefe1a296 100644
--- a/cc/layers/texture_layer.h
+++ b/cc/layers/texture_layer.h
@@ -14,6 +14,10 @@
namespace WebKit { class WebGraphicsContext3D; }
+namespace base {
+class MessageLoopProxy;
+}
+
namespace cc {
class TextureLayerClient;
@@ -84,6 +88,35 @@ 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);
+
+ // Gets a ReleaseCallback that can be called from another thread. Note: this
+ // adds a reference that is only released when the callback is called (as
+ // opposed to a traditional callback which releases the reference on
+ // destruction), so the caller must ensure the callback is called.
+ TextureMailbox::ReleaseCallback GetCallbackForImplThread();
+
+ private:
+ friend class base::RefCounted<MailboxHolder>;
+ ~MailboxHolder();
+ void ReturnAndReleaseOnMainThread(unsigned sync_point, bool is_lost);
+ void ReturnAndReleaseOnImplThread(unsigned sync_point, bool is_lost);
+
+ // Thread safety notes: except for the thread-safe message_loop_, all fields
+ // (including refcount) are only used on the main thread, or on the impl
+ // thread during commit where the main thread is blocked.
+ scoped_refptr<base::MessageLoopProxy> const message_loop_;
danakj 2013/06/18 00:53:24 nit: const first (why const?)
piman 2013/06/18 02:10:58 Done.
+ TextureMailbox mailbox_;
+ unsigned sync_point_;
+ bool is_lost_;
+ DISALLOW_COPY_AND_ASSIGN(MailboxHolder);
+ };
+
TextureLayerClient* client_;
bool uses_mailbox_;
@@ -98,8 +131,8 @@ class CC_EXPORT TextureLayer : public Layer {
bool content_committed_;
unsigned texture_id_;
- TextureMailbox texture_mailbox_;
- bool own_mailbox_;
+ scoped_refptr<MailboxHolder> holder_;
+ bool needs_set_mailbox_;
DISALLOW_COPY_AND_ASSIGN(TextureLayer);
};
« no previous file with comments | « no previous file | cc/layers/texture_layer.cc » ('j') | cc/layers/texture_layer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698