| 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/texture_mailbox.h" | 14 #include "cc/resources/texture_mailbox.h" |
| 15 | 15 |
| 16 namespace blink { class WebGraphicsContext3D; } | 16 namespace blink { class WebGraphicsContext3D; } |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 class BlockingTaskRunner; | 19 class BlockingTaskRunner; |
| 20 class SingleReleaseCallback; | 20 class SingleReleaseCallback; |
| 21 class TextureLayerClient; | 21 class TextureLayerClient; |
| 22 | 22 |
| 23 // A Layer containing a the rendered output of a plugin instance. | 23 // A Layer containing a the rendered output of a plugin instance. |
| 24 class CC_EXPORT TextureLayer : public Layer { | 24 class CC_EXPORT TextureLayer : public Layer { |
| 25 public: | 25 public: |
| 26 class CC_EXPORT MailboxHolder | 26 class CC_EXPORT TextureMailboxHolder |
| 27 : public base::RefCountedThreadSafe<MailboxHolder> { | 27 : public base::RefCountedThreadSafe<TextureMailboxHolder> { |
| 28 public: | 28 public: |
| 29 class CC_EXPORT MainThreadReference { | 29 class CC_EXPORT MainThreadReference { |
| 30 public: | 30 public: |
| 31 explicit MainThreadReference(MailboxHolder* holder); | 31 explicit MainThreadReference(TextureMailboxHolder* holder); |
| 32 ~MainThreadReference(); | 32 ~MainThreadReference(); |
| 33 MailboxHolder* holder() { return holder_.get(); } | 33 TextureMailboxHolder* holder() { return holder_.get(); } |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 scoped_refptr<MailboxHolder> holder_; | 36 scoped_refptr<TextureMailboxHolder> holder_; |
| 37 DISALLOW_COPY_AND_ASSIGN(MainThreadReference); | 37 DISALLOW_COPY_AND_ASSIGN(MainThreadReference); |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 const TextureMailbox& mailbox() const { return mailbox_; } | 40 const TextureMailbox& mailbox() const { return mailbox_; } |
| 41 void Return(unsigned sync_point, bool is_lost); | 41 void Return(uint32 sync_point, bool is_lost); |
| 42 | 42 |
| 43 // 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 |
| 44 // caller must ensure the callback is called. | 44 // caller must ensure the callback is called. |
| 45 scoped_ptr<SingleReleaseCallback> GetCallbackForImplThread(); | 45 scoped_ptr<SingleReleaseCallback> GetCallbackForImplThread(); |
| 46 | 46 |
| 47 protected: | 47 protected: |
| 48 friend class TextureLayer; | 48 friend class TextureLayer; |
| 49 | 49 |
| 50 // Protected visiblity so only TextureLayer and unit tests can create these. | 50 // Protected visiblity so only TextureLayer and unit tests can create these. |
| 51 static scoped_ptr<MainThreadReference> Create( | 51 static scoped_ptr<MainThreadReference> Create( |
| 52 const TextureMailbox& mailbox, | 52 const TextureMailbox& mailbox, |
| 53 scoped_ptr<SingleReleaseCallback> release_callback); | 53 scoped_ptr<SingleReleaseCallback> release_callback); |
| 54 virtual ~MailboxHolder(); | 54 virtual ~TextureMailboxHolder(); |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 friend class base::RefCountedThreadSafe<MailboxHolder>; | 57 friend class base::RefCountedThreadSafe<TextureMailboxHolder>; |
| 58 friend class MainThreadReference; | 58 friend class MainThreadReference; |
| 59 explicit MailboxHolder(const TextureMailbox& mailbox, | 59 explicit TextureMailboxHolder( |
| 60 scoped_ptr<SingleReleaseCallback> release_callback); | 60 const TextureMailbox& mailbox, |
| 61 scoped_ptr<SingleReleaseCallback> release_callback); |
| 61 | 62 |
| 62 void InternalAddRef(); | 63 void InternalAddRef(); |
| 63 void InternalRelease(); | 64 void InternalRelease(); |
| 64 void ReturnAndReleaseOnImplThread(unsigned sync_point, bool is_lost); | 65 void ReturnAndReleaseOnImplThread(uint32 sync_point, bool is_lost); |
| 65 | 66 |
| 66 // This member is thread safe, and is accessed on main and impl threads. | 67 // This member is thread safe, and is accessed on main and impl threads. |
| 67 const scoped_refptr<BlockingTaskRunner> message_loop_; | 68 const scoped_refptr<BlockingTaskRunner> message_loop_; |
| 68 | 69 |
| 69 // These members are only accessed on the main thread, or on the impl thread | 70 // These members are only accessed on the main thread, or on the impl thread |
| 70 // during commit where the main thread is blocked. | 71 // during commit where the main thread is blocked. |
| 71 unsigned internal_references_; | 72 unsigned internal_references_; |
| 72 TextureMailbox mailbox_; | 73 TextureMailbox mailbox_; |
| 73 scoped_ptr<SingleReleaseCallback> release_callback_; | 74 scoped_ptr<SingleReleaseCallback> release_callback_; |
| 74 | 75 |
| 75 // This lock guards the sync_point_ and is_lost_ fields because they can be | 76 // This lock guards the sync_point_ and is_lost_ fields because they can be |
| 76 // accessed on both the impl and main thread. We do this to ensure that the | 77 // accessed on both the impl and main thread. We do this to ensure that the |
| 77 // values of these fields are well-ordered such that the last call to | 78 // values of these fields are well-ordered such that the last call to |
| 78 // ReturnAndReleaseOnImplThread() defines their values. | 79 // ReturnAndReleaseOnImplThread() defines their values. |
| 79 base::Lock arguments_lock_; | 80 base::Lock arguments_lock_; |
| 80 unsigned sync_point_; | 81 uint32 sync_point_; |
| 81 bool is_lost_; | 82 bool is_lost_; |
| 82 DISALLOW_COPY_AND_ASSIGN(MailboxHolder); | 83 DISALLOW_COPY_AND_ASSIGN(TextureMailboxHolder); |
| 83 }; | 84 }; |
| 84 | 85 |
| 85 // If this texture layer requires special preparation logic for each frame | 86 // If this texture layer requires special preparation logic for each frame |
| 86 // driven by the compositor, pass in a non-nil client. Pass in a nil client | 87 // driven by the compositor, pass in a non-nil client. Pass in a nil client |
| 87 // pointer if texture updates are driven by an external process. | 88 // pointer if texture updates are driven by an external process. |
| 88 static scoped_refptr<TextureLayer> Create(TextureLayerClient* client); | 89 static scoped_refptr<TextureLayer> Create(TextureLayerClient* client); |
| 89 | 90 |
| 90 // Used when mailbox names are specified instead of texture IDs. | 91 // Used when mailbox names are specified instead of texture IDs. |
| 91 static scoped_refptr<TextureLayer> CreateForMailbox( | 92 static scoped_refptr<TextureLayer> CreateForMailbox( |
| 92 TextureLayerClient* client); | 93 TextureLayerClient* client); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 gfx::PointF uv_top_left_; | 161 gfx::PointF uv_top_left_; |
| 161 gfx::PointF uv_bottom_right_; | 162 gfx::PointF uv_bottom_right_; |
| 162 // [bottom left, top left, top right, bottom right] | 163 // [bottom left, top left, top right, bottom right] |
| 163 float vertex_opacity_[4]; | 164 float vertex_opacity_[4]; |
| 164 bool premultiplied_alpha_; | 165 bool premultiplied_alpha_; |
| 165 bool blend_background_color_; | 166 bool blend_background_color_; |
| 166 bool rate_limit_context_; | 167 bool rate_limit_context_; |
| 167 bool content_committed_; | 168 bool content_committed_; |
| 168 | 169 |
| 169 unsigned texture_id_; | 170 unsigned texture_id_; |
| 170 scoped_ptr<MailboxHolder::MainThreadReference> holder_ref_; | 171 scoped_ptr<TextureMailboxHolder::MainThreadReference> holder_ref_; |
| 171 bool needs_set_mailbox_; | 172 bool needs_set_mailbox_; |
| 172 | 173 |
| 173 DISALLOW_COPY_AND_ASSIGN(TextureLayer); | 174 DISALLOW_COPY_AND_ASSIGN(TextureLayer); |
| 174 }; | 175 }; |
| 175 | 176 |
| 176 } // namespace cc | 177 } // namespace cc |
| 177 #endif // CC_LAYERS_TEXTURE_LAYER_H_ | 178 #endif // CC_LAYERS_TEXTURE_LAYER_H_ |
| OLD | NEW |