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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "cc/layers/texture_layer_client.h" | 10 #include "cc/layers/texture_layer_client.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 | 25 |
26 TextureLayer::TextureLayer(TextureLayerClient* client, bool uses_mailbox) | 26 TextureLayer::TextureLayer(TextureLayerClient* client, bool uses_mailbox) |
27 : Layer(), | 27 : Layer(), |
28 client_(client), | 28 client_(client), |
29 uses_mailbox_(uses_mailbox), | 29 uses_mailbox_(uses_mailbox), |
30 flipped_(true), | 30 flipped_(true), |
31 uv_top_left_(0.f, 0.f), | 31 uv_top_left_(0.f, 0.f), |
32 uv_bottom_right_(1.f, 1.f), | 32 uv_bottom_right_(1.f, 1.f), |
33 premultiplied_alpha_(true), | 33 premultiplied_alpha_(true), |
| 34 blend_background_color_(false), |
34 rate_limit_context_(false), | 35 rate_limit_context_(false), |
35 context_lost_(false), | 36 context_lost_(false), |
36 content_committed_(false), | 37 content_committed_(false), |
37 texture_id_(0), | 38 texture_id_(0), |
38 needs_set_mailbox_(false) { | 39 needs_set_mailbox_(false) { |
39 vertex_opacity_[0] = 1.0f; | 40 vertex_opacity_[0] = 1.0f; |
40 vertex_opacity_[1] = 1.0f; | 41 vertex_opacity_[1] = 1.0f; |
41 vertex_opacity_[2] = 1.0f; | 42 vertex_opacity_[2] = 1.0f; |
42 vertex_opacity_[3] = 1.0f; | 43 vertex_opacity_[3] = 1.0f; |
43 } | 44 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 SetNeedsCommit(); | 100 SetNeedsCommit(); |
100 } | 101 } |
101 | 102 |
102 void TextureLayer::SetPremultipliedAlpha(bool premultiplied_alpha) { | 103 void TextureLayer::SetPremultipliedAlpha(bool premultiplied_alpha) { |
103 if (premultiplied_alpha_ == premultiplied_alpha) | 104 if (premultiplied_alpha_ == premultiplied_alpha) |
104 return; | 105 return; |
105 premultiplied_alpha_ = premultiplied_alpha; | 106 premultiplied_alpha_ = premultiplied_alpha; |
106 SetNeedsCommit(); | 107 SetNeedsCommit(); |
107 } | 108 } |
108 | 109 |
| 110 void TextureLayer::SetBlendBackgroundColor(bool blend) { |
| 111 if (blend_background_color_ == blend) |
| 112 return; |
| 113 blend_background_color_ = blend; |
| 114 SetNeedsCommit(); |
| 115 } |
| 116 |
109 void TextureLayer::SetRateLimitContext(bool rate_limit) { | 117 void TextureLayer::SetRateLimitContext(bool rate_limit) { |
110 if (!rate_limit && rate_limit_context_ && client_ && layer_tree_host()) | 118 if (!rate_limit && rate_limit_context_ && client_ && layer_tree_host()) |
111 layer_tree_host()->StopRateLimiter(client_->Context3d()); | 119 layer_tree_host()->StopRateLimiter(client_->Context3d()); |
112 | 120 |
113 rate_limit_context_ = rate_limit; | 121 rate_limit_context_ = rate_limit; |
114 } | 122 } |
115 | 123 |
116 void TextureLayer::SetTextureId(unsigned id) { | 124 void TextureLayer::SetTextureId(unsigned id) { |
117 DCHECK(!uses_mailbox_); | 125 DCHECK(!uses_mailbox_); |
118 if (texture_id_ == id) | 126 if (texture_id_ == id) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 194 |
187 void TextureLayer::PushPropertiesTo(LayerImpl* layer) { | 195 void TextureLayer::PushPropertiesTo(LayerImpl* layer) { |
188 Layer::PushPropertiesTo(layer); | 196 Layer::PushPropertiesTo(layer); |
189 | 197 |
190 TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer); | 198 TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer); |
191 texture_layer->set_flipped(flipped_); | 199 texture_layer->set_flipped(flipped_); |
192 texture_layer->set_uv_top_left(uv_top_left_); | 200 texture_layer->set_uv_top_left(uv_top_left_); |
193 texture_layer->set_uv_bottom_right(uv_bottom_right_); | 201 texture_layer->set_uv_bottom_right(uv_bottom_right_); |
194 texture_layer->set_vertex_opacity(vertex_opacity_); | 202 texture_layer->set_vertex_opacity(vertex_opacity_); |
195 texture_layer->set_premultiplied_alpha(premultiplied_alpha_); | 203 texture_layer->set_premultiplied_alpha(premultiplied_alpha_); |
| 204 texture_layer->set_blend_background_color(blend_background_color_); |
196 if (uses_mailbox_ && needs_set_mailbox_) { | 205 if (uses_mailbox_ && needs_set_mailbox_) { |
197 TextureMailbox texture_mailbox; | 206 TextureMailbox texture_mailbox; |
198 if (holder_ref_) { | 207 if (holder_ref_) { |
199 MailboxHolder* holder = holder_ref_->holder(); | 208 MailboxHolder* holder = holder_ref_->holder(); |
200 TextureMailbox::ReleaseCallback callback = | 209 TextureMailbox::ReleaseCallback callback = |
201 holder->GetCallbackForImplThread(); | 210 holder->GetCallbackForImplThread(); |
202 texture_mailbox = holder->mailbox().CopyWithNewCallback(callback); | 211 texture_mailbox = holder->mailbox().CopyWithNewCallback(callback); |
203 } | 212 } |
204 texture_layer->SetTextureMailbox(texture_mailbox); | 213 texture_layer->SetTextureMailbox(texture_mailbox); |
205 needs_set_mailbox_ = false; | 214 needs_set_mailbox_ = false; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 } | 291 } |
283 | 292 |
284 void TextureLayer::MailboxHolder::ReturnAndReleaseOnImplThread( | 293 void TextureLayer::MailboxHolder::ReturnAndReleaseOnImplThread( |
285 unsigned sync_point, bool is_lost) { | 294 unsigned sync_point, bool is_lost) { |
286 message_loop_->PostTask(FROM_HERE, base::Bind( | 295 message_loop_->PostTask(FROM_HERE, base::Bind( |
287 &MailboxHolder::ReturnAndReleaseOnMainThread, | 296 &MailboxHolder::ReturnAndReleaseOnMainThread, |
288 this, sync_point, is_lost)); | 297 this, sync_point, is_lost)); |
289 } | 298 } |
290 | 299 |
291 } // namespace cc | 300 } // namespace cc |
OLD | NEW |