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); |
}; |