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 static void SendACK(const std::string& mailbox_name, | |
16 int host_route_id, | |
17 int gpu_route_id, | |
18 int gpu_host_id, | |
19 unsigned sync_point) { | |
20 RenderThread::Get()->Send( | |
21 new BrowserPluginHostMsg_BuffersSwappedACK( | |
22 host_route_id, | |
23 gpu_route_id, | |
24 gpu_host_id, | |
25 mailbox_name, | |
26 sync_point)); | |
27 } | |
28 | |
29 BrowserPluginCompositingHelper::BrowserPluginCompositingHelper( | |
30 WebKit::WebPluginContainer* container, | |
31 int host_routing_id) | |
32 : host_routing_id_(host_routing_id), | |
33 last_mailbox_valid_(false), | |
34 container_(container) { | |
35 } | |
36 | |
37 BrowserPluginCompositingHelper::~BrowserPluginCompositingHelper() { | |
38 container_->setWebLayer(NULL); | |
39 } | |
40 | |
41 void BrowserPluginCompositingHelper::EnableCompositing(bool enable) { | |
42 if (enable && !texture_layer_) { | |
43 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
| |
44 web_layer_.reset(new WebKit::WebLayerImpl(texture_layer_)); | |
45 } | |
46 | |
47 container_->setWebLayer(enable ? web_layer_.get() : NULL); | |
48 } | |
49 | |
50 void BrowserPluginCompositingHelper::OnBuffersSwapped(const gfx::Size& size, | |
51 const std::string& mailbox_name, | |
52 int gpu_route_id, | |
53 int gpu_host_id) { | |
54 if (!last_mailbox_valid_) | |
55 SendACK(std::string(), host_routing_id_, gpu_route_id, gpu_host_id, 0); | |
56 | |
57 last_mailbox_valid_ = !mailbox_name.empty(); | |
58 texture_layer_->setTextureMailbox(mailbox_name, | |
59 base::Bind(&SendACK, | |
60 mailbox_name, | |
61 host_routing_id_, | |
62 gpu_route_id, | |
63 gpu_host_id)); | |
64 } | |
65 | |
66 } // namespace content | |
OLD | NEW |