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_RESOURCES_TEXTURE_MAILBOX_DELETER_H_ | 5 #ifndef CC_RESOURCES_TEXTURE_MAILBOX_DELETER_H_ |
6 #define CC_RESOURCES_TEXTURE_MAILBOX_DELETER_H_ | 6 #define CC_RESOURCES_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 #include "cc/resources/texture_mailbox.h" | 11 #include "cc/resources/scoped_release_callback.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 class ContextProvider; | 14 class ContextProvider; |
15 | 15 |
16 class CC_EXPORT TextureMailboxDeleter { | 16 class CC_EXPORT TextureMailboxDeleter { |
17 public: | 17 public: |
18 TextureMailboxDeleter(); | 18 TextureMailboxDeleter(); |
19 ~TextureMailboxDeleter(); | 19 ~TextureMailboxDeleter(); |
20 | 20 |
21 // Returns a Callback that can be used as the ReleaseCallback for a | 21 // Returns a Callback that can be used as the ReleaseCallback for a |
22 // TextureMailbox attached to the |texture_id|. The ReleaseCallback can | 22 // TextureMailbox attached to the |texture_id|. The ReleaseCallback can |
23 // be passed to other threads and will destroy the texture, once it is | 23 // be passed to other threads and will destroy the texture, once it is |
24 // run, on the impl thread. If the TextureMailboxDeleter is destroyed | 24 // run, on the impl thread. If the TextureMailboxDeleter is destroyed |
25 // due to the compositor shutting down, then the ReleaseCallback will | 25 // due to the compositor shutting down, then the ReleaseCallback will |
26 // become a no-op and the texture will be deleted immediately on the | 26 // become a no-op and the texture will be deleted immediately on the |
27 // impl thread, along with dropping the reference to the ContextProvider. | 27 // impl thread, along with dropping the reference to the ContextProvider. |
28 TextureMailbox::ReleaseCallback GetReleaseCallback( | 28 ScopedReleaseCallback GetReleaseCallback( |
29 const scoped_refptr<ContextProvider>& context_provider, | 29 const scoped_refptr<ContextProvider>& context_provider, |
30 unsigned texture_id); | 30 unsigned texture_id); |
31 | 31 |
32 private: | 32 private: |
33 // Runs the |impl_callback| to delete the texture and removes the callback | 33 // Runs the |impl_callback| to delete the texture and removes the callback |
34 // from the |impl_callbacks_| list. | 34 // from the |impl_callbacks_| list. |
35 void RunDeleteTextureOnImplThread( | 35 void RunDeleteTextureOnImplThread( |
36 TextureMailbox::ReleaseCallback* impl_callback, | 36 ScopedReleaseCallback* impl_callback, |
37 unsigned sync_point, | 37 unsigned sync_point, |
38 bool is_lost); | 38 bool is_lost); |
39 | 39 |
40 base::WeakPtrFactory<TextureMailboxDeleter> weak_ptr_factory_; | 40 base::WeakPtrFactory<TextureMailboxDeleter> weak_ptr_factory_; |
41 ScopedPtrVector<TextureMailbox::ReleaseCallback> impl_callbacks_; | 41 ScopedPtrVector<ScopedReleaseCallback> impl_callbacks_; |
42 }; | 42 }; |
43 | 43 |
44 } // namespace cc | 44 } // namespace cc |
45 | 45 |
46 #endif // CC_RESOURCES_TEXTURE_MAILBOX_DELETER_H_ | 46 #endif // CC_RESOURCES_TEXTURE_MAILBOX_DELETER_H_ |
OLD | NEW |