OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/layers/texture_layer.h" | 5 #include "cc/layers/texture_layer.h" |
6 | 6 |
7 #include "cc/base/thread.h" | 7 #include "base/location.h" |
| 8 #include "base/single_thread_task_runner.h" |
8 #include "cc/layers/texture_layer_client.h" | 9 #include "cc/layers/texture_layer_client.h" |
9 #include "cc/layers/texture_layer_impl.h" | 10 #include "cc/layers/texture_layer_impl.h" |
10 #include "cc/trees/layer_tree_host.h" | 11 #include "cc/trees/layer_tree_host.h" |
11 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 12 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
12 | 13 |
13 namespace cc { | 14 namespace cc { |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 void RunCallback( | 18 void RunCallback( |
18 const TextureMailbox::ReleaseCallback& callback, | 19 const TextureMailbox::ReleaseCallback& callback, |
19 unsigned sync_point, | 20 unsigned sync_point, |
20 bool lost_resource) { | 21 bool lost_resource) { |
21 callback.Run(sync_point, lost_resource); | 22 callback.Run(sync_point, lost_resource); |
22 } | 23 } |
23 | 24 |
24 void PostCallbackToThread( | 25 void PostCallbackToThread( |
25 Thread* thread, | 26 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
26 const TextureMailbox::ReleaseCallback& callback, | 27 const TextureMailbox::ReleaseCallback& callback, |
27 unsigned sync_point, | 28 unsigned sync_point, |
28 bool lost_resource) { | 29 bool lost_resource) { |
29 if (!callback.is_null()) { | 30 if (!callback.is_null()) { |
30 thread->PostTask(base::Bind(&RunCallback, callback, | 31 task_runner->PostTask(FROM_HERE, |
31 sync_point, lost_resource)); | 32 base::Bind(&RunCallback, callback, |
| 33 sync_point, lost_resource)); |
32 } | 34 } |
33 } | 35 } |
34 | 36 |
35 } // namespace | 37 } // namespace |
36 | 38 |
37 scoped_refptr<TextureLayer> TextureLayer::Create(TextureLayerClient* client) { | 39 scoped_refptr<TextureLayer> TextureLayer::Create(TextureLayerClient* client) { |
38 return scoped_refptr<TextureLayer>(new TextureLayer(client, false)); | 40 return scoped_refptr<TextureLayer>(new TextureLayer(client, false)); |
39 } | 41 } |
40 | 42 |
41 scoped_refptr<TextureLayer> TextureLayer::CreateForMailbox( | 43 scoped_refptr<TextureLayer> TextureLayer::CreateForMailbox( |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 void TextureLayer::PushPropertiesTo(LayerImpl* layer) { | 209 void TextureLayer::PushPropertiesTo(LayerImpl* layer) { |
208 Layer::PushPropertiesTo(layer); | 210 Layer::PushPropertiesTo(layer); |
209 | 211 |
210 TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer); | 212 TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer); |
211 texture_layer->set_flipped(flipped_); | 213 texture_layer->set_flipped(flipped_); |
212 texture_layer->set_uv_top_left(uv_top_left_); | 214 texture_layer->set_uv_top_left(uv_top_left_); |
213 texture_layer->set_uv_bottom_right(uv_bottom_right_); | 215 texture_layer->set_uv_bottom_right(uv_bottom_right_); |
214 texture_layer->set_vertex_opacity(vertex_opacity_); | 216 texture_layer->set_vertex_opacity(vertex_opacity_); |
215 texture_layer->set_premultiplied_alpha(premultiplied_alpha_); | 217 texture_layer->set_premultiplied_alpha(premultiplied_alpha_); |
216 if (uses_mailbox_ && own_mailbox_) { | 218 if (uses_mailbox_ && own_mailbox_) { |
217 Thread* main_thread = layer_tree_host()->proxy()->MainThread(); | 219 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
| 220 layer_tree_host()->proxy()->MainThreadTaskRunner(); |
218 TextureMailbox::ReleaseCallback callback = base::Bind( | 221 TextureMailbox::ReleaseCallback callback = base::Bind( |
219 &PostCallbackToThread, main_thread, texture_mailbox_.callback()); | 222 &PostCallbackToThread, |
| 223 main_thread_task_runner, |
| 224 texture_mailbox_.callback()); |
220 texture_layer->SetTextureMailbox( | 225 texture_layer->SetTextureMailbox( |
221 texture_mailbox_.CopyWithNewCallback(callback)); | 226 texture_mailbox_.CopyWithNewCallback(callback)); |
222 own_mailbox_ = false; | 227 own_mailbox_ = false; |
223 } else { | 228 } else { |
224 texture_layer->set_texture_id(texture_id_); | 229 texture_layer->set_texture_id(texture_id_); |
225 } | 230 } |
226 content_committed_ = DrawsContent(); | 231 content_committed_ = DrawsContent(); |
227 } | 232 } |
228 | 233 |
229 bool TextureLayer::BlocksPendingCommit() const { | 234 bool TextureLayer::BlocksPendingCommit() const { |
230 // Double-buffered texture layers need to be blocked until they can be made | 235 // Double-buffered texture layers need to be blocked until they can be made |
231 // triple-buffered. Single-buffered layers already prevent draws, so | 236 // triple-buffered. Single-buffered layers already prevent draws, so |
232 // can block too for simplicity. | 237 // can block too for simplicity. |
233 return DrawsContent(); | 238 return DrawsContent(); |
234 } | 239 } |
235 | 240 |
236 bool TextureLayer::CanClipSelf() const { | 241 bool TextureLayer::CanClipSelf() const { |
237 return true; | 242 return true; |
238 } | 243 } |
239 | 244 |
240 } // namespace cc | 245 } // namespace cc |
OLD | NEW |