Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/renderer/browser_plugin/browser_plugin_compositing_helper.h" | |
| 6 | |
| 7 #include "cc/texture_layer.h" | |
| 8 #include "content/common/browser_plugin_messages.h" | |
| 9 #include "content/renderer/render_thread_impl.h" | |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | |
| 11 #include "webkit/compositor_bindings/web_layer_impl.h" | |
| 12 | |
| 13 namespace content { | |
| 14 | |
| 15 BrowserPluginCompositingHelper::BrowserPluginCompositingHelper( | |
| 16 WebKit::WebPluginContainer* container, | |
| 17 int host_routing_id) | |
| 18 : host_routing_id_(host_routing_id), | |
| 19 last_mailbox_valid_(false), | |
| 20 container_(container) { | |
| 21 } | |
| 22 | |
| 23 void BrowserPluginCompositingHelper::EnableCompositing(bool enable) { | |
| 24 if (enable && !texture_layer_) { | |
| 25 texture_layer_ = cc::TextureLayer::createForMailbox(); | |
| 26 web_layer_.reset(new WebKit::WebLayerImpl(texture_layer_)); | |
| 27 } | |
| 28 | |
| 29 container_->setWebLayer(enable ? web_layer_.get() : NULL); | |
| 30 } | |
| 31 | |
| 32 BrowserPluginCompositingHelper::~BrowserPluginCompositingHelper() { | |
| 33 if (texture_layer_) { | |
| 34 texture_layer_->setTextureMailbox(std::string(), | |
| 35 cc::TextureLayer::MailboxCallback()); | |
|
piman
2013/01/09 22:38:57
Is this necessary given that you are about to dele
alexst (slow to review)
2013/01/09 23:16:05
You are probably right. I was thinking that if the
| |
| 36 } | |
|
piman
2013/01/09 22:38:57
you want to reset the container_'s weblayer here,
alexst (slow to review)
2013/01/09 23:16:05
Done.
alexst (slow to review)
2013/01/09 23:16:05
Done.
| |
| 37 } | |
| 38 | |
| 39 static void sendAck(const std::string& mailbox_name, | |
|
Fady Samuel
2013/01/09 21:23:38
SendACK
| |
| 40 int host_route_id, | |
| 41 int gpu_route_id, | |
| 42 int gpu_host_id, | |
| 43 unsigned syncPoint) { | |
|
Fady Samuel
2013/01/09 21:23:38
sync_point
| |
| 44 RenderThread::Get()->Send( | |
| 45 new BrowserPluginHostMsg_BuffersSwappedACK( | |
| 46 host_route_id, | |
| 47 gpu_route_id, | |
| 48 gpu_host_id, | |
| 49 mailbox_name, | |
| 50 syncPoint)); | |
|
Fady Samuel
2013/01/09 21:23:38
sync_point
| |
| 51 } | |
| 52 | |
| 53 void BrowserPluginCompositingHelper::OnBuffersSwapped(const gfx::Size& size, | |
| 54 const std::string& mailbox_name, | |
| 55 int gpu_route_id, | |
| 56 int gpu_host_id) { | |
| 57 if (!last_mailbox_valid_) | |
| 58 sendAck(std::string(), host_routing_id_, gpu_route_id, gpu_host_id, 0); | |
| 59 | |
| 60 last_mailbox_valid_ = !mailbox_name.empty(); | |
| 61 texture_layer_->setTextureMailbox(mailbox_name, | |
| 62 base::Bind(&sendAck, | |
| 63 mailbox_name, | |
| 64 host_routing_id_, | |
| 65 gpu_route_id, | |
| 66 gpu_host_id)); | |
| 67 } | |
| 68 | |
| 69 } // namespace content | |
| OLD | NEW |