| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 vertex_opacity_[1] = 1.0f; | 43 vertex_opacity_[1] = 1.0f; |
| 44 vertex_opacity_[2] = 1.0f; | 44 vertex_opacity_[2] = 1.0f; |
| 45 vertex_opacity_[3] = 1.0f; | 45 vertex_opacity_[3] = 1.0f; |
| 46 } | 46 } |
| 47 | 47 |
| 48 TextureLayer::~TextureLayer() { | 48 TextureLayer::~TextureLayer() { |
| 49 } | 49 } |
| 50 | 50 |
| 51 void TextureLayer::ClearClient() { | 51 void TextureLayer::ClearClient() { |
| 52 if (rate_limit_context_ && client_ && layer_tree_host()) | 52 if (rate_limit_context_ && client_ && layer_tree_host()) |
| 53 layer_tree_host()->StopRateLimiter(client_->Context3d()); | 53 layer_tree_host()->StopRateLimiter(); |
| 54 client_ = NULL; | 54 client_ = NULL; |
| 55 if (uses_mailbox_) | 55 if (uses_mailbox_) |
| 56 SetTextureMailbox(TextureMailbox(), scoped_ptr<SingleReleaseCallback>()); | 56 SetTextureMailbox(TextureMailbox(), scoped_ptr<SingleReleaseCallback>()); |
| 57 else | 57 else |
| 58 SetTextureId(0); | 58 SetTextureId(0); |
| 59 } | 59 } |
| 60 | 60 |
| 61 scoped_ptr<LayerImpl> TextureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 61 scoped_ptr<LayerImpl> TextureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
| 62 return TextureLayerImpl::Create(tree_impl, id(), uses_mailbox_). | 62 return TextureLayerImpl::Create(tree_impl, id(), uses_mailbox_). |
| 63 PassAs<LayerImpl>(); | 63 PassAs<LayerImpl>(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 void TextureLayer::SetBlendBackgroundColor(bool blend) { | 108 void TextureLayer::SetBlendBackgroundColor(bool blend) { |
| 109 if (blend_background_color_ == blend) | 109 if (blend_background_color_ == blend) |
| 110 return; | 110 return; |
| 111 blend_background_color_ = blend; | 111 blend_background_color_ = blend; |
| 112 SetNeedsCommit(); | 112 SetNeedsCommit(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void TextureLayer::SetRateLimitContext(bool rate_limit) { | 115 void TextureLayer::SetRateLimitContext(bool rate_limit) { |
| 116 if (!rate_limit && rate_limit_context_ && client_ && layer_tree_host()) | 116 if (!rate_limit && rate_limit_context_ && client_ && layer_tree_host()) |
| 117 layer_tree_host()->StopRateLimiter(client_->Context3d()); | 117 layer_tree_host()->StopRateLimiter(); |
| 118 | 118 |
| 119 rate_limit_context_ = rate_limit; | 119 rate_limit_context_ = rate_limit; |
| 120 } | 120 } |
| 121 | 121 |
| 122 void TextureLayer::SetTextureId(unsigned id) { | 122 void TextureLayer::SetTextureId(unsigned id) { |
| 123 DCHECK(!uses_mailbox_); | 123 DCHECK(!uses_mailbox_); |
| 124 if (texture_id_ == id) | 124 if (texture_id_ == id) |
| 125 return; | 125 return; |
| 126 if (texture_id_ && layer_tree_host()) | 126 if (texture_id_ && layer_tree_host()) |
| 127 layer_tree_host()->AcquireLayerTextures(); | 127 layer_tree_host()->AcquireLayerTextures(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 if (layer_tree_host() && (DrawsContent() || content_committed_)) { | 171 if (layer_tree_host() && (DrawsContent() || content_committed_)) { |
| 172 layer_tree_host()->AcquireLayerTextures(); | 172 layer_tree_host()->AcquireLayerTextures(); |
| 173 content_committed_ = false; | 173 content_committed_ = false; |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 | 176 |
| 177 void TextureLayer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) { | 177 void TextureLayer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) { |
| 178 Layer::SetNeedsDisplayRect(dirty_rect); | 178 Layer::SetNeedsDisplayRect(dirty_rect); |
| 179 | 179 |
| 180 if (rate_limit_context_ && client_ && layer_tree_host() && DrawsContent()) | 180 if (rate_limit_context_ && client_ && layer_tree_host() && DrawsContent()) |
| 181 layer_tree_host()->StartRateLimiter(client_->Context3d()); | 181 layer_tree_host()->StartRateLimiter(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void TextureLayer::SetLayerTreeHost(LayerTreeHost* host) { | 184 void TextureLayer::SetLayerTreeHost(LayerTreeHost* host) { |
| 185 if (layer_tree_host() == host) { | 185 if (layer_tree_host() == host) { |
| 186 Layer::SetLayerTreeHost(host); | 186 Layer::SetLayerTreeHost(host); |
| 187 return; | 187 return; |
| 188 } | 188 } |
| 189 | 189 |
| 190 if (layer_tree_host()) { | 190 if (layer_tree_host()) { |
| 191 if (texture_id_) { | 191 if (texture_id_) { |
| 192 layer_tree_host()->AcquireLayerTextures(); | 192 layer_tree_host()->AcquireLayerTextures(); |
| 193 // The texture id needs to be removed from the active tree before the | 193 // The texture id needs to be removed from the active tree before the |
| 194 // commit is called complete. | 194 // commit is called complete. |
| 195 SetNextCommitWaitsForActivation(); | 195 SetNextCommitWaitsForActivation(); |
| 196 } | 196 } |
| 197 if (rate_limit_context_ && client_) | 197 if (rate_limit_context_ && client_) |
| 198 layer_tree_host()->StopRateLimiter(client_->Context3d()); | 198 layer_tree_host()->StopRateLimiter(); |
| 199 } | 199 } |
| 200 // If we're removed from the tree, the TextureLayerImpl will be destroyed, and | 200 // If we're removed from the tree, the TextureLayerImpl will be destroyed, and |
| 201 // we will need to set the mailbox again on a new TextureLayerImpl the next | 201 // we will need to set the mailbox again on a new TextureLayerImpl the next |
| 202 // time we push. | 202 // time we push. |
| 203 if (!host && uses_mailbox_ && holder_ref_) { | 203 if (!host && uses_mailbox_ && holder_ref_) { |
| 204 needs_set_mailbox_ = true; | 204 needs_set_mailbox_ = true; |
| 205 // The active frame needs to be replaced and the mailbox returned before the | 205 // The active frame needs to be replaced and the mailbox returned before the |
| 206 // commit is called complete. | 206 // commit is called complete. |
| 207 SetNextCommitWaitsForActivation(); | 207 SetNextCommitWaitsForActivation(); |
| 208 } | 208 } |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 } | 350 } |
| 351 | 351 |
| 352 void TextureLayer::MailboxHolder::ReturnAndReleaseOnImplThread( | 352 void TextureLayer::MailboxHolder::ReturnAndReleaseOnImplThread( |
| 353 unsigned sync_point, bool is_lost) { | 353 unsigned sync_point, bool is_lost) { |
| 354 Return(sync_point, is_lost); | 354 Return(sync_point, is_lost); |
| 355 message_loop_->PostTask(FROM_HERE, | 355 message_loop_->PostTask(FROM_HERE, |
| 356 base::Bind(&MailboxHolder::InternalRelease, this)); | 356 base::Bind(&MailboxHolder::InternalRelease, this)); |
| 357 } | 357 } |
| 358 | 358 |
| 359 } // namespace cc | 359 } // namespace cc |
| OLD | NEW |