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/texture_layer.h" | 5 #include "cc/texture_layer.h" |
6 | 6 |
7 #include "cc/layer_tree_host.h" | 7 #include "cc/layer_tree_host.h" |
8 #include "cc/texture_layer_client.h" | 8 #include "cc/texture_layer_client.h" |
9 #include "cc/texture_layer_impl.h" | 9 #include "cc/texture_layer_impl.h" |
10 #include "cc/thread.h" | 10 #include "cc/thread.h" |
11 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 | 14 |
15 static void RunCallbackOnMainThread( | 15 static void RunCallbackOnMainThread( |
16 const TextureMailbox::ReleaseCallback& callback, | 16 const TextureMailbox::ReleaseCallback& callback, |
17 unsigned sync_point) { | 17 unsigned sync_point) { |
18 callback.Run(sync_point); | 18 callback.Run(sync_point); |
19 } | 19 } |
20 | 20 |
21 static void PostCallbackToMainThread( | 21 static void PostCallbackToMainThread( |
22 Thread* main_thread, | 22 Thread* main_thread, |
23 const TextureMailbox::ReleaseCallback& callback, | 23 const TextureMailbox::ReleaseCallback& callback, |
24 unsigned sync_point) { | 24 unsigned sync_point) { |
25 main_thread->postTask( | 25 main_thread->postTask( |
26 base::Bind(&RunCallbackOnMainThread, callback, sync_point)); | 26 base::Bind(&RunCallbackOnMainThread, callback, sync_point)); |
27 } | 27 } |
28 | 28 |
29 scoped_refptr<TextureLayer> TextureLayer::Create(TextureLayerClient* client) { | 29 scoped_refptr<TextureLayer> TextureLayer::Create(TextureLayerClient* client, boo
l single_buffer) { |
30 return scoped_refptr<TextureLayer>(new TextureLayer(client, false)); | 30 return scoped_refptr<TextureLayer>(new TextureLayer(client, false, single_buff
er)); |
31 } | 31 } |
32 | 32 |
33 scoped_refptr<TextureLayer> TextureLayer::CreateForMailbox() { | 33 scoped_refptr<TextureLayer> TextureLayer::CreateForMailbox() { |
34 return scoped_refptr<TextureLayer>(new TextureLayer(NULL, true)); | 34 return scoped_refptr<TextureLayer>(new TextureLayer(NULL, true, false)); |
35 } | 35 } |
36 | 36 |
37 TextureLayer::TextureLayer(TextureLayerClient* client, bool uses_mailbox) | 37 TextureLayer::TextureLayer(TextureLayerClient* client, bool uses_mailbox, bool s
ingle_buffer) |
38 : Layer(), | 38 : Layer(), |
39 client_(client), | 39 client_(client), |
40 uses_mailbox_(uses_mailbox), | 40 uses_mailbox_(uses_mailbox), |
41 flipped_(true), | 41 flipped_(true), |
42 uv_top_left_(0.f, 0.f), | 42 uv_top_left_(0.f, 0.f), |
43 uv_bottom_right_(1.f, 1.f), | 43 uv_bottom_right_(1.f, 1.f), |
44 premultiplied_alpha_(true), | 44 premultiplied_alpha_(true), |
45 rate_limit_context_(false), | 45 rate_limit_context_(false), |
46 context_lost_(false), | 46 context_lost_(false), |
47 texture_id_(0), | 47 texture_id_(0), |
48 content_committed_(false), | 48 content_committed_(false), |
49 own_mailbox_(false) { | 49 own_mailbox_(false), |
| 50 single_buffer_(single_buffer) { |
50 vertex_opacity_[0] = 1.0f; | 51 vertex_opacity_[0] = 1.0f; |
51 vertex_opacity_[1] = 1.0f; | 52 vertex_opacity_[1] = 1.0f; |
52 vertex_opacity_[2] = 1.0f; | 53 vertex_opacity_[2] = 1.0f; |
53 vertex_opacity_[3] = 1.0f; | 54 vertex_opacity_[3] = 1.0f; |
54 } | 55 } |
55 | 56 |
56 TextureLayer::~TextureLayer() { | 57 TextureLayer::~TextureLayer() { |
57 if (layer_tree_host()) { | 58 if (layer_tree_host()) { |
58 if (texture_id_) | 59 if (texture_id_) |
59 layer_tree_host()->AcquireLayerTextures(); | 60 layer_tree_host()->AcquireLayerTextures(); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 texture_mailbox_.name(), callback, texture_mailbox_.sync_point())); | 186 texture_mailbox_.name(), callback, texture_mailbox_.sync_point())); |
186 own_mailbox_ = false; | 187 own_mailbox_ = false; |
187 } else { | 188 } else { |
188 texture_layer->setTextureId(texture_id_); | 189 texture_layer->setTextureId(texture_id_); |
189 } | 190 } |
190 content_committed_ = DrawsContent(); | 191 content_committed_ = DrawsContent(); |
191 } | 192 } |
192 | 193 |
193 bool TextureLayer::BlocksPendingCommit() const { | 194 bool TextureLayer::BlocksPendingCommit() const { |
194 // Double-buffered texture layers need to be blocked until they can be made | 195 // Double-buffered texture layers need to be blocked until they can be made |
195 // triple-buffered. Single-buffered layers already prevent draws, so | 196 // triple-buffered. Single-buffered layers already prevent draws. |
196 // can block too for simplicity. | 197 if (single_buffer_) |
197 return DrawsContent(); | 198 return false; |
| 199 else |
| 200 return DrawsContent(); |
198 } | 201 } |
199 | 202 |
200 bool TextureLayer::CanClipSelf() const { | 203 bool TextureLayer::CanClipSelf() const { |
201 return true; | 204 return true; |
202 } | 205 } |
203 | 206 |
204 } // namespace cc | 207 } // namespace cc |
OLD | NEW |