Upgrade ReadPixels to ES3 semantic in command buffer.
[chromium-blink-merge.git] / cc / output / texture_mailbox_deleter.h
blob19760ea0a4c0d032b06180f8bb9886c769976ccc
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.
5 #ifndef CC_OUTPUT_TEXTURE_MAILBOX_DELETER_H_
6 #define CC_OUTPUT_TEXTURE_MAILBOX_DELETER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "cc/base/cc_export.h"
10 #include "cc/base/scoped_ptr_vector.h"
12 namespace base {
13 class SingleThreadTaskRunner;
16 namespace cc {
17 class ContextProvider;
18 class SingleReleaseCallback;
20 class CC_EXPORT TextureMailboxDeleter {
21 public:
22 // task_runner corresponds with the thread the delete task should be posted
23 // to. If null, the delete will happen on the calling thread.
24 explicit TextureMailboxDeleter(
25 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
26 ~TextureMailboxDeleter();
28 // Returns a Callback that can be used as the ReleaseCallback for a
29 // TextureMailbox attached to the |texture_id|. The ReleaseCallback can
30 // be passed to other threads and will destroy the texture, once it is
31 // run, on the impl thread. If the TextureMailboxDeleter is destroyed
32 // due to the compositor shutting down, then the ReleaseCallback will
33 // become a no-op and the texture will be deleted immediately on the
34 // impl thread, along with dropping the reference to the ContextProvider.
35 scoped_ptr<SingleReleaseCallback> GetReleaseCallback(
36 const scoped_refptr<ContextProvider>& context_provider,
37 unsigned texture_id);
39 private:
40 // Runs the |impl_callback| to delete the texture and removes the callback
41 // from the |impl_callbacks_| list.
42 void RunDeleteTextureOnImplThread(SingleReleaseCallback* impl_callback,
43 uint32 sync_point,
44 bool is_lost);
46 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_;
47 ScopedPtrVector<SingleReleaseCallback> impl_callbacks_;
48 base::WeakPtrFactory<TextureMailboxDeleter> weak_ptr_factory_;
51 } // namespace cc
53 #endif // CC_OUTPUT_TEXTURE_MAILBOX_DELETER_H_