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