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 #include "cc/output/texture_mailbox_deleter.h" | 5 #include "cc/output/texture_mailbox_deleter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
11 #include "cc/output/context_provider.h" | 11 #include "cc/output/context_provider.h" |
12 #include "cc/resources/single_release_callback.h" | 12 #include "cc/resources/single_release_callback.h" |
13 #include "gpu/command_buffer/client/gles2_interface.h" | 13 #include "gpu/command_buffer/client/gles2_interface.h" |
| 14 #include "gpu/command_buffer/common/sync_token.h" |
14 | 15 |
15 namespace cc { | 16 namespace cc { |
16 | 17 |
17 static void DeleteTextureOnImplThread( | 18 static void DeleteTextureOnImplThread( |
18 const scoped_refptr<ContextProvider>& context_provider, | 19 const scoped_refptr<ContextProvider>& context_provider, |
19 unsigned texture_id, | 20 unsigned texture_id, |
20 uint32 sync_point, | 21 const gpu::SyncToken& sync_token, |
21 bool is_lost) { | 22 bool is_lost) { |
22 if (sync_point) | 23 if (sync_token.HasData()) { |
23 context_provider->ContextGL()->WaitSyncPointCHROMIUM(sync_point); | 24 context_provider->ContextGL()->WaitSyncTokenCHROMIUM( |
| 25 sync_token.GetConstData()); |
| 26 } |
24 context_provider->ContextGL()->DeleteTextures(1, &texture_id); | 27 context_provider->ContextGL()->DeleteTextures(1, &texture_id); |
25 } | 28 } |
26 | 29 |
27 static void PostTaskFromMainToImplThread( | 30 static void PostTaskFromMainToImplThread( |
28 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 31 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
29 ReleaseCallback run_impl_callback, | 32 ReleaseCallback run_impl_callback, |
30 unsigned sync_point, | 33 const gpu::SyncToken& sync_token, |
31 bool is_lost) { | 34 bool is_lost) { |
32 // This posts the task to RunDeleteTextureOnImplThread(). | 35 // This posts the task to RunDeleteTextureOnImplThread(). |
33 impl_task_runner->PostTask( | 36 impl_task_runner->PostTask( |
34 FROM_HERE, base::Bind(run_impl_callback, sync_point, is_lost)); | 37 FROM_HERE, base::Bind(run_impl_callback, sync_token, is_lost)); |
35 } | 38 } |
36 | 39 |
37 TextureMailboxDeleter::TextureMailboxDeleter( | 40 TextureMailboxDeleter::TextureMailboxDeleter( |
38 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) | 41 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) |
39 : impl_task_runner_(task_runner), weak_ptr_factory_(this) {} | 42 : impl_task_runner_(task_runner), weak_ptr_factory_(this) {} |
40 | 43 |
41 TextureMailboxDeleter::~TextureMailboxDeleter() { | 44 TextureMailboxDeleter::~TextureMailboxDeleter() { |
42 for (size_t i = 0; i < impl_callbacks_.size(); ++i) | 45 for (size_t i = 0; i < impl_callbacks_.size(); ++i) |
43 impl_callbacks_.at(i)->Run(0, true); | 46 impl_callbacks_.at(i)->Run(gpu::SyncToken(), true); |
44 } | 47 } |
45 | 48 |
46 scoped_ptr<SingleReleaseCallback> TextureMailboxDeleter::GetReleaseCallback( | 49 scoped_ptr<SingleReleaseCallback> TextureMailboxDeleter::GetReleaseCallback( |
47 const scoped_refptr<ContextProvider>& context_provider, | 50 const scoped_refptr<ContextProvider>& context_provider, |
48 unsigned texture_id) { | 51 unsigned texture_id) { |
49 // This callback owns a reference on the |context_provider|. It must be | 52 // This callback owns a reference on the |context_provider|. It must be |
50 // destroyed on the impl thread. Upon destruction of this class, the | 53 // destroyed on the impl thread. Upon destruction of this class, the |
51 // callback must immediately be destroyed. | 54 // callback must immediately be destroyed. |
52 scoped_ptr<SingleReleaseCallback> impl_callback = | 55 scoped_ptr<SingleReleaseCallback> impl_callback = |
53 SingleReleaseCallback::Create(base::Bind(&DeleteTextureOnImplThread, | 56 SingleReleaseCallback::Create(base::Bind(&DeleteTextureOnImplThread, |
(...skipping 17 matching lines...) Expand all Loading... |
71 &PostTaskFromMainToImplThread, impl_task_runner_, run_impl_callback)); | 74 &PostTaskFromMainToImplThread, impl_task_runner_, run_impl_callback)); |
72 } else { | 75 } else { |
73 main_callback = SingleReleaseCallback::Create(run_impl_callback); | 76 main_callback = SingleReleaseCallback::Create(run_impl_callback); |
74 } | 77 } |
75 | 78 |
76 return main_callback.Pass(); | 79 return main_callback.Pass(); |
77 } | 80 } |
78 | 81 |
79 void TextureMailboxDeleter::RunDeleteTextureOnImplThread( | 82 void TextureMailboxDeleter::RunDeleteTextureOnImplThread( |
80 SingleReleaseCallback* impl_callback, | 83 SingleReleaseCallback* impl_callback, |
81 unsigned sync_point, | 84 const gpu::SyncToken& sync_token, |
82 bool is_lost) { | 85 bool is_lost) { |
83 for (size_t i = 0; i < impl_callbacks_.size(); ++i) { | 86 for (size_t i = 0; i < impl_callbacks_.size(); ++i) { |
84 if (impl_callbacks_.at(i) == impl_callback) { | 87 if (impl_callbacks_.at(i) == impl_callback) { |
85 // Run the callback, then destroy it here on the impl thread. | 88 // Run the callback, then destroy it here on the impl thread. |
86 impl_callbacks_.at(i)->Run(sync_point, is_lost); | 89 impl_callbacks_.at(i)->Run(sync_token, is_lost); |
87 impl_callbacks_.erase(impl_callbacks_.begin() + i); | 90 impl_callbacks_.erase(impl_callbacks_.begin() + i); |
88 return; | 91 return; |
89 } | 92 } |
90 } | 93 } |
91 | 94 |
92 NOTREACHED() << "The Callback returned by GetDeleteCallback() was called " | 95 NOTREACHED() << "The Callback returned by GetDeleteCallback() was called " |
93 << "more than once."; | 96 << "more than once."; |
94 } | 97 } |
95 | 98 |
96 } // namespace cc | 99 } // namespace cc |
OLD | NEW |