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

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

Issue 10735010: 3D Compositing in <browser>, first draft. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Use the correct baseline Created 8 years, 4 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.cc
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc
index 700f34d1681fb11cb98631a111024507a9606965..749b34458643cca60ae1db052ba54d4553f1f998 100644
--- a/content/renderer/browser_plugin/browser_plugin.cc
+++ b/content/renderer/browser_plugin/browser_plugin.cc
@@ -11,9 +11,11 @@
#include "content/public/renderer/content_renderer_client.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"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebFloatRect.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
@@ -54,7 +56,9 @@ BrowserPlugin::BrowserPlugin(
sad_guest_(NULL),
guest_crashed_(false),
resize_pending_(false),
- parent_frame_(frame->identifier()) {
+ parent_frame_(frame->identifier()),
+ provider_(0),
+ ignore_input_(false) {
BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this);
bindings_.reset(new BrowserPluginBindings(this));
@@ -74,6 +78,9 @@ BrowserPlugin::~BrowserPlugin() {
new BrowserPluginHostMsg_PluginDestroyed(
render_view_->GetRoutingID(),
instance_id_));
+
+ if (provider_)
+ provider_->Destroy();
}
void BrowserPlugin::Cleanup() {
@@ -91,13 +98,31 @@ void BrowserPlugin::SetSrcAttribute(const std::string& src) {
if (src == src_ && !guest_crashed_)
return;
if (!src.empty()) {
+ WebKit::WebView* web_view = render_view_->webview();
+ DCHECK(web_view);
+ WebGraphicsContext3DCommandBufferImpl* context =
+ static_cast<WebGraphicsContext3DCommandBufferImpl*>(
+ web_view->sharedGraphicsContext3D());
+ BrowserPluginHostMsg_Surface_Params params;
+ 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.texture_id[0] = params.texture_id[1] = 0;
+ }
BrowserPluginManager::Get()->Send(
new BrowserPluginHostMsg_NavigateGuest(
render_view_->GetRoutingID(),
instance_id_,
parent_frame_,
src,
- gfx::Size(width(), height())));
+ gfx::Size(width(), height()),
+ params));
}
src_ = src;
guest_crashed_ = false;
@@ -123,6 +148,15 @@ float BrowserPlugin::GetDeviceScaleFactor() const {
return render_view_->GetWebView()->deviceScaleFactor();
}
+BrowserPluginTextureProvider* BrowserPlugin::CreateTextureProvider(
+ int instance_id,
+ int routing_id) const {
+ return new BrowserPluginTextureProvider(
+ instance_id_,
+ render_view_->GetRoutingID(),
+ RenderThreadImpl::Get()->GetChannel());
+}
+
void BrowserPlugin::RemoveEventListeners() {
EventListenerMap::iterator event_listener_map_iter =
event_listener_map_.begin();
@@ -143,11 +177,12 @@ void BrowserPlugin::UpdateRect(
const BrowserPluginMsg_UpdateRect_Params& params) {
if (width() != params.view_size.width() ||
height() != params.view_size.height()) {
- BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UpdateRect_ACK(
- render_view_->GetRoutingID(),
- instance_id_,
- message_id,
- gfx::Size(width(), height())));
+ if (params.needs_ack)
+ BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UpdateRect_ACK(
+ render_view_->GetRoutingID(),
+ instance_id_,
+ message_id,
+ gfx::Size(width(), height())));
return;
}
@@ -176,11 +211,12 @@ void BrowserPlugin::UpdateRect(
}
// Invalidate the container.
container_->invalidate();
- BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UpdateRect_ACK(
- render_view_->GetRoutingID(),
- instance_id_,
- message_id,
- gfx::Size()));
+ if (params.needs_ack)
+ BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UpdateRect_ACK(
+ render_view_->GetRoutingID(),
+ instance_id_,
+ message_id,
+ gfx::Size()));
}
void BrowserPlugin::GuestCrashed() {
@@ -233,6 +269,36 @@ bool BrowserPlugin::HasListeners(const std::string& event_name) {
return event_listener_map_.find(event_name) != event_listener_map_.end();
}
+void BrowserPlugin::SurfaceResize(const gfx::Size& size) {
+ if (!provider_) {
+ provider_ = CreateTextureProvider(instance_id_,
+ render_view_->GetRoutingID());
+ provider_->Resize(gfx::Size(width(), height()));
+ }
+
+ provider_->SurfaceResize(size);
+}
+
+void BrowserPlugin::BuffersSwapped(
+ uint64 surface_handle,
+ const BrowserPlugin_SwapInfo& info) {
+ DCHECK(!ignore_input_);
+ DCHECK(surface_handle);
+ DCHECK(container_);
+ DCHECK(provider_);
+
+ provider_->SetDelayedSwap(surface_handle, info);
+
+ container_->setBackingTextureProvider(provider_);
+ container_->commitBackingTexture();
+
+ ignore_input_ = true;
+}
+
+void BrowserPlugin::TextureProviderIsReady() {
+ ignore_input_ = false;
+}
+
bool BrowserPlugin::AddEventListener(const std::string& event_name,
v8::Local<v8::Function> function) {
EventListeners& listeners = event_listener_map_[event_name];
@@ -359,6 +425,9 @@ void BrowserPlugin::updateGeometry(
damage_buffer_ = NULL;
}
damage_buffer_ = new_damage_buffer;
+
+ if (provider_)
+ provider_->Resize(gfx::Size(window_rect.width, window_rect.height));
}
void BrowserPlugin::updateFocus(bool focused) {
@@ -377,8 +446,15 @@ bool BrowserPlugin::acceptsInputEvents() {
bool BrowserPlugin::handleInputEvent(const WebKit::WebInputEvent& event,
WebKit::WebCursorInfo& cursor_info) {
- if (guest_crashed_ || src_.empty())
+ // In certain circumstances we won't pass input on to the guest. If we are
+ // deliberately ignoring input to a working guest, we should sink the input
+ // event so that we won't have a random stray input event handled by the
+ // surrounding page.
+ if (guest_crashed_ || src_.empty() || !container_)
return false;
+ if (ignore_input_)
+ return true;
+
bool handled = false;
WebCursor cursor;
IPC::Message* message =
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.h ('k') | content/renderer/browser_plugin/browser_plugin_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698