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

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: 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 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 // This is the signal for having no context
27 if (helper_->surface_params_.texture_id[0] == 0) {
28 DCHECK(helper_->surface_params_.texture_id[1] == 0);
29 return gfx::GLSurfaceHandle();
30 } else {
31 DCHECK(helper_->surface_params_.texture_id[1] != 0);
32 DCHECK(helper_->surface_params_.texture_id[0] !=
33 helper_->surface_params_.texture_id[1]);
34 }
35
36 gfx::GLSurfaceHandle handle =
37 gfx::GLSurfaceHandle(gfx::kNullPluginWindow, true);
38 handle.parent_gpu_process_id = helper_->surface_params_.gpu_process_id;
39 handle.parent_client_id = helper_->surface_params_.client_id;
40 handle.parent_context_id = helper_->surface_params_.context_id;
41 handle.parent_texture_id[0] = helper_->surface_params_.texture_id[0];
42 handle.parent_texture_id[1] = helper_->surface_params_.texture_id[1];
43 handle.sync_point = helper_->surface_params_.sync_point;
44 return handle;
45 }
46
47 virtual bool ResizeNeedsNewSurface() { return false; }
48 BrowserPluginHostHelper* helper_;
49 BrowserPluginCompositingDelegate(BrowserPluginHostHelper* helper)
50 : helper_(helper) {
51 }
52
53 virtual void AcceleratedSurfaceBuffersSwapped(
54 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
55 int gpu_host_id) OVERRIDE {
56 BrowserPlugin_SwapInfo info;
57 info.route_id = params.route_id;
58 info.gpu_host_id = gpu_host_id;
59
60 helper_->browser_plugin_host_->SendBuffersSwappedToEmbedder(
61 params.surface_handle,
62 info);
63 }
64
65 virtual void AcceleratedSurfacePostSubBuffer(
66 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
67 int gpu_host_id) OVERRIDE {
68 // TODO(scshunt): We don't actually support posting a sub-buffer.
69 // However, we can't turn that off here; the TextureImageTransportSurface
70 // needs to know not to accept sub-buffers. Try to do an entire swap
71 // instead, which is probably better than ignoring the post altogether.
72 BrowserPlugin_SwapInfo info;
73 info.route_id = params.route_id;
74 info.gpu_host_id = gpu_host_id;
75
76 helper_->browser_plugin_host_->SendBuffersSwappedToEmbedder(
77 params.surface_handle,
78 info);
79 }
80
81 virtual void AcceleratedSurfaceNew(
82 int32 width_in_pixel,
83 int32 height_in_pixel,
84 uint64 surface_handle) {
85 helper_->browser_plugin_host_->SendSurfaceResizeToEmbedder(
86 gfx::Size(width_in_pixel, height_in_pixel));
87 }
88 virtual void AcceleratedSurfaceRelease(
89 uint64 surface_handle) {
90 }
91 };
92
20 BrowserPluginHostHelper::BrowserPluginHostHelper( 93 BrowserPluginHostHelper::BrowserPluginHostHelper(
21 BrowserPluginHost* browser_plugin_host, 94 BrowserPluginHost* browser_plugin_host,
22 RenderViewHost* render_view_host) 95 RenderViewHost* render_view_host,
96 const BrowserPluginHostMsg_Surface_Params& params)
23 : RenderViewHostObserver(render_view_host), 97 : RenderViewHostObserver(render_view_host),
24 browser_plugin_host_(browser_plugin_host) { 98 browser_plugin_host_(browser_plugin_host),
99 surface_params_(params) {
100 if (browser_plugin_host->embedder_render_process_host())
101 static_cast<RenderWidgetHostViewBase*>(render_view_host->GetView())->
102 SetCompositingDelegate(
103 scoped_ptr<RenderWidgetHostViewBase::CompositingDelegate>(
104 new BrowserPluginCompositingDelegate(this)).Pass());
25 } 105 }
26 106
27 BrowserPluginHostHelper::~BrowserPluginHostHelper() { 107 BrowserPluginHostHelper::~BrowserPluginHostHelper() {
28 } 108 }
29 109
30 bool BrowserPluginHostHelper::Send(IPC::Message* message) { 110 bool BrowserPluginHostHelper::Send(IPC::Message* message) {
31 return RenderViewHostObserver::Send(message); 111 return RenderViewHostObserver::Send(message);
32 } 112 }
33 113
34 bool BrowserPluginHostHelper::OnMessageReceived(const IPC::Message& message) { 114 bool BrowserPluginHostHelper::OnMessageReceived(const IPC::Message& message) {
35 bool handled = true; 115 bool handled = true;
36 IPC_BEGIN_MESSAGE_MAP(BrowserPluginHostHelper, message) 116 IPC_BEGIN_MESSAGE_MAP(BrowserPluginHostHelper, message)
37 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest, 117 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest,
38 OnNavigateGuest) 118 OnNavigateGuest)
39 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) 119 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest)
40 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateRect_ACK, OnUpdateRectACK) 120 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateRect_ACK, OnUpdateRectACK)
41 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus) 121 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus)
122 IPC_MESSAGE_HANDLER(
123 BrowserPluginHostMsg_BuffersSwappedACK,
124 OnSwapBuffersACK)
42 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_HandleInputEvent, 125 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_HandleInputEvent,
43 OnHandleInputEvent(*static_cast<const IPC::SyncMessage*>(&message), 126 OnHandleInputEvent(*static_cast<const IPC::SyncMessage*>(&message),
44 &handled)) 127 &handled))
45 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed) 128 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed)
46 IPC_MESSAGE_UNHANDLED(handled = false) 129 IPC_MESSAGE_UNHANDLED(handled = false)
47 IPC_END_MESSAGE_MAP() 130 IPC_END_MESSAGE_MAP()
48 131
49 // We want to intercept certain messages if they are guests. 132 // We want to intercept certain messages if they are guests.
50 if (!browser_plugin_host_->embedder_render_process_host()) 133 if (!browser_plugin_host_->embedder_render_process_host())
51 return handled; 134 return handled;
52 135
53 handled = true; 136 handled = true;
54 IPC_BEGIN_MESSAGE_MAP(BrowserPluginHostHelper, message) 137 IPC_BEGIN_MESSAGE_MAP(BrowserPluginHostHelper, message)
55 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) 138 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect)
56 IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, 139 IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK,
57 OnHandleInputEventAck) 140 OnHandleInputEventAck)
58 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) 141 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
59 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) 142 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget)
60 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) 143 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor)
61 IPC_MESSAGE_UNHANDLED(handled = false) 144 IPC_MESSAGE_UNHANDLED(handled = false)
62 IPC_END_MESSAGE_MAP() 145 IPC_END_MESSAGE_MAP()
63 146
64 return handled; 147 return handled;
65 } 148 }
66 149
67 void BrowserPluginHostHelper::OnNavigateGuest( 150 void BrowserPluginHostHelper::OnNavigateGuest(
68 int instance_id, 151 int instance_id,
69 long long frame_id, 152 long long frame_id,
70 const std::string& src, 153 const std::string& src,
71 const gfx::Size& size) { 154 const gfx::Size& size,
155 const BrowserPluginHostMsg_Surface_Params& params) {
72 browser_plugin_host_->NavigateGuest( 156 browser_plugin_host_->NavigateGuest(
73 render_view_host(), 157 render_view_host(),
74 instance_id, 158 instance_id,
75 frame_id, 159 frame_id,
76 src, 160 src,
77 size); 161 size,
162 params);
78 } 163 }
79 164
80 void BrowserPluginHostHelper::OnResizeGuest( 165 void BrowserPluginHostHelper::OnResizeGuest(
81 int instance_id, 166 int instance_id,
82 const BrowserPluginHostMsg_ResizeGuest_Params& params) { 167 const BrowserPluginHostMsg_ResizeGuest_Params& params) {
83 TransportDIB* damage_buffer = NULL; 168 TransportDIB* damage_buffer = NULL;
84 #if defined(OS_WIN) 169 #if defined(OS_WIN)
85 // On Windows we need to duplicate the handle from the remote process 170 // On Windows we need to duplicate the handle from the remote process
86 HANDLE section; 171 HANDLE section;
87 DuplicateHandle(GetHandle(), 172 DuplicateHandle(GetHandle(),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 void BrowserPluginHostHelper::OnHandleInputEventAck( 207 void BrowserPluginHostHelper::OnHandleInputEventAck(
123 WebKit::WebInputEvent::Type event_type, 208 WebKit::WebInputEvent::Type event_type,
124 bool processed) { 209 bool processed) {
125 browser_plugin_host_->HandleInputEventAck(render_view_host(), processed); 210 browser_plugin_host_->HandleInputEventAck(render_view_host(), processed);
126 } 211 }
127 212
128 void BrowserPluginHostHelper::OnTakeFocus(bool reverse) { 213 void BrowserPluginHostHelper::OnTakeFocus(bool reverse) {
129 browser_plugin_host_->TakeFocus(0, reverse); 214 browser_plugin_host_->TakeFocus(0, reverse);
130 } 215 }
131 216
217 void BrowserPluginHostHelper::OnSwapBuffersACK(
218 const BrowserPlugin_SwapInfo& info,
219 uint32 sync_point) {
220 RenderWidgetHostImpl::AcknowledgeBufferPresent(
221 info.route_id,
222 info.gpu_host_id,
223 sync_point);
224 }
225
132 void BrowserPluginHostHelper::OnShowWidget( 226 void BrowserPluginHostHelper::OnShowWidget(
133 int route_id, 227 int route_id,
134 const gfx::Rect& initial_pos) { 228 const gfx::Rect& initial_pos) {
135 browser_plugin_host_->ShowWidget(render_view_host(), route_id, initial_pos); 229 browser_plugin_host_->ShowWidget(render_view_host(), route_id, initial_pos);
136 } 230 }
137 231
138 void BrowserPluginHostHelper::OnSetCursor(const WebCursor& cursor) { 232 void BrowserPluginHostHelper::OnSetCursor(const WebCursor& cursor) {
139 browser_plugin_host_->SetCursor(cursor); 233 browser_plugin_host_->SetCursor(cursor);
140 } 234 }
141 235
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 GetGuestByInstanceID(instance_id); 290 GetGuestByInstanceID(instance_id);
197 if (guest) 291 if (guest)
198 guest->SetFocus(focused); 292 guest->SetFocus(focused);
199 } 293 }
200 294
201 void BrowserPluginHostHelper::OnPluginDestroyed(int instance_id) { 295 void BrowserPluginHostHelper::OnPluginDestroyed(int instance_id) {
202 browser_plugin_host_->DestroyGuestByInstanceID(instance_id); 296 browser_plugin_host_->DestroyGuestByInstanceID(instance_id);
203 } 297 }
204 298
205 } // namespace content 299 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_host_helper.h ('k') | content/browser/gpu/gpu_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698