| 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/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 TextureLayer::TextureLayer(const LayerSettings& settings, | 27 TextureLayer::TextureLayer(const LayerSettings& settings, |
| 28 TextureLayerClient* client) | 28 TextureLayerClient* client) |
| 29 : Layer(settings), | 29 : Layer(settings), |
| 30 client_(client), | 30 client_(client), |
| 31 flipped_(true), | 31 flipped_(true), |
| 32 nearest_neighbor_(false), | 32 nearest_neighbor_(false), |
| 33 uv_top_left_(0.f, 0.f), | 33 uv_top_left_(0.f, 0.f), |
| 34 uv_bottom_right_(1.f, 1.f), | 34 uv_bottom_right_(1.f, 1.f), |
| 35 premultiplied_alpha_(true), | 35 premultiplied_alpha_(true), |
| 36 blend_background_color_(false), | 36 blend_background_color_(false), |
| 37 rate_limit_context_(false), | |
| 38 needs_set_mailbox_(false) { | 37 needs_set_mailbox_(false) { |
| 39 vertex_opacity_[0] = 1.0f; | 38 vertex_opacity_[0] = 1.0f; |
| 40 vertex_opacity_[1] = 1.0f; | 39 vertex_opacity_[1] = 1.0f; |
| 41 vertex_opacity_[2] = 1.0f; | 40 vertex_opacity_[2] = 1.0f; |
| 42 vertex_opacity_[3] = 1.0f; | 41 vertex_opacity_[3] = 1.0f; |
| 43 } | 42 } |
| 44 | 43 |
| 45 TextureLayer::~TextureLayer() { | 44 TextureLayer::~TextureLayer() { |
| 46 } | 45 } |
| 47 | 46 |
| 48 void TextureLayer::ClearClient() { | 47 void TextureLayer::ClearClient() { |
| 49 if (rate_limit_context_ && client_ && layer_tree_host()) | |
| 50 layer_tree_host()->StopRateLimiter(); | |
| 51 client_ = nullptr; | 48 client_ = nullptr; |
| 52 ClearTexture(); | 49 ClearTexture(); |
| 53 UpdateDrawsContent(HasDrawableContent()); | 50 UpdateDrawsContent(HasDrawableContent()); |
| 54 } | 51 } |
| 55 | 52 |
| 56 void TextureLayer::ClearTexture() { | 53 void TextureLayer::ClearTexture() { |
| 57 SetTextureMailbox(TextureMailbox(), nullptr); | 54 SetTextureMailbox(TextureMailbox(), nullptr); |
| 58 } | 55 } |
| 59 | 56 |
| 60 scoped_ptr<LayerImpl> TextureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 57 scoped_ptr<LayerImpl> TextureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 SetNeedsCommit(); | 108 SetNeedsCommit(); |
| 112 } | 109 } |
| 113 | 110 |
| 114 void TextureLayer::SetBlendBackgroundColor(bool blend) { | 111 void TextureLayer::SetBlendBackgroundColor(bool blend) { |
| 115 if (blend_background_color_ == blend) | 112 if (blend_background_color_ == blend) |
| 116 return; | 113 return; |
| 117 blend_background_color_ = blend; | 114 blend_background_color_ = blend; |
| 118 SetNeedsCommit(); | 115 SetNeedsCommit(); |
| 119 } | 116 } |
| 120 | 117 |
| 121 void TextureLayer::SetRateLimitContext(bool rate_limit) { | |
| 122 if (!rate_limit && rate_limit_context_ && client_ && layer_tree_host()) | |
| 123 layer_tree_host()->StopRateLimiter(); | |
| 124 | |
| 125 rate_limit_context_ = rate_limit; | |
| 126 } | |
| 127 | |
| 128 void TextureLayer::SetTextureMailboxInternal( | 118 void TextureLayer::SetTextureMailboxInternal( |
| 129 const TextureMailbox& mailbox, | 119 const TextureMailbox& mailbox, |
| 130 scoped_ptr<SingleReleaseCallback> release_callback, | 120 scoped_ptr<SingleReleaseCallback> release_callback, |
| 131 bool requires_commit, | 121 bool requires_commit, |
| 132 bool allow_mailbox_reuse) { | 122 bool allow_mailbox_reuse) { |
| 133 DCHECK(!mailbox.IsValid() || !holder_ref_ || | 123 DCHECK(!mailbox.IsValid() || !holder_ref_ || |
| 134 !mailbox.Equals(holder_ref_->holder()->mailbox()) || | 124 !mailbox.Equals(holder_ref_->holder()->mailbox()) || |
| 135 allow_mailbox_reuse); | 125 allow_mailbox_reuse); |
| 136 DCHECK_EQ(mailbox.IsValid(), !!release_callback); | 126 DCHECK_EQ(mailbox.IsValid(), !!release_callback); |
| 137 | 127 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 bool requires_commit = true; | 168 bool requires_commit = true; |
| 179 bool allow_mailbox_reuse = true; | 169 bool allow_mailbox_reuse = true; |
| 180 if (mailbox.IsValid()) | 170 if (mailbox.IsValid()) |
| 181 release = SingleReleaseCallback::Create(base::Bind(&IgnoreReleaseCallback)); | 171 release = SingleReleaseCallback::Create(base::Bind(&IgnoreReleaseCallback)); |
| 182 SetTextureMailboxInternal( | 172 SetTextureMailboxInternal( |
| 183 mailbox, release.Pass(), requires_commit, allow_mailbox_reuse); | 173 mailbox, release.Pass(), requires_commit, allow_mailbox_reuse); |
| 184 } | 174 } |
| 185 | 175 |
| 186 void TextureLayer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { | 176 void TextureLayer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { |
| 187 Layer::SetNeedsDisplayRect(dirty_rect); | 177 Layer::SetNeedsDisplayRect(dirty_rect); |
| 188 | |
| 189 if (rate_limit_context_ && client_ && layer_tree_host() && DrawsContent()) | |
| 190 layer_tree_host()->StartRateLimiter(); | |
| 191 } | 178 } |
| 192 | 179 |
| 193 void TextureLayer::SetLayerTreeHost(LayerTreeHost* host) { | 180 void TextureLayer::SetLayerTreeHost(LayerTreeHost* host) { |
| 194 if (layer_tree_host() == host) { | 181 if (layer_tree_host() == host) { |
| 195 Layer::SetLayerTreeHost(host); | 182 Layer::SetLayerTreeHost(host); |
| 196 return; | 183 return; |
| 197 } | 184 } |
| 198 | 185 |
| 199 if (layer_tree_host()) { | |
| 200 if (rate_limit_context_ && client_) | |
| 201 layer_tree_host()->StopRateLimiter(); | |
| 202 } | |
| 203 // If we're removed from the tree, the TextureLayerImpl will be destroyed, and | 186 // If we're removed from the tree, the TextureLayerImpl will be destroyed, and |
| 204 // we will need to set the mailbox again on a new TextureLayerImpl the next | 187 // we will need to set the mailbox again on a new TextureLayerImpl the next |
| 205 // time we push. | 188 // time we push. |
| 206 if (!host && holder_ref_) { | 189 if (!host && holder_ref_) { |
| 207 needs_set_mailbox_ = true; | 190 needs_set_mailbox_ = true; |
| 208 // The active frame needs to be replaced and the mailbox returned before the | 191 // The active frame needs to be replaced and the mailbox returned before the |
| 209 // commit is called complete. | 192 // commit is called complete. |
| 210 SetNextCommitWaitsForActivation(); | 193 SetNextCommitWaitsForActivation(); |
| 211 } | 194 } |
| 212 Layer::SetLayerTreeHost(host); | 195 Layer::SetLayerTreeHost(host); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 void TextureLayer::TextureMailboxHolder::ReturnAndReleaseOnImplThread( | 316 void TextureLayer::TextureMailboxHolder::ReturnAndReleaseOnImplThread( |
| 334 uint32 sync_point, | 317 uint32 sync_point, |
| 335 bool is_lost, | 318 bool is_lost, |
| 336 BlockingTaskRunner* main_thread_task_runner) { | 319 BlockingTaskRunner* main_thread_task_runner) { |
| 337 Return(sync_point, is_lost); | 320 Return(sync_point, is_lost); |
| 338 main_thread_task_runner->PostTask( | 321 main_thread_task_runner->PostTask( |
| 339 FROM_HERE, base::Bind(&TextureMailboxHolder::InternalRelease, this)); | 322 FROM_HERE, base::Bind(&TextureMailboxHolder::InternalRelease, this)); |
| 340 } | 323 } |
| 341 | 324 |
| 342 } // namespace cc | 325 } // namespace cc |
| OLD | NEW |