Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: cc/layers/texture_layer.cc

Issue 18432002: Blend TextureLayer background-color at draw time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added TextureLayer unittest Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 197
190 void TextureLayer::PushPropertiesTo(LayerImpl* layer) { 198 void TextureLayer::PushPropertiesTo(LayerImpl* layer) {
191 Layer::PushPropertiesTo(layer); 199 Layer::PushPropertiesTo(layer);
192 200
193 TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer); 201 TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer);
194 texture_layer->set_flipped(flipped_); 202 texture_layer->set_flipped(flipped_);
195 texture_layer->set_uv_top_left(uv_top_left_); 203 texture_layer->set_uv_top_left(uv_top_left_);
196 texture_layer->set_uv_bottom_right(uv_bottom_right_); 204 texture_layer->set_uv_bottom_right(uv_bottom_right_);
197 texture_layer->set_vertex_opacity(vertex_opacity_); 205 texture_layer->set_vertex_opacity(vertex_opacity_);
198 texture_layer->set_premultiplied_alpha(premultiplied_alpha_); 206 texture_layer->set_premultiplied_alpha(premultiplied_alpha_);
207 texture_layer->set_blend_background_color(blend_background_color_);
199 if (uses_mailbox_ && needs_set_mailbox_) { 208 if (uses_mailbox_ && needs_set_mailbox_) {
200 TextureMailbox texture_mailbox; 209 TextureMailbox texture_mailbox;
201 if (holder_ref_) { 210 if (holder_ref_) {
202 MailboxHolder* holder = holder_ref_->holder(); 211 MailboxHolder* holder = holder_ref_->holder();
203 TextureMailbox::ReleaseCallback callback = 212 TextureMailbox::ReleaseCallback callback =
204 holder->GetCallbackForImplThread(); 213 holder->GetCallbackForImplThread();
205 texture_mailbox = holder->mailbox().CopyWithNewCallback(callback); 214 texture_mailbox = holder->mailbox().CopyWithNewCallback(callback);
206 } 215 }
207 texture_layer->SetTextureMailbox(texture_mailbox); 216 texture_layer->SetTextureMailbox(texture_mailbox);
208 needs_set_mailbox_ = false; 217 needs_set_mailbox_ = false;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 } 294 }
286 295
287 void TextureLayer::MailboxHolder::ReturnAndReleaseOnImplThread( 296 void TextureLayer::MailboxHolder::ReturnAndReleaseOnImplThread(
288 unsigned sync_point, bool is_lost) { 297 unsigned sync_point, bool is_lost) {
289 message_loop_->PostTask(FROM_HERE, base::Bind( 298 message_loop_->PostTask(FROM_HERE, base::Bind(
290 &MailboxHolder::ReturnAndReleaseOnMainThread, 299 &MailboxHolder::ReturnAndReleaseOnMainThread,
291 this, sync_point, is_lost)); 300 this, sync_point, is_lost));
292 } 301 }
293 302
294 } // namespace cc 303 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698