Index: content/renderer/browser_plugin/browser_plugin.cc |
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc |
index 5b2fce11d00b624bd19c5598988e72a718f44c1e..13eea625df43d9827005b236169c9ad0a8215b64 100644 |
--- a/content/renderer/browser_plugin/browser_plugin.cc |
+++ b/content/renderer/browser_plugin/browser_plugin.cc |
@@ -14,8 +14,10 @@ |
#include "content/common/view_messages.h" |
#include "content/public/common/content_client.h" |
#include "content/public/renderer/content_renderer_client.h" |
+#include "content/renderer/gpu/compositor_thread.h" |
#include "content/renderer/browser_plugin/browser_plugin_bindings.h" |
#include "content/renderer/browser_plugin/browser_plugin_manager.h" |
+#include "content/renderer/browser_plugin/browser_plugin_texture_provider.h" |
#include "content/renderer/render_process_impl.h" |
#include "content/renderer/render_thread_impl.h" |
#include "skia/ext/platform_canvas.h" |
@@ -96,7 +98,10 @@ BrowserPlugin::BrowserPlugin( |
focused_(false), |
visible_(true), |
current_nav_entry_index_(0), |
- nav_entry_count_(0) { |
+ nav_entry_count_(0), |
+ provider_(0), |
+ compositingPossible_(false), |
+ compositingEnabled_(false) { |
BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this); |
bindings_.reset(new BrowserPluginBindings(this)); |
@@ -114,6 +119,9 @@ BrowserPlugin::~BrowserPlugin() { |
new BrowserPluginHostMsg_PluginDestroyed( |
render_view_routing_id_, |
instance_id_)); |
+ |
+ if (provider_) |
+ provider_->Destroy(); |
} |
void BrowserPlugin::Cleanup() { |
@@ -147,6 +155,15 @@ void BrowserPlugin::SetSrcAttribute(const std::string& src) { |
GetPendingResizeParams()); |
DCHECK(!params->resize_pending); |
+ WebKit::WebView* web_view = render_view_->webview(); |
+ DCHECK(web_view); |
+ WebGraphicsContext3DCommandBufferImpl* context = NULL; |
+ if (compositingPossible_) { |
+ context = static_cast<WebGraphicsContext3DCommandBufferImpl*>( |
+ web_view->sharedGraphicsContext3D()); |
+ } |
+ ProvideHWCompositingInfo(params.get(), context); |
+ |
BrowserPluginManager::Get()->Send( |
new BrowserPluginHostMsg_NavigateGuest( |
render_view_routing_id_, |
@@ -255,6 +272,43 @@ void BrowserPlugin::InitializeEvents() { |
event_listener_map_[kLoadStopEventName] = EventListeners(); |
} |
+void BrowserPlugin::InitializeTextureProvider() { |
+ RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); |
+ CompositorThread* compositor_thread = render_thread_impl->compositor_thread(); |
+ compositingPossible_ = !!compositor_thread; |
+ |
+ if (compositingPossible_) { |
+ MessageLoop* compositor_thread_loop = compositor_thread->message_loop(); |
+ provider_ = new BrowserPluginTextureProvider( |
+ instance_id_, |
+ render_view_->GetRoutingID(), |
+ RenderThreadImpl::Get()->GetChannel(), |
+ compositor_thread_loop->message_loop_proxy()); |
+ provider_->Initialize(); |
+ } |
+} |
+ |
+void BrowserPlugin::ProvideHWCompositingInfo( |
+ BrowserPluginHostMsg_ResizeGuest_Params* params, |
+ WebGraphicsContext3DCommandBufferImpl* context) { |
+ if (context) { |
+ params->gpu_process_id = context->GetGPUProcessID(); |
+ params->client_id = context->GetChannelID(); |
+ params->context_id = context->GetContextID(); |
+ params->texture_id_0 = context->createTexture(); |
+ params->texture_id_1 = context->createTexture(); |
+ params->sync_point = context->insertSyncPoint(); |
+ } else { |
+ // Zero textures signal a lack of compositing |
+ params->gpu_process_id = 0; |
+ params->client_id = 0; |
+ params->context_id = 0; |
+ params->texture_id_0 = 0; |
+ params->texture_id_1 = 0; |
+ params->sync_point = 0; |
+ } |
+} |
+ |
void BrowserPlugin::RemoveEventListeners() { |
EventListenerMap::iterator event_listener_map_iter = |
event_listener_map_.begin(); |
@@ -401,6 +455,7 @@ void BrowserPlugin::UpdateRect( |
// NULL so we shouldn't attempt to access it. |
if (container_) |
container_->invalidate(); |
+ |
BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( |
render_view_routing_id_, |
instance_id_, |
@@ -621,6 +676,18 @@ bool BrowserPlugin::initialize(WebPluginContainer* container) { |
return true; |
} |
+void BrowserPlugin::EnableCompositing() { |
+ if (!compositingPossible_) { |
+ LOG(WARNING) << "BrowserPlugin compositing requires an impl thread, " |
+ << "try running with --enable-threaded-compositing"; |
+ return; |
+ } |
+ if (!compositingEnabled_) |
+ container_->setBackingTextureProvider(provider_); |
+ |
+ compositingEnabled_ = true; |
+} |
+ |
void BrowserPlugin::destroy() { |
// The BrowserPlugin's WebPluginContainer is deleted immediately after this |
// call returns, so let's not keep a reference to it around. |
@@ -685,6 +752,7 @@ void BrowserPlugin::updateGeometry( |
const WebRect& clip_rect, |
const WebVector<WebRect>& cut_outs_rects, |
bool is_visible) { |
+ |
int old_width = width(); |
int old_height = height(); |
plugin_rect_ = window_rect; |
@@ -771,6 +839,8 @@ BrowserPluginHostMsg_ResizeGuest_Params* |
params->width = width(); |
params->height = height(); |
params->resize_pending = false; |
+ // Reset HW compositing info. |
+ ProvideHWCompositingInfo(params, NULL); |
return params; |
} |
} |