Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_LAYERS_TEXTURE_LAYER_H_ | 5 #ifndef CC_LAYERS_TEXTURE_LAYER_H_ |
| 6 #define CC_LAYERS_TEXTURE_LAYER_H_ | 6 #define CC_LAYERS_TEXTURE_LAYER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
| 12 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" |
| 13 #include "cc/layers/layer.h" | 13 #include "cc/layers/layer.h" |
| 14 #include "cc/resources/scoped_release_callback.h" | |
|
piman
2013/09/12 01:13:03
File is missing from the CL :(
danakj
2013/09/12 01:20:16
Ooops oops, fixed!
| |
| 14 #include "cc/resources/texture_mailbox.h" | 15 #include "cc/resources/texture_mailbox.h" |
| 15 | 16 |
| 16 namespace WebKit { class WebGraphicsContext3D; } | 17 namespace WebKit { class WebGraphicsContext3D; } |
| 17 | 18 |
| 18 namespace cc { | 19 namespace cc { |
| 19 class BlockingTaskRunner; | 20 class BlockingTaskRunner; |
| 20 class TextureLayerClient; | 21 class TextureLayerClient; |
| 21 | 22 |
| 22 // A Layer containing a the rendered output of a plugin instance. | 23 // A Layer containing a the rendered output of a plugin instance. |
| 23 class CC_EXPORT TextureLayer : public Layer { | 24 class CC_EXPORT TextureLayer : public Layer { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 34 private: | 35 private: |
| 35 scoped_refptr<MailboxHolder> holder_; | 36 scoped_refptr<MailboxHolder> holder_; |
| 36 DISALLOW_COPY_AND_ASSIGN(MainThreadReference); | 37 DISALLOW_COPY_AND_ASSIGN(MainThreadReference); |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 const TextureMailbox& mailbox() const { return mailbox_; } | 40 const TextureMailbox& mailbox() const { return mailbox_; } |
| 40 void Return(unsigned sync_point, bool is_lost); | 41 void Return(unsigned sync_point, bool is_lost); |
| 41 | 42 |
| 42 // Gets a ReleaseCallback that can be called from another thread. Note: the | 43 // Gets a ReleaseCallback that can be called from another thread. Note: the |
| 43 // caller must ensure the callback is called. | 44 // caller must ensure the callback is called. |
| 44 TextureMailbox::ReleaseCallback GetCallbackForImplThread(); | 45 ScopedReleaseCallback GetCallbackForImplThread(); |
| 45 | 46 |
| 46 protected: | 47 protected: |
| 47 friend class TextureLayer; | 48 friend class TextureLayer; |
| 48 | 49 |
| 49 // Protected visiblity so only TextureLayer and unit tests can create these. | 50 // Protected visiblity so only TextureLayer and unit tests can create these. |
| 50 static scoped_ptr<MainThreadReference> Create( | 51 static scoped_ptr<MainThreadReference> Create( |
| 51 const TextureMailbox& mailbox); | 52 const TextureMailbox& mailbox, |
| 53 ScopedReleaseCallback release_callback); | |
| 52 virtual ~MailboxHolder(); | 54 virtual ~MailboxHolder(); |
| 53 | 55 |
| 54 private: | 56 private: |
| 55 friend class base::RefCountedThreadSafe<MailboxHolder>; | 57 friend class base::RefCountedThreadSafe<MailboxHolder>; |
| 56 friend class MainThreadReference; | 58 friend class MainThreadReference; |
| 57 explicit MailboxHolder(const TextureMailbox& mailbox); | 59 explicit MailboxHolder(const TextureMailbox& mailbox, |
| 60 ScopedReleaseCallback release_callback); | |
| 58 | 61 |
| 59 void InternalAddRef(); | 62 void InternalAddRef(); |
| 60 void InternalRelease(); | 63 void InternalRelease(); |
| 61 void ReturnAndReleaseOnImplThread(unsigned sync_point, bool is_lost); | 64 void ReturnAndReleaseOnImplThread(unsigned sync_point, bool is_lost); |
| 62 | 65 |
| 63 // This member is thread safe, and is accessed on main and impl threads. | 66 // This member is thread safe, and is accessed on main and impl threads. |
| 64 const scoped_refptr<BlockingTaskRunner> message_loop_; | 67 const scoped_refptr<BlockingTaskRunner> message_loop_; |
| 65 | 68 |
| 66 // These members are only accessed on the main thread, or on the impl thread | 69 // These members are only accessed on the main thread, or on the impl thread |
| 67 // during commit where the main thread is blocked. | 70 // during commit where the main thread is blocked. |
| 68 unsigned internal_references_; | 71 unsigned internal_references_; |
| 69 TextureMailbox mailbox_; | 72 TextureMailbox mailbox_; |
| 73 ScopedReleaseCallback release_callback_; | |
| 70 | 74 |
| 71 // This lock guards the sync_point_ and is_lost_ fields because they can be | 75 // This lock guards the sync_point_ and is_lost_ fields because they can be |
| 72 // accessed on both the impl and main thread. We do this to ensure that the | 76 // accessed on both the impl and main thread. We do this to ensure that the |
| 73 // values of these fields are well-ordered such that the last call to | 77 // values of these fields are well-ordered such that the last call to |
| 74 // ReturnAndReleaseOnImplThread() defines their values. | 78 // ReturnAndReleaseOnImplThread() defines their values. |
| 75 base::Lock arguments_lock_; | 79 base::Lock arguments_lock_; |
| 76 unsigned sync_point_; | 80 unsigned sync_point_; |
| 77 bool is_lost_; | 81 bool is_lost_; |
| 78 DISALLOW_COPY_AND_ASSIGN(MailboxHolder); | 82 DISALLOW_COPY_AND_ASSIGN(MailboxHolder); |
| 79 }; | 83 }; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 // frames from being queued up before the compositor gets a chance to run. | 122 // frames from being queued up before the compositor gets a chance to run. |
| 119 // Requires a non-nil client. Defaults to false. | 123 // Requires a non-nil client. Defaults to false. |
| 120 void SetRateLimitContext(bool rate_limit); | 124 void SetRateLimitContext(bool rate_limit); |
| 121 | 125 |
| 122 // Code path for plugins which supply their own texture ID. | 126 // Code path for plugins which supply their own texture ID. |
| 123 // DEPRECATED. DO NOT USE. | 127 // DEPRECATED. DO NOT USE. |
| 124 void SetTextureId(unsigned texture_id); | 128 void SetTextureId(unsigned texture_id); |
| 125 | 129 |
| 126 // Code path for plugins which supply their own mailbox. | 130 // Code path for plugins which supply their own mailbox. |
| 127 bool uses_mailbox() const { return uses_mailbox_; } | 131 bool uses_mailbox() const { return uses_mailbox_; } |
| 128 void SetTextureMailbox(const TextureMailbox& mailbox); | 132 void SetTextureMailbox(const TextureMailbox& mailbox, |
| 133 ScopedReleaseCallback release_callback); | |
| 129 | 134 |
| 130 void WillModifyTexture(); | 135 void WillModifyTexture(); |
| 131 | 136 |
| 132 virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect) OVERRIDE; | 137 virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect) OVERRIDE; |
| 133 | 138 |
| 134 virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE; | 139 virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE; |
| 135 virtual bool DrawsContent() const OVERRIDE; | 140 virtual bool DrawsContent() const OVERRIDE; |
| 136 virtual bool Update(ResourceUpdateQueue* queue, | 141 virtual bool Update(ResourceUpdateQueue* queue, |
| 137 const OcclusionTracker* occlusion) OVERRIDE; | 142 const OcclusionTracker* occlusion) OVERRIDE; |
| 138 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; | 143 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 160 | 165 |
| 161 unsigned texture_id_; | 166 unsigned texture_id_; |
| 162 scoped_ptr<MailboxHolder::MainThreadReference> holder_ref_; | 167 scoped_ptr<MailboxHolder::MainThreadReference> holder_ref_; |
| 163 bool needs_set_mailbox_; | 168 bool needs_set_mailbox_; |
| 164 | 169 |
| 165 DISALLOW_COPY_AND_ASSIGN(TextureLayer); | 170 DISALLOW_COPY_AND_ASSIGN(TextureLayer); |
| 166 }; | 171 }; |
| 167 | 172 |
| 168 } // namespace cc | 173 } // namespace cc |
| 169 #endif // CC_LAYERS_TEXTURE_LAYER_H_ | 174 #endif // CC_LAYERS_TEXTURE_LAYER_H_ |
| OLD | NEW |