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

Side by Side 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: Comments 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 unified diff | Download patch
OLDNEW
(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,
piman 2013/01/09 23:24:47 nit: SendACK
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();
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698