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/texture_layer.h" | 5 #include "cc/texture_layer.h" |
| 6 | 6 |
| 7 #include "cc/layer_tree_host.h" | 7 #include "cc/layer_tree_host.h" |
| 8 #include "cc/texture_layer_client.h" | 8 #include "cc/texture_layer_client.h" |
| 9 #include "cc/texture_layer_impl.h" | 9 #include "cc/texture_layer_impl.h" |
| 10 #include "cc/thread.h" | 10 #include "cc/thread.h" |
| 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" | 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 | 14 |
| 15 static void RunCallbackOnMainThread( | 15 static void RunCallbackOnMainThread( |
| 16 const TextureMailbox::ReleaseCallback& callback, | 16 const TextureMailbox::ReleaseCallback& callback, |
| 17 unsigned sync_point) { | 17 unsigned sync_point) { |
| 18 callback.Run(sync_point); | 18 callback.Run(sync_point); |
| 19 } | 19 } |
| 20 | 20 |
| 21 static void PostCallbackToMainThread( | 21 static void PostCallbackToMainThread( |
| 22 Thread* main_thread, | 22 Thread* main_thread, |
| 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 bool usesMailbox) { |
|
piman
2013/03/14 19:54:58
nit: uses_mailbox
alexst (slow to review)
2013/03/14 20:37:06
Done.
| |
| 31 } | 31 return scoped_refptr<TextureLayer>(new TextureLayer(client, usesMailbox)); |
| 32 | |
| 33 scoped_refptr<TextureLayer> TextureLayer::CreateForMailbox() { | |
| 34 return scoped_refptr<TextureLayer>(new TextureLayer(NULL, true)); | |
| 35 } | 32 } |
| 36 | 33 |
| 37 TextureLayer::TextureLayer(TextureLayerClient* client, bool uses_mailbox) | 34 TextureLayer::TextureLayer(TextureLayerClient* client, bool uses_mailbox) |
| 38 : Layer(), | 35 : Layer(), |
| 39 client_(client), | 36 client_(client), |
| 40 uses_mailbox_(uses_mailbox), | 37 uses_mailbox_(uses_mailbox), |
| 41 flipped_(true), | 38 flipped_(true), |
| 42 uv_top_left_(0.f, 0.f), | 39 uv_top_left_(0.f, 0.f), |
| 43 uv_bottom_right_(1.f, 1.f), | 40 uv_bottom_right_(1.f, 1.f), |
| 44 premultiplied_alpha_(true), | 41 premultiplied_alpha_(true), |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 | 148 |
| 152 bool TextureLayer::DrawsContent() const { | 149 bool TextureLayer::DrawsContent() const { |
| 153 return (client_ || texture_id_ || !texture_mailbox_.IsEmpty()) && | 150 return (client_ || texture_id_ || !texture_mailbox_.IsEmpty()) && |
| 154 !context_lost_ && Layer::DrawsContent(); | 151 !context_lost_ && Layer::DrawsContent(); |
| 155 } | 152 } |
| 156 | 153 |
| 157 void TextureLayer::Update(ResourceUpdateQueue* queue, | 154 void TextureLayer::Update(ResourceUpdateQueue* queue, |
| 158 const OcclusionTracker* occlusion, | 155 const OcclusionTracker* occlusion, |
| 159 RenderingStats* stats) { | 156 RenderingStats* stats) { |
| 160 if (client_) { | 157 if (client_) { |
| 161 texture_id_ = client_->prepareTexture(*queue); | 158 if (uses_mailbox_) { |
| 159 TextureMailbox mailbox; | |
| 160 if (client_->prepareTextureMailbox(&mailbox)) | |
| 161 SetTextureMailbox(mailbox); | |
|
piman
2013/03/14 19:54:58
How hard would it be to change the BrowserPluginCo
alexst (slow to review)
2013/03/14 20:37:06
Shouldn't be too bad, I'll look into it.
As far a
| |
| 162 } else { | |
| 163 texture_id_ = client_->prepareTexture(*queue); | |
| 164 } | |
| 162 context_lost_ = | 165 context_lost_ = |
| 163 client_->context()->getGraphicsResetStatusARB() != GL_NO_ERROR; | 166 client_->context()->getGraphicsResetStatusARB() != GL_NO_ERROR; |
| 164 } | 167 } |
| 165 | 168 |
| 166 needs_display_ = false; | 169 needs_display_ = false; |
| 167 } | 170 } |
| 168 | 171 |
| 169 void TextureLayer::PushPropertiesTo(LayerImpl* layer) { | 172 void TextureLayer::PushPropertiesTo(LayerImpl* layer) { |
| 170 Layer::PushPropertiesTo(layer); | 173 Layer::PushPropertiesTo(layer); |
| 171 | 174 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 195 // triple-buffered. Single-buffered layers already prevent draws, so | 198 // triple-buffered. Single-buffered layers already prevent draws, so |
| 196 // can block too for simplicity. | 199 // can block too for simplicity. |
| 197 return DrawsContent(); | 200 return DrawsContent(); |
| 198 } | 201 } |
| 199 | 202 |
| 200 bool TextureLayer::CanClipSelf() const { | 203 bool TextureLayer::CanClipSelf() const { |
| 201 return true; | 204 return true; |
| 202 } | 205 } |
| 203 | 206 |
| 204 } // namespace cc | 207 } // namespace cc |
| OLD | NEW |