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..6f8a0a39a11c5214d3ee4a7e3f706f8983d8336f |
| --- /dev/null |
| +++ b/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc |
| @@ -0,0 +1,66 @@ |
| +// 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 { |
| + |
| +static void SendACK(const std::string& mailbox_name, |
| + int host_route_id, |
| + int gpu_route_id, |
| + int gpu_host_id, |
| + unsigned sync_point) { |
| + RenderThread::Get()->Send( |
| + new BrowserPluginHostMsg_BuffersSwappedACK( |
| + host_route_id, |
| + gpu_route_id, |
| + gpu_host_id, |
| + mailbox_name, |
| + sync_point)); |
| +} |
| + |
| +BrowserPluginCompositingHelper::BrowserPluginCompositingHelper( |
| + WebKit::WebPluginContainer* container, |
| + int host_routing_id) |
| + : host_routing_id_(host_routing_id), |
| + last_mailbox_valid_(false), |
| + container_(container) { |
| +} |
| + |
| +BrowserPluginCompositingHelper::~BrowserPluginCompositingHelper() { |
| + container_->setWebLayer(NULL); |
| +} |
| + |
| +void BrowserPluginCompositingHelper::EnableCompositing(bool enable) { |
| + if (enable && !texture_layer_) { |
| + texture_layer_ = cc::TextureLayer::createForMailbox(); |
|
rjkroege
2013/01/10 17:03:21
nit: wrong # of spaces at start of line? Chrome in
alexst (slow to review)
2013/01/10 18:56:31
Sigh, too much jumping between cc and content. Don
|
| + web_layer_.reset(new WebKit::WebLayerImpl(texture_layer_)); |
| + } |
| + |
| + container_->setWebLayer(enable ? web_layer_.get() : NULL); |
| +} |
| + |
| +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 |