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

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: Major changes to clean up deadlock & other issues 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 8ba5421f33aa700fe63e733024d9a5185ed74684..4ad5af744c364eebd6f6f9ba33c183b94c769cc4 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,12 +98,26 @@ 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());
+ DCHECK(context);
+ BrowserPluginHostMsg_Surface_Params params;
+ 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();
BrowserPluginManager::Get()->Send(
new BrowserPluginHostMsg_NavigateOrCreateGuest(
render_view_->GetRoutingID(),
instance_id_,
parent_frame_,
- src));
+ src,
+ params));
}
src_ = src;
guest_crashed_ = false;
@@ -140,8 +161,8 @@ void BrowserPlugin::RemoveEventListeners() {
void BrowserPlugin::UpdateRect(
int message_id,
const BrowserPluginMsg_UpdateRect_Params& params) {
- if (width() != params.view_size.width() ||
- height() != params.view_size.height()) {
+ if ((width() != params.view_size.width() ||
+ height() != params.view_size.height()) && params.needs_ack) {
BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UpdateRect_ACK(
render_view_->GetRoutingID(),
instance_id_,
@@ -175,11 +196,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() {
@@ -232,6 +254,35 @@ 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_ = new BrowserPluginTextureProvider(instance_id_, render_view_);
+ 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;
scshunt 2012/08/12 01:42:45 ignore_input should probably be commented, explain
+}
+
+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 +410,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,7 +431,7 @@ bool BrowserPlugin::acceptsInputEvents() {
bool BrowserPlugin::handleInputEvent(const WebKit::WebInputEvent& event,
WebKit::WebCursorInfo& cursor_info) {
- if (guest_crashed_ || src_.empty())
+ if (guest_crashed_ || src_.empty() || !container_ || ignore_input_)
return false;
bool handled = false;
WebCursor cursor;

Powered by Google App Engine
This is Rietveld 408576698