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

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: Created 8 years, 5 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 2c00eb2debb0c5c7a9d2450758e837bfc591a576..6bfe614513fed83029fdb0a01cd0c5d05485a55d 100644
--- a/content/renderer/browser_plugin/browser_plugin.cc
+++ b/content/renderer/browser_plugin/browser_plugin.cc
@@ -76,11 +76,25 @@ void BrowserPlugin::SetSrcAttribute(const std::string& src) {
if (src == src_ && !guest_crashed_)
return;
if (!src.empty()) {
- render_view_->Send(new BrowserPluginHostMsg_NavigateFromEmbedder(
- render_view_->GetRoutingID(),
- id_,
- parent_frame_,
- src));
+ WebKit::WebView* web_view = render_view_->webview();
+ 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();
+ printf("Giving guest textures %u and %u\n", params.texture_id[0], params.texture_id[1]);
+ if (web_view) {
+ render_view_->Send(new BrowserPluginHostMsg_NavigateFromEmbedder(
+ render_view_->GetRoutingID(),
+ id_,
+ parent_frame_,
+ src,
+ params));
+ }
}
src_ = src;
guest_crashed_ = false;
@@ -150,12 +164,39 @@ void BrowserPlugin::AdvanceFocus(bool reverse) {
render_view_->GetWebView()->advanceFocus(reverse);
}
+void BrowserPlugin::BuffersSwapped(uint64 surface_handle, const BrowserPlugin_SwapInfo& info) {
+ DCHECK(surface_handle != 0);
+ fprintf(stderr, "Browser plugin swapping buffers on surface %lu\n", surface_handle);
+ container_->setBackingTextureId(surface_handle);
+ container_->commitBackingTexture();
+ compositing_callbacks_.push_back(base::Bind(&BrowserPlugin::PerformBuffersSwappedACK, base::Unretained(this), info));
Fady Samuel 2012/07/06 15:14:44 So are you sure you're delaying ACK'ing enough her
scshunt 2012/07/06 16:39:03 I was not, and that was the cause of the flicker.
+}
+
void BrowserPlugin::PostMessage(const std::string& message,
const std::string& target_origin) {
fprintf(stderr, ">>>%s message: \"%s\"\n", __PRETTY_FUNCTION__,
message.c_str());
}
+void BrowserPlugin::WillInitiatePaint() {
+ for (std::vector< base::Callback<void(void)> >::const_iterator
+ it = compositing_callbacks_.begin();
Fady Samuel 2012/07/06 15:14:44 Do we ever really expect to get multiple compositi
scshunt 2012/07/06 16:39:03 Not sure. It occurs to me that it would probably b
+ it != compositing_callbacks_.end(); ++it) {
+ it->Run();
+ }
+ compositing_callbacks_.clear();
+}
+
+void BrowserPlugin::PerformBuffersSwappedACK(const BrowserPlugin_SwapInfo& info) {
+ WebKit::WebView* webview = render_view_->webview();
+ DCHECK(webview);
+ WebGraphicsContext3DCommandBufferImpl* buffer = static_cast<WebGraphicsContext3DCommandBufferImpl*>(webview->sharedGraphicsContext3D());
+ DCHECK(buffer);
+ uint32 sync_point = buffer->insertSyncPoint();
+ render_view_->Send(new BrowserPluginHostMsg_BuffersSwappedACK(render_view_->GetRoutingID(), info, sync_point));
+ fprintf(stderr, "Sent browser plugin buffers swapped ACK\n");
+}
+
WebKit::WebPluginContainer* BrowserPlugin::container() const {
return container_;
}

Powered by Google App Engine
This is Rietveld 408576698