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 SingleReleaseCallbackImpl; |
19 class TextureLayerClient; | 20 class TextureLayerClient; |
20 | 21 |
21 // A Layer containing a the rendered output of a plugin instance. | 22 // A Layer containing a the rendered output of a plugin instance. |
22 class CC_EXPORT TextureLayer : public Layer { | 23 class CC_EXPORT TextureLayer : public Layer { |
23 public: | 24 public: |
24 class CC_EXPORT TextureMailboxHolder | 25 class CC_EXPORT TextureMailboxHolder |
25 : public base::RefCountedThreadSafe<TextureMailboxHolder> { | 26 : public base::RefCountedThreadSafe<TextureMailboxHolder> { |
26 public: | 27 public: |
27 class CC_EXPORT MainThreadReference { | 28 class CC_EXPORT MainThreadReference { |
28 public: | 29 public: |
29 explicit MainThreadReference(TextureMailboxHolder* holder); | 30 explicit MainThreadReference(TextureMailboxHolder* holder); |
30 ~MainThreadReference(); | 31 ~MainThreadReference(); |
31 TextureMailboxHolder* holder() { return holder_.get(); } | 32 TextureMailboxHolder* holder() { return holder_.get(); } |
32 | 33 |
33 private: | 34 private: |
34 scoped_refptr<TextureMailboxHolder> holder_; | 35 scoped_refptr<TextureMailboxHolder> holder_; |
35 DISALLOW_COPY_AND_ASSIGN(MainThreadReference); | 36 DISALLOW_COPY_AND_ASSIGN(MainThreadReference); |
36 }; | 37 }; |
37 | 38 |
38 const TextureMailbox& mailbox() const { return mailbox_; } | 39 const TextureMailbox& mailbox() const { return mailbox_; } |
39 void Return(uint32 sync_point, bool is_lost); | 40 void Return(uint32 sync_point, bool is_lost); |
40 | 41 |
41 // Gets a ReleaseCallback that can be called from another thread. Note: the | 42 // Gets a ReleaseCallback that can be called from another thread. Note: the |
42 // caller must ensure the callback is called. | 43 // caller must ensure the callback is called. |
43 scoped_ptr<SingleReleaseCallback> GetCallbackForImplThread(); | 44 scoped_ptr<SingleReleaseCallbackImpl> GetCallbackForImplThread(); |
44 | 45 |
45 protected: | 46 protected: |
46 friend class TextureLayer; | 47 friend class TextureLayer; |
47 | 48 |
48 // Protected visiblity so only TextureLayer and unit tests can create these. | 49 // Protected visiblity so only TextureLayer and unit tests can create these. |
49 static scoped_ptr<MainThreadReference> Create( | 50 static scoped_ptr<MainThreadReference> Create( |
50 const TextureMailbox& mailbox, | 51 const TextureMailbox& mailbox, |
51 scoped_ptr<SingleReleaseCallback> release_callback); | 52 scoped_ptr<SingleReleaseCallback> release_callback); |
52 virtual ~TextureMailboxHolder(); | 53 virtual ~TextureMailboxHolder(); |
53 | 54 |
54 private: | 55 private: |
55 friend class base::RefCountedThreadSafe<TextureMailboxHolder>; | 56 friend class base::RefCountedThreadSafe<TextureMailboxHolder>; |
56 friend class MainThreadReference; | 57 friend class MainThreadReference; |
57 explicit TextureMailboxHolder( | 58 explicit TextureMailboxHolder( |
58 const TextureMailbox& mailbox, | 59 const TextureMailbox& mailbox, |
59 scoped_ptr<SingleReleaseCallback> release_callback); | 60 scoped_ptr<SingleReleaseCallback> release_callback); |
60 | 61 |
61 void InternalAddRef(); | 62 void InternalAddRef(); |
62 void InternalRelease(); | 63 void InternalRelease(); |
63 void ReturnAndReleaseOnImplThread(uint32 sync_point, bool is_lost); | 64 void ReturnAndReleaseOnImplThread( |
64 | 65 uint32 sync_point, |
65 // This member is thread safe, and is accessed on main and impl threads. | 66 bool is_lost, |
66 const scoped_refptr<BlockingTaskRunner> message_loop_; | 67 scoped_refptr<BlockingTaskRunner> main_thread_task_runner); |
67 | 68 |
68 // 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 |
69 // during commit where the main thread is blocked. | 70 // during commit where the main thread is blocked. |
70 unsigned internal_references_; | 71 unsigned internal_references_; |
71 TextureMailbox mailbox_; | 72 TextureMailbox mailbox_; |
72 scoped_ptr<SingleReleaseCallback> release_callback_; | 73 scoped_ptr<SingleReleaseCallback> release_callback_; |
73 | 74 |
74 // 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 |
75 // 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 |
76 // 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 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 bool rate_limit_context_; | 164 bool rate_limit_context_; |
164 | 165 |
165 scoped_ptr<TextureMailboxHolder::MainThreadReference> holder_ref_; | 166 scoped_ptr<TextureMailboxHolder::MainThreadReference> holder_ref_; |
166 bool needs_set_mailbox_; | 167 bool needs_set_mailbox_; |
167 | 168 |
168 DISALLOW_COPY_AND_ASSIGN(TextureLayer); | 169 DISALLOW_COPY_AND_ASSIGN(TextureLayer); |
169 }; | 170 }; |
170 | 171 |
171 } // namespace cc | 172 } // namespace cc |
172 #endif // CC_LAYERS_TEXTURE_LAYER_H_ | 173 #endif // CC_LAYERS_TEXTURE_LAYER_H_ |
OLD | NEW |