Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: content/renderer/browser_plugin/browser_plugin_compositing_helper.cc

Issue 11824040: Enables compositing support for webview. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed build error on mac and win, nits Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ce0be5e12c50da0e3818525579c196d0ee280c69
--- /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();
+ 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

Powered by Google App Engine
This is Rietveld 408576698