Chromium Code Reviews| 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 "cc/base/thread.h" | 7 #include "cc/base/thread.h" |
| 8 #include "cc/layers/texture_layer_client.h" | 8 #include "cc/layers/texture_layer_client.h" |
| 9 #include "cc/layers/texture_layer_impl.h" | 9 #include "cc/layers/texture_layer_impl.h" |
| 10 #include "cc/trees/layer_tree_host.h" | 10 #include "cc/trees/layer_tree_host.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 vertex_opacity_[0] = 1.0f; | 55 vertex_opacity_[0] = 1.0f; |
| 56 vertex_opacity_[1] = 1.0f; | 56 vertex_opacity_[1] = 1.0f; |
| 57 vertex_opacity_[2] = 1.0f; | 57 vertex_opacity_[2] = 1.0f; |
| 58 vertex_opacity_[3] = 1.0f; | 58 vertex_opacity_[3] = 1.0f; |
| 59 } | 59 } |
| 60 | 60 |
| 61 TextureLayer::~TextureLayer() { | 61 TextureLayer::~TextureLayer() { |
| 62 if (layer_tree_host()) { | 62 if (layer_tree_host()) { |
| 63 if (texture_id_) | 63 if (texture_id_) |
| 64 layer_tree_host()->AcquireLayerTextures(); | 64 layer_tree_host()->AcquireLayerTextures(); |
| 65 if (rate_limit_context_ && client_) | 65 if (rate_limit_context_ && client_ && client_->Context3d()) |
| 66 layer_tree_host()->StopRateLimiter(client_->Context3d()); | 66 layer_tree_host()->StopRateLimiter(client_->Context3d()); |
| 67 } | 67 } |
| 68 if (own_mailbox_) | 68 if (own_mailbox_) |
| 69 texture_mailbox_.RunReleaseCallback(texture_mailbox_.sync_point(), false); | 69 texture_mailbox_.RunReleaseCallback(texture_mailbox_.sync_point(), false); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void TextureLayer::ClearClient() { | 72 void TextureLayer::ClearClient() { |
| 73 client_ = NULL; | 73 client_ = NULL; |
| 74 if (uses_mailbox_) | 74 if (uses_mailbox_) |
| 75 SetTextureMailbox(TextureMailbox()); | 75 SetTextureMailbox(TextureMailbox()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 } | 118 } |
| 119 | 119 |
| 120 void TextureLayer::SetPremultipliedAlpha(bool premultiplied_alpha) { | 120 void TextureLayer::SetPremultipliedAlpha(bool premultiplied_alpha) { |
| 121 if (premultiplied_alpha_ == premultiplied_alpha) | 121 if (premultiplied_alpha_ == premultiplied_alpha) |
| 122 return; | 122 return; |
| 123 premultiplied_alpha_ = premultiplied_alpha; | 123 premultiplied_alpha_ = premultiplied_alpha; |
| 124 SetNeedsCommit(); | 124 SetNeedsCommit(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void TextureLayer::SetRateLimitContext(bool rate_limit) { | 127 void TextureLayer::SetRateLimitContext(bool rate_limit) { |
| 128 if (!rate_limit && rate_limit_context_ && client_ && layer_tree_host()) | 128 if (!rate_limit && rate_limit_context_ && client_ && client_->Context3d() && |
| 129 layer_tree_host()) | |
| 129 layer_tree_host()->StopRateLimiter(client_->Context3d()); | 130 layer_tree_host()->StopRateLimiter(client_->Context3d()); |
| 130 | 131 |
| 131 rate_limit_context_ = rate_limit; | 132 rate_limit_context_ = rate_limit; |
| 132 } | 133 } |
| 133 | 134 |
| 134 void TextureLayer::SetTextureId(unsigned id) { | 135 void TextureLayer::SetTextureId(unsigned id) { |
| 135 DCHECK(!uses_mailbox_); | 136 DCHECK(!uses_mailbox_); |
| 136 if (texture_id_ == id) | 137 if (texture_id_ == id) |
| 137 return; | 138 return; |
| 138 if (texture_id_ && layer_tree_host()) | 139 if (texture_id_ && layer_tree_host()) |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 156 void TextureLayer::WillModifyTexture() { | 157 void TextureLayer::WillModifyTexture() { |
| 157 if (layer_tree_host() && (DrawsContent() || content_committed_)) { | 158 if (layer_tree_host() && (DrawsContent() || content_committed_)) { |
| 158 layer_tree_host()->AcquireLayerTextures(); | 159 layer_tree_host()->AcquireLayerTextures(); |
| 159 content_committed_ = false; | 160 content_committed_ = false; |
| 160 } | 161 } |
| 161 } | 162 } |
| 162 | 163 |
| 163 void TextureLayer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) { | 164 void TextureLayer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) { |
| 164 Layer::SetNeedsDisplayRect(dirty_rect); | 165 Layer::SetNeedsDisplayRect(dirty_rect); |
| 165 | 166 |
| 166 if (rate_limit_context_ && client_ && layer_tree_host() && DrawsContent()) | 167 if (rate_limit_context_ && client_ && client_->Context3d() && |
|
Justin Novosad
2013/06/21 18:24:11
I was getting test crashes right here because of l
piman
2013/06/21 19:05:05
Why is the context NULL after a context loss?
Losi
| |
| 168 layer_tree_host() && DrawsContent()) | |
| 167 layer_tree_host()->StartRateLimiter(client_->Context3d()); | 169 layer_tree_host()->StartRateLimiter(client_->Context3d()); |
| 168 } | 170 } |
| 169 | 171 |
| 170 void TextureLayer::SetLayerTreeHost(LayerTreeHost* host) { | 172 void TextureLayer::SetLayerTreeHost(LayerTreeHost* host) { |
| 171 if (texture_id_ && layer_tree_host() && host != layer_tree_host()) | 173 if (texture_id_ && layer_tree_host() && host != layer_tree_host()) |
| 172 layer_tree_host()->AcquireLayerTextures(); | 174 layer_tree_host()->AcquireLayerTextures(); |
| 173 Layer::SetLayerTreeHost(host); | 175 Layer::SetLayerTreeHost(host); |
| 174 } | 176 } |
| 175 | 177 |
| 176 bool TextureLayer::DrawsContent() const { | 178 bool TextureLayer::DrawsContent() const { |
| 177 return (client_ || texture_id_ || !texture_mailbox_.IsEmpty()) && | 179 return (client_ || texture_id_ || !texture_mailbox_.IsEmpty()) && |
| 178 !context_lost_ && Layer::DrawsContent(); | 180 !context_lost_ && Layer::DrawsContent(); |
| 179 } | 181 } |
| 180 | 182 |
| 181 void TextureLayer::Update(ResourceUpdateQueue* queue, | 183 void TextureLayer::Update(ResourceUpdateQueue* queue, |
| 182 const OcclusionTracker* occlusion, | 184 const OcclusionTracker* occlusion, |
| 183 RenderingStats* stats) { | 185 RenderingStats* stats) { |
| 184 if (client_) { | 186 if (client_) { |
| 185 if (uses_mailbox_) { | 187 if (uses_mailbox_) { |
| 186 TextureMailbox mailbox; | 188 TextureMailbox mailbox; |
| 187 if (client_->PrepareTextureMailbox(&mailbox)) | 189 if (client_->PrepareTextureMailbox(&mailbox)) |
| 188 SetTextureMailbox(mailbox); | 190 SetTextureMailbox(mailbox); |
| 189 } else { | 191 } else { |
| 190 texture_id_ = client_->PrepareTexture(queue); | 192 texture_id_ = client_->PrepareTexture(queue); |
| 191 } | 193 } |
| 192 context_lost_ = | 194 context_lost_ = |
| 195 !client_->Context3d() || | |
| 193 client_->Context3d()->getGraphicsResetStatusARB() != GL_NO_ERROR; | 196 client_->Context3d()->getGraphicsResetStatusARB() != GL_NO_ERROR; |
| 194 } | 197 } |
| 195 | 198 |
| 196 needs_display_ = false; | 199 needs_display_ = false; |
| 197 } | 200 } |
| 198 | 201 |
| 199 void TextureLayer::PushPropertiesTo(LayerImpl* layer) { | 202 void TextureLayer::PushPropertiesTo(LayerImpl* layer) { |
| 200 Layer::PushPropertiesTo(layer); | 203 Layer::PushPropertiesTo(layer); |
| 201 | 204 |
| 202 TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer); | 205 TextureLayerImpl* texture_layer = static_cast<TextureLayerImpl*>(layer); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 225 // triple-buffered. Single-buffered layers already prevent draws, so | 228 // triple-buffered. Single-buffered layers already prevent draws, so |
| 226 // can block too for simplicity. | 229 // can block too for simplicity. |
| 227 return DrawsContent(); | 230 return DrawsContent(); |
| 228 } | 231 } |
| 229 | 232 |
| 230 bool TextureLayer::CanClipSelf() const { | 233 bool TextureLayer::CanClipSelf() const { |
| 231 return true; | 234 return true; |
| 232 } | 235 } |
| 233 | 236 |
| 234 } // namespace cc | 237 } // namespace cc |
| OLD | NEW |