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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_host_helper.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 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/browser/browser_plugin/browser_plugin_host_helper.h" 5 #include "content/browser/browser_plugin/browser_plugin_host_helper.h"
6 6
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "content/browser/browser_plugin/browser_plugin_host.h" 8 #include "content/browser/browser_plugin/browser_plugin_host.h"
9 #include "content/browser/renderer_host/render_view_host_impl.h" 9 #include "content/browser/renderer_host/render_view_host_impl.h"
10 #include "content/browser/renderer_host/render_widget_host_impl.h" 10 #include "content/browser/renderer_host/render_widget_host_impl.h"
11 #include "content/browser/renderer_host/render_widget_host_view_base.h"
11 #include "content/common/browser_plugin_messages.h" 12 #include "content/common/browser_plugin_messages.h"
12 #include "content/common/view_messages.h" 13 #include "content/common/view_messages.h"
13 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
15 #include "content/common/gpu/gpu_messages.h"
14 #include "content/public/browser/render_view_host.h" 16 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/render_widget_host_view.h" 17 #include "content/public/browser/render_widget_host_view.h"
16 #include "ui/gfx/size.h" 18 #include "ui/gfx/size.h"
17 19
18 namespace content { 20 namespace content {
19 21
22 class BrowserPluginCompositingDelegate :
23 public RenderWidgetHostViewBase::CompositingDelegate {
24 public:
25 virtual gfx::GLSurfaceHandle GetCompositingSurface() {
26 gfx::GLSurfaceHandle handle =
27 gfx::GLSurfaceHandle(gfx::kNullPluginWindow, true);
28 handle.parent_gpu_process_id = helper_->surface_params_.gpu_process_id;
29 handle.parent_client_id = helper_->surface_params_.client_id;
30 handle.parent_context_id = helper_->surface_params_.context_id;
31 handle.parent_texture_id[0] = helper_->surface_params_.texture_id[0];
32 handle.parent_texture_id[1] = helper_->surface_params_.texture_id[1];
33 handle.sync_point = helper_->surface_params_.sync_point;
34 return handle;
35 }
36
37 virtual bool ResizeNeedsNewSurface() { return false; }
38 BrowserPluginHostHelper* helper_;
39 BrowserPluginCompositingDelegate(BrowserPluginHostHelper* helper)
40 : helper_(helper) {
41 }
42
43 virtual void AcceleratedSurfaceBuffersSwapped(
44 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
45 int gpu_host_id) OVERRIDE {
46 BrowserPlugin_SwapInfo info;
47 info.route_id = params.route_id;
48 info.gpu_host_id = gpu_host_id;
49
50 helper_->browser_plugin_host_->SendBuffersSwappedToEmbedder(
51 params.surface_handle,
52 info);
53 }
54
55 virtual void AcceleratedSurfacePostSubBuffer(
56 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
57 int gpu_host_id) OVERRIDE {
58 // WebPluginContents does not allow for partial invalidation, so we just
59 // invalidate the whole thing.
scshunt 2012/08/12 01:42:45 Verify that these are the correct semantics for a
scshunt 2012/08/17 17:30:28 They are not and not easily. Made a TODO since I h
60 BrowserPlugin_SwapInfo info;
61 info.route_id = params.route_id;
62 info.gpu_host_id = gpu_host_id;
63
64 helper_->browser_plugin_host_->SendBuffersSwappedToEmbedder(
65 params.surface_handle,
66 info);
67 }
68
69 virtual void AcceleratedSurfaceNew(
70 int32 width_in_pixel,
71 int32 height_in_pixel,
72 uint64 surface_handle) {
73 helper_->browser_plugin_host_->SendSurfaceResizeToEmbedder(
74 gfx::Size(width_in_pixel, height_in_pixel));
75 }
76 virtual void AcceleratedSurfaceRelease(
77 uint64 surface_handle) {
78 }
79 };
80
20 BrowserPluginHostHelper::BrowserPluginHostHelper( 81 BrowserPluginHostHelper::BrowserPluginHostHelper(
21 BrowserPluginHost* browser_plugin_host, 82 BrowserPluginHost* browser_plugin_host,
22 RenderViewHost* render_view_host) 83 RenderViewHost* render_view_host,
84 const BrowserPluginHostMsg_Surface_Params& params)
23 : RenderViewHostObserver(render_view_host), 85 : RenderViewHostObserver(render_view_host),
24 browser_plugin_host_(browser_plugin_host) { 86 browser_plugin_host_(browser_plugin_host),
87 surface_params_(params) {
88 if (browser_plugin_host->embedder_render_process_host())
89 static_cast<RenderWidgetHostViewBase*>(render_view_host->GetView())->
90 SetCompositingDelegate(
91 scoped_ptr<RenderWidgetHostViewBase::CompositingDelegate>(
92 new BrowserPluginCompositingDelegate(this)).Pass());
25 } 93 }
26 94
27 BrowserPluginHostHelper::~BrowserPluginHostHelper() { 95 BrowserPluginHostHelper::~BrowserPluginHostHelper() {
28 } 96 }
29 97
30 bool BrowserPluginHostHelper::Send(IPC::Message* message) { 98 bool BrowserPluginHostHelper::Send(IPC::Message* message) {
31 return RenderViewHostObserver::Send(message); 99 return RenderViewHostObserver::Send(message);
32 } 100 }
33 101
34 bool BrowserPluginHostHelper::OnMessageReceived(const IPC::Message& message) { 102 bool BrowserPluginHostHelper::OnMessageReceived(const IPC::Message& message) {
35 bool handled = true; 103 bool handled = true;
36 IPC_BEGIN_MESSAGE_MAP(BrowserPluginHostHelper, message) 104 IPC_BEGIN_MESSAGE_MAP(BrowserPluginHostHelper, message)
37 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateOrCreateGuest, 105 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateOrCreateGuest,
38 OnNavigateOrCreateGuest) 106 OnNavigateOrCreateGuest)
39 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) 107 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest)
40 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateRect_ACK, OnUpdateRectACK) 108 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateRect_ACK, OnUpdateRectACK)
41 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus) 109 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus)
110 IPC_MESSAGE_HANDLER(
111 BrowserPluginHostMsg_BuffersSwappedACK,
112 OnSwapBuffersACK)
42 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_HandleInputEvent, 113 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_HandleInputEvent,
43 OnHandleInputEvent(*static_cast<const IPC::SyncMessage*>(&message), 114 OnHandleInputEvent(*static_cast<const IPC::SyncMessage*>(&message),
44 &handled)) 115 &handled))
45 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed) 116 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed)
46 IPC_MESSAGE_UNHANDLED(handled = false) 117 IPC_MESSAGE_UNHANDLED(handled = false)
47 IPC_END_MESSAGE_MAP() 118 IPC_END_MESSAGE_MAP()
48 119
49 // We want to intercept certain messages if they are guests. 120 // We want to intercept certain messages if they are guests.
50 if (!browser_plugin_host_->embedder_render_process_host()) 121 if (!browser_plugin_host_->embedder_render_process_host())
51 return handled; 122 return handled;
52 123
53 handled = true; 124 handled = true;
54 IPC_BEGIN_MESSAGE_MAP(BrowserPluginHostHelper, message) 125 IPC_BEGIN_MESSAGE_MAP(BrowserPluginHostHelper, message)
55 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) 126 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect)
56 IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, 127 IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK,
57 OnHandleInputEventAck) 128 OnHandleInputEventAck)
58 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) 129 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
59 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) 130 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget)
60 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) 131 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor)
61 IPC_MESSAGE_UNHANDLED(handled = false) 132 IPC_MESSAGE_UNHANDLED(handled = false)
62 IPC_END_MESSAGE_MAP() 133 IPC_END_MESSAGE_MAP()
63 134
64 return handled; 135 return handled;
65 } 136 }
66 137
67 void BrowserPluginHostHelper::OnNavigateOrCreateGuest( 138 void BrowserPluginHostHelper::OnNavigateOrCreateGuest(
68 int instance_id, 139 int instance_id,
69 long long frame_id, 140 long long frame_id,
70 const std::string& src) { 141 const std::string& src,
142 const BrowserPluginHostMsg_Surface_Params& params) {
71 browser_plugin_host_->NavigateOrCreateGuest( 143 browser_plugin_host_->NavigateOrCreateGuest(
72 render_view_host(), 144 render_view_host(),
73 instance_id, 145 instance_id,
74 frame_id, 146 frame_id,
75 src); 147 src,
148 params);
76 } 149 }
77 150
78 void BrowserPluginHostHelper::OnResizeGuest( 151 void BrowserPluginHostHelper::OnResizeGuest(
79 int instance_id, 152 int instance_id,
80 const BrowserPluginHostMsg_ResizeGuest_Params& params) { 153 const BrowserPluginHostMsg_ResizeGuest_Params& params) {
81 TransportDIB* damage_buffer = NULL; 154 TransportDIB* damage_buffer = NULL;
82 #if defined(OS_WIN) 155 #if defined(OS_WIN)
83 // On Windows we need to duplicate the handle from the remote process 156 // On Windows we need to duplicate the handle from the remote process
84 HANDLE section; 157 HANDLE section;
85 DuplicateHandle(GetHandle(), 158 DuplicateHandle(GetHandle(),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 browser_plugin_host_->UpdateRect(render_view_host(), params); 190 browser_plugin_host_->UpdateRect(render_view_host(), params);
118 } 191 }
119 192
120 void BrowserPluginHostHelper::OnHandleInputEventAck( 193 void BrowserPluginHostHelper::OnHandleInputEventAck(
121 WebKit::WebInputEvent::Type event_type, 194 WebKit::WebInputEvent::Type event_type,
122 bool processed) { 195 bool processed) {
123 browser_plugin_host_->HandleInputEventAck(render_view_host(), processed); 196 browser_plugin_host_->HandleInputEventAck(render_view_host(), processed);
124 } 197 }
125 198
126 void BrowserPluginHostHelper::OnTakeFocus(bool reverse) { 199 void BrowserPluginHostHelper::OnTakeFocus(bool reverse) {
127 browser_plugin_host_->TakeFocus(reverse); 200 browser_plugin_host_->TakeFocus(0, reverse);
201 }
202
203 void BrowserPluginHostHelper::OnSwapBuffersACK(
204 const BrowserPlugin_SwapInfo& info,
205 uint32 sync_point) {
206 RenderWidgetHostImpl::AcknowledgeBufferPresent(
207 info.route_id,
208 info.gpu_host_id,
209 sync_point);
128 } 210 }
129 211
130 void BrowserPluginHostHelper::OnShowWidget( 212 void BrowserPluginHostHelper::OnShowWidget(
131 int route_id, 213 int route_id,
132 const gfx::Rect& initial_pos) { 214 const gfx::Rect& initial_pos) {
133 browser_plugin_host_->ShowWidget(render_view_host(), route_id, initial_pos); 215 browser_plugin_host_->ShowWidget(render_view_host(), route_id, initial_pos);
134 } 216 }
135 217
136 void BrowserPluginHostHelper::OnSetCursor(const WebCursor& cursor) { 218 void BrowserPluginHostHelper::OnSetCursor(const WebCursor& cursor) {
137 browser_plugin_host_->SetCursor(cursor); 219 browser_plugin_host_->SetCursor(cursor);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 BrowserPluginHost* guest = browser_plugin_host_-> 275 BrowserPluginHost* guest = browser_plugin_host_->
194 GetGuestByInstanceID(instance_id); 276 GetGuestByInstanceID(instance_id);
195 guest->SetFocus(focused); 277 guest->SetFocus(focused);
196 } 278 }
197 279
198 void BrowserPluginHostHelper::OnPluginDestroyed(int instance_id) { 280 void BrowserPluginHostHelper::OnPluginDestroyed(int instance_id) {
199 browser_plugin_host_->DestroyGuestByInstanceID(instance_id); 281 browser_plugin_host_->DestroyGuestByInstanceID(instance_id);
200 } 282 }
201 283
202 } // namespace content 284 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698