OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_OUTPUT_TEXTURE_MAILBOX_DELETER_H_ | 5 #ifndef CC_OUTPUT_TEXTURE_MAILBOX_DELETER_H_ |
6 #define CC_OUTPUT_TEXTURE_MAILBOX_DELETER_H_ | 6 #define CC_OUTPUT_TEXTURE_MAILBOX_DELETER_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "cc/base/cc_export.h" | 9 #include "cc/base/cc_export.h" |
10 #include "cc/base/scoped_ptr_vector.h" | 10 #include "cc/base/scoped_ptr_vector.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 class SingleThreadTaskRunner; | 13 class SingleThreadTaskRunner; |
14 } | 14 } |
15 | 15 |
| 16 namespace gpu { |
| 17 struct SyncToken; |
| 18 } |
| 19 |
16 namespace cc { | 20 namespace cc { |
17 class ContextProvider; | 21 class ContextProvider; |
18 class SingleReleaseCallback; | 22 class SingleReleaseCallback; |
19 | 23 |
20 class CC_EXPORT TextureMailboxDeleter { | 24 class CC_EXPORT TextureMailboxDeleter { |
21 public: | 25 public: |
22 // task_runner corresponds with the thread the delete task should be posted | 26 // task_runner corresponds with the thread the delete task should be posted |
23 // to. If null, the delete will happen on the calling thread. | 27 // to. If null, the delete will happen on the calling thread. |
24 explicit TextureMailboxDeleter( | 28 explicit TextureMailboxDeleter( |
25 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 29 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
26 ~TextureMailboxDeleter(); | 30 ~TextureMailboxDeleter(); |
27 | 31 |
28 // Returns a Callback that can be used as the ReleaseCallback for a | 32 // Returns a Callback that can be used as the ReleaseCallback for a |
29 // TextureMailbox attached to the |texture_id|. The ReleaseCallback can | 33 // TextureMailbox attached to the |texture_id|. The ReleaseCallback can |
30 // be passed to other threads and will destroy the texture, once it is | 34 // be passed to other threads and will destroy the texture, once it is |
31 // run, on the impl thread. If the TextureMailboxDeleter is destroyed | 35 // run, on the impl thread. If the TextureMailboxDeleter is destroyed |
32 // due to the compositor shutting down, then the ReleaseCallback will | 36 // due to the compositor shutting down, then the ReleaseCallback will |
33 // become a no-op and the texture will be deleted immediately on the | 37 // become a no-op and the texture will be deleted immediately on the |
34 // impl thread, along with dropping the reference to the ContextProvider. | 38 // impl thread, along with dropping the reference to the ContextProvider. |
35 scoped_ptr<SingleReleaseCallback> GetReleaseCallback( | 39 scoped_ptr<SingleReleaseCallback> GetReleaseCallback( |
36 const scoped_refptr<ContextProvider>& context_provider, | 40 const scoped_refptr<ContextProvider>& context_provider, |
37 unsigned texture_id); | 41 unsigned texture_id); |
38 | 42 |
39 private: | 43 private: |
40 // Runs the |impl_callback| to delete the texture and removes the callback | 44 // Runs the |impl_callback| to delete the texture and removes the callback |
41 // from the |impl_callbacks_| list. | 45 // from the |impl_callbacks_| list. |
42 void RunDeleteTextureOnImplThread(SingleReleaseCallback* impl_callback, | 46 void RunDeleteTextureOnImplThread(SingleReleaseCallback* impl_callback, |
43 uint32 sync_point, | 47 const gpu::SyncToken& sync_token, |
44 bool is_lost); | 48 bool is_lost); |
45 | 49 |
46 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_; | 50 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_; |
47 ScopedPtrVector<SingleReleaseCallback> impl_callbacks_; | 51 ScopedPtrVector<SingleReleaseCallback> impl_callbacks_; |
48 base::WeakPtrFactory<TextureMailboxDeleter> weak_ptr_factory_; | 52 base::WeakPtrFactory<TextureMailboxDeleter> weak_ptr_factory_; |
49 }; | 53 }; |
50 | 54 |
51 } // namespace cc | 55 } // namespace cc |
52 | 56 |
53 #endif // CC_OUTPUT_TEXTURE_MAILBOX_DELETER_H_ | 57 #endif // CC_OUTPUT_TEXTURE_MAILBOX_DELETER_H_ |
OLD | NEW |