Chromium Code Reviews| Index: content/renderer/browser_plugin/browser_plugin_compositing_helper.cc |
| diff --git a/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc b/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5a23f935d67d40f37a31db69aa6c880ccd0cd9fa |
| --- /dev/null |
| +++ b/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc |
| @@ -0,0 +1,69 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/renderer/browser_plugin/browser_plugin_compositing_helper.h" |
| + |
| +#include "cc/texture_layer.h" |
| +#include "content/common/browser_plugin_messages.h" |
| +#include "content/renderer/render_thread_impl.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
| +#include "webkit/compositor_bindings/web_layer_impl.h" |
| + |
| +namespace content { |
| + |
| +BrowserPluginCompositingHelper::BrowserPluginCompositingHelper( |
| + WebKit::WebPluginContainer* container, |
| + int host_routing_id) |
| + : host_routing_id_(host_routing_id), |
| + last_mailbox_valid_(false), |
| + container_(container) { |
| +} |
| + |
| +void BrowserPluginCompositingHelper::EnableCompositing(bool enable) { |
| + if (enable && !texture_layer_) { |
| + texture_layer_ = cc::TextureLayer::createForMailbox(); |
| + web_layer_.reset(new WebKit::WebLayerImpl(texture_layer_)); |
| + } |
| + |
| + container_->setWebLayer(enable ? web_layer_.get() : NULL); |
| +} |
| + |
| +BrowserPluginCompositingHelper::~BrowserPluginCompositingHelper() { |
| + if (texture_layer_) { |
| + texture_layer_->setTextureMailbox(std::string(), |
| + 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
|
| + } |
|
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.
|
| +} |
| + |
| +static void sendAck(const std::string& mailbox_name, |
|
Fady Samuel
2013/01/09 21:23:38
SendACK
|
| + int host_route_id, |
| + int gpu_route_id, |
| + int gpu_host_id, |
| + unsigned syncPoint) { |
|
Fady Samuel
2013/01/09 21:23:38
sync_point
|
| + RenderThread::Get()->Send( |
| + new BrowserPluginHostMsg_BuffersSwappedACK( |
| + host_route_id, |
| + gpu_route_id, |
| + gpu_host_id, |
| + mailbox_name, |
| + syncPoint)); |
|
Fady Samuel
2013/01/09 21:23:38
sync_point
|
| +} |
| + |
| +void BrowserPluginCompositingHelper::OnBuffersSwapped(const gfx::Size& size, |
| + const std::string& mailbox_name, |
| + int gpu_route_id, |
| + int gpu_host_id) { |
| + if (!last_mailbox_valid_) |
| + sendAck(std::string(), host_routing_id_, gpu_route_id, gpu_host_id, 0); |
| + |
| + last_mailbox_valid_ = !mailbox_name.empty(); |
| + texture_layer_->setTextureMailbox(mailbox_name, |
| + base::Bind(&sendAck, |
| + mailbox_name, |
| + host_routing_id_, |
| + gpu_route_id, |
| + gpu_host_id)); |
| +} |
| + |
| +} // namespace content |