| 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 12 matching lines...) Expand all Loading... |
| 23 const TextureMailbox::ReleaseCallback& callback, | 23 const TextureMailbox::ReleaseCallback& callback, |
| 24 unsigned sync_point) { | 24 unsigned sync_point) { |
| 25 main_thread->PostTask( | 25 main_thread->PostTask( |
| 26 base::Bind(&RunCallbackOnMainThread, callback, sync_point)); | 26 base::Bind(&RunCallbackOnMainThread, callback, sync_point)); |
| 27 } | 27 } |
| 28 | 28 |
| 29 scoped_refptr<TextureLayer> TextureLayer::Create(TextureLayerClient* client) { | 29 scoped_refptr<TextureLayer> TextureLayer::Create(TextureLayerClient* client) { |
| 30 return scoped_refptr<TextureLayer>(new TextureLayer(client, false)); | 30 return scoped_refptr<TextureLayer>(new TextureLayer(client, false)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 scoped_refptr<TextureLayer> TextureLayer::CreateForMailbox() { | 33 scoped_refptr<TextureLayer> TextureLayer::CreateForMailbox( |
| 34 return scoped_refptr<TextureLayer>(new TextureLayer(NULL, true)); | 34 TextureLayerClient* client) { |
| 35 return scoped_refptr<TextureLayer>(new TextureLayer(client, true)); |
| 35 } | 36 } |
| 36 | 37 |
| 37 TextureLayer::TextureLayer(TextureLayerClient* client, bool uses_mailbox) | 38 TextureLayer::TextureLayer(TextureLayerClient* client, bool uses_mailbox) |
| 38 : Layer(), | 39 : Layer(), |
| 39 client_(client), | 40 client_(client), |
| 40 uses_mailbox_(uses_mailbox), | 41 uses_mailbox_(uses_mailbox), |
| 41 flipped_(true), | 42 flipped_(true), |
| 42 uv_top_left_(0.f, 0.f), | 43 uv_top_left_(0.f, 0.f), |
| 43 uv_bottom_right_(1.f, 1.f), | 44 uv_bottom_right_(1.f, 1.f), |
| 44 premultiplied_alpha_(true), | 45 premultiplied_alpha_(true), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 59 layer_tree_host()->AcquireLayerTextures(); | 60 layer_tree_host()->AcquireLayerTextures(); |
| 60 if (rate_limit_context_ && client_) | 61 if (rate_limit_context_ && client_) |
| 61 layer_tree_host()->StopRateLimiter(client_->Context3d()); | 62 layer_tree_host()->StopRateLimiter(client_->Context3d()); |
| 62 } | 63 } |
| 63 if (own_mailbox_) | 64 if (own_mailbox_) |
| 64 texture_mailbox_.RunReleaseCallback(texture_mailbox_.sync_point()); | 65 texture_mailbox_.RunReleaseCallback(texture_mailbox_.sync_point()); |
| 65 } | 66 } |
| 66 | 67 |
| 67 void TextureLayer::ClearClient() { | 68 void TextureLayer::ClearClient() { |
| 68 client_ = NULL; | 69 client_ = NULL; |
| 69 SetTextureId(0); | 70 if (uses_mailbox_) |
| 71 SetTextureMailbox(TextureMailbox()); |
| 72 else |
| 73 SetTextureId(0); |
| 70 } | 74 } |
| 71 | 75 |
| 72 scoped_ptr<LayerImpl> TextureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 76 scoped_ptr<LayerImpl> TextureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
| 73 return TextureLayerImpl::Create(tree_impl, id(), uses_mailbox_). | 77 return TextureLayerImpl::Create(tree_impl, id(), uses_mailbox_). |
| 74 PassAs<LayerImpl>(); | 78 PassAs<LayerImpl>(); |
| 75 } | 79 } |
| 76 | 80 |
| 77 void TextureLayer::SetFlipped(bool flipped) { | 81 void TextureLayer::SetFlipped(bool flipped) { |
| 78 flipped_ = flipped; | 82 flipped_ = flipped; |
| 79 SetNeedsCommit(); | 83 SetNeedsCommit(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 160 |
| 157 bool TextureLayer::DrawsContent() const { | 161 bool TextureLayer::DrawsContent() const { |
| 158 return (client_ || texture_id_ || !texture_mailbox_.IsEmpty()) && | 162 return (client_ || texture_id_ || !texture_mailbox_.IsEmpty()) && |
| 159 !context_lost_ && Layer::DrawsContent(); | 163 !context_lost_ && Layer::DrawsContent(); |
| 160 } | 164 } |
| 161 | 165 |
| 162 void TextureLayer::Update(ResourceUpdateQueue* queue, | 166 void TextureLayer::Update(ResourceUpdateQueue* queue, |
| 163 const OcclusionTracker* occlusion, | 167 const OcclusionTracker* occlusion, |
| 164 RenderingStats* stats) { | 168 RenderingStats* stats) { |
| 165 if (client_) { | 169 if (client_) { |
| 166 texture_id_ = client_->PrepareTexture(queue); | 170 if (uses_mailbox_) { |
| 171 TextureMailbox mailbox; |
| 172 if (client_->PrepareTextureMailbox(&mailbox)) |
| 173 SetTextureMailbox(mailbox); |
| 174 } else { |
| 175 texture_id_ = client_->PrepareTexture(queue); |
| 176 } |
| 167 context_lost_ = | 177 context_lost_ = |
| 168 client_->Context3d()->getGraphicsResetStatusARB() != GL_NO_ERROR; | 178 client_->Context3d()->getGraphicsResetStatusARB() != GL_NO_ERROR; |
| 169 } | 179 } |
| 170 | 180 |
| 171 needs_display_ = false; | 181 needs_display_ = false; |
| 172 } | 182 } |
| 173 | 183 |
| 174 void TextureLayer::PushPropertiesTo(LayerImpl* layer) { | 184 void TextureLayer::PushPropertiesTo(LayerImpl* layer) { |
| 175 Layer::PushPropertiesTo(layer); | 185 Layer::PushPropertiesTo(layer); |
| 176 | 186 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 200 // triple-buffered. Single-buffered layers already prevent draws, so | 210 // triple-buffered. Single-buffered layers already prevent draws, so |
| 201 // can block too for simplicity. | 211 // can block too for simplicity. |
| 202 return DrawsContent(); | 212 return DrawsContent(); |
| 203 } | 213 } |
| 204 | 214 |
| 205 bool TextureLayer::CanClipSelf() const { | 215 bool TextureLayer::CanClipSelf() const { |
| 206 return true; | 216 return true; |
| 207 } | 217 } |
| 208 | 218 |
| 209 } // namespace cc | 219 } // namespace cc |
| OLD | NEW |