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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/browser_plugin/browser_plugin.h" 5 #include "content/renderer/browser_plugin/browser_plugin.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "content/common/browser_plugin_messages.h" 9 #include "content/common/browser_plugin_messages.h"
10 #include "content/browser/renderer_host/backing_store.h" 10 #include "content/browser/renderer_host/backing_store.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 RenderThreadImpl::current()->browser_plugin_manager()-> 69 RenderThreadImpl::current()->browser_plugin_manager()->
70 RemoveBrowserPlugin(id_); 70 RemoveBrowserPlugin(id_);
71 } 71 }
72 72
73 void BrowserPlugin::SetSrcAttribute(const std::string& src) { 73 void BrowserPlugin::SetSrcAttribute(const std::string& src) {
74 // TODO(fsamuel): What if the BrowserPlugin element's parent frame 74 // TODO(fsamuel): What if the BrowserPlugin element's parent frame
75 // changes? 75 // changes?
76 if (src == src_ && !guest_crashed_) 76 if (src == src_ && !guest_crashed_)
77 return; 77 return;
78 if (!src.empty()) { 78 if (!src.empty()) {
79 render_view_->Send(new BrowserPluginHostMsg_NavigateFromEmbedder( 79 WebKit::WebView* web_view = render_view_->webview();
80 render_view_->GetRoutingID(), 80 WebGraphicsContext3DCommandBufferImpl* context = static_cast<WebGraphicsCont ext3DCommandBufferImpl*>(web_view->sharedGraphicsContext3D());
81 id_, 81 DCHECK(context);
82 parent_frame_, 82 BrowserPluginHostMsg_Surface_Params params;
83 src)); 83 params.gpu_process_id = context->GetGPUProcessID();
84 params.client_id = context->GetChannelID();
85 params.context_id = context->GetContextID();
86 params.texture_id[0] = context->createTexture();
87 params.texture_id[1] = context->createTexture();
88 params.sync_point = context->insertSyncPoint();
89 printf("Giving guest textures %u and %u\n", params.texture_id[0], params.tex ture_id[1]);
90 if (web_view) {
91 render_view_->Send(new BrowserPluginHostMsg_NavigateFromEmbedder(
92 render_view_->GetRoutingID(),
93 id_,
94 parent_frame_,
95 src,
96 params));
97 }
84 } 98 }
85 src_ = src; 99 src_ = src;
86 guest_crashed_ = false; 100 guest_crashed_ = false;
87 } 101 }
88 102
89 int BrowserPlugin::GetBackingStoreWidth() const { 103 int BrowserPlugin::GetBackingStoreWidth() const {
90 return backing_store_.get() ? backing_store_->GetSize().width() : 0; 104 return backing_store_.get() ? backing_store_->GetSize().width() : 0;
91 } 105 }
92 106
93 int BrowserPlugin::GetBackingStoreHeight() const { 107 int BrowserPlugin::GetBackingStoreHeight() const {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 157
144 void BrowserPlugin::UpdateURL(const GURL& url) { 158 void BrowserPlugin::UpdateURL(const GURL& url) {
145 src_ = url.spec(); 159 src_ = url.spec();
146 // TODO(fsamuel): Send a custom message? 160 // TODO(fsamuel): Send a custom message?
147 } 161 }
148 162
149 void BrowserPlugin::AdvanceFocus(bool reverse) { 163 void BrowserPlugin::AdvanceFocus(bool reverse) {
150 render_view_->GetWebView()->advanceFocus(reverse); 164 render_view_->GetWebView()->advanceFocus(reverse);
151 } 165 }
152 166
167 void BrowserPlugin::BuffersSwapped(uint64 surface_handle, const BrowserPlugin_Sw apInfo& info) {
168 DCHECK(surface_handle != 0);
169 fprintf(stderr, "Browser plugin swapping buffers on surface %lu\n", surface_ha ndle);
170 container_->setBackingTextureId(surface_handle);
171 container_->commitBackingTexture();
172 compositing_callbacks_.push_back(base::Bind(&BrowserPlugin::PerformBuffersSwap pedACK, 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.
173 }
174
153 void BrowserPlugin::PostMessage(const std::string& message, 175 void BrowserPlugin::PostMessage(const std::string& message,
154 const std::string& target_origin) { 176 const std::string& target_origin) {
155 fprintf(stderr, ">>>%s message: \"%s\"\n", __PRETTY_FUNCTION__, 177 fprintf(stderr, ">>>%s message: \"%s\"\n", __PRETTY_FUNCTION__,
156 message.c_str()); 178 message.c_str());
157 } 179 }
158 180
181 void BrowserPlugin::WillInitiatePaint() {
182 for (std::vector< base::Callback<void(void)> >::const_iterator
183 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
184 it != compositing_callbacks_.end(); ++it) {
185 it->Run();
186 }
187 compositing_callbacks_.clear();
188 }
189
190 void BrowserPlugin::PerformBuffersSwappedACK(const BrowserPlugin_SwapInfo& info) {
191 WebKit::WebView* webview = render_view_->webview();
192 DCHECK(webview);
193 WebGraphicsContext3DCommandBufferImpl* buffer = static_cast<WebGraphicsContext 3DCommandBufferImpl*>(webview->sharedGraphicsContext3D());
194 DCHECK(buffer);
195 uint32 sync_point = buffer->insertSyncPoint();
196 render_view_->Send(new BrowserPluginHostMsg_BuffersSwappedACK(render_view_->Ge tRoutingID(), info, sync_point));
197 fprintf(stderr, "Sent browser plugin buffers swapped ACK\n");
198 }
199
159 WebKit::WebPluginContainer* BrowserPlugin::container() const { 200 WebKit::WebPluginContainer* BrowserPlugin::container() const {
160 return container_; 201 return container_;
161 } 202 }
162 203
163 bool BrowserPlugin::initialize(WebPluginContainer* container) { 204 bool BrowserPlugin::initialize(WebPluginContainer* container) {
164 container_ = container; 205 container_ = container;
165 return true; 206 return true;
166 } 207 }
167 208
168 void BrowserPlugin::destroy() { 209 void BrowserPlugin::destroy() {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 } 326 }
286 327
287 void BrowserPlugin::didFailLoadingFrameRequest( 328 void BrowserPlugin::didFailLoadingFrameRequest(
288 const WebKit::WebURL& url, 329 const WebKit::WebURL& url,
289 void* notify_data, 330 void* notify_data,
290 const WebKit::WebURLError& error) { 331 const WebKit::WebURLError& error) {
291 } 332 }
292 333
293 } // namespace browser_plugin 334 } // namespace browser_plugin
294 } // namespace content 335 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698