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.
5 #include "content/renderer/browser_plugin/browser_plugin_compositing_helper.h"
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"
15 static void SendACK(const std::string
& mailbox_name
,
19 unsigned sync_point
) {
20 RenderThread::Get()->Send(
21 new BrowserPluginHostMsg_BuffersSwappedACK(
29 BrowserPluginCompositingHelper::BrowserPluginCompositingHelper(
30 WebKit::WebPluginContainer
* container
,
32 : host_routing_id_(host_routing_id
),
33 last_mailbox_valid_(false),
34 container_(container
) {
37 BrowserPluginCompositingHelper::~BrowserPluginCompositingHelper() {
38 container_
->setWebLayer(NULL
);
41 void BrowserPluginCompositingHelper::EnableCompositing(bool enable
) {
42 if (enable
&& !texture_layer_
) {
43 texture_layer_
= cc::TextureLayer::createForMailbox();
44 web_layer_
.reset(new WebKit::WebLayerImpl(texture_layer_
));
47 container_
->setWebLayer(enable
? web_layer_
.get() : NULL
);
50 void BrowserPluginCompositingHelper::OnBuffersSwapped(const gfx::Size
& size
,
51 const std::string
& mailbox_name
,
54 if (!last_mailbox_valid_
)
55 SendACK(std::string(), host_routing_id_
, gpu_route_id
, gpu_host_id
, 0);
57 last_mailbox_valid_
= !mailbox_name
.empty();
58 texture_layer_
->setTextureMailbox(mailbox_name
,
66 } // namespace content