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