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