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

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: nits 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') | no next file with comments »
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..cbc42ceca086e9b30a78844854dce8d971dc1524 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,50 @@ class CC_EXPORT TextureLayer : public Layer {
virtual ~TextureLayer();
private:
+ class MailboxHolder : public base::RefCountedThreadSafe<MailboxHolder> {
+ public:
+ class MainThreadReference {
+ public:
+ explicit MainThreadReference(MailboxHolder* holder);
+ ~MainThreadReference();
+ MailboxHolder* holder() { return holder_; }
+
+ private:
+ scoped_refptr<MailboxHolder> holder_;
+ DISALLOW_COPY_AND_ASSIGN(MainThreadReference);
+ };
+
+ static scoped_ptr<MainThreadReference> Create(
+ 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: the
+ // caller must ensure the callback is called.
+ TextureMailbox::ReleaseCallback GetCallbackForImplThread();
+
+ private:
+ friend class base::RefCountedThreadSafe<MailboxHolder>;
+ friend class MainThreadReference;
+ explicit MailboxHolder(const TextureMailbox& mailbox);
+ ~MailboxHolder();
+ void InternalAddRef();
+ void InternalRelease();
+ 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
+ // are only used on the main thread, or on the impl thread during commit
+ // where the main thread is blocked.
+ const scoped_refptr<base::MessageLoopProxy> message_loop_;
+ unsigned internal_references_;
+ TextureMailbox mailbox_;
+ unsigned sync_point_;
+ bool is_lost_;
+ DISALLOW_COPY_AND_ASSIGN(MailboxHolder);
+ };
+
TextureLayerClient* client_;
bool uses_mailbox_;
@@ -98,8 +146,8 @@ class CC_EXPORT TextureLayer : public Layer {
bool content_committed_;
unsigned texture_id_;
- TextureMailbox texture_mailbox_;
- bool own_mailbox_;
+ scoped_ptr<MailboxHolder::MainThreadReference> holder_ref_;
+ bool needs_set_mailbox_;
DISALLOW_COPY_AND_ASSIGN(TextureLayer);
};
« no previous file with comments | « no previous file | cc/layers/texture_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698