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