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

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: 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/browser/browser_plugin/browser_plugin_host_helper.h" 5 #include "content/browser/browser_plugin/browser_plugin_host_helper.h"
6 6
7 #include "content/browser/browser_plugin/browser_plugin_host.h" 7 #include "content/browser/browser_plugin/browser_plugin_host.h"
8 #include "content/browser/renderer_host/render_widget_host_impl.h" 8 #include "content/browser/renderer_host/render_widget_host_impl.h"
9 #include "content/common/browser_plugin_messages.h" 9 #include "content/common/browser_plugin_messages.h"
10 #include "content/common/view_messages.h" 10 #include "content/common/view_messages.h"
11 #include "content/public/browser/render_process_host.h" 11 #include "content/public/browser/render_process_host.h"
12 #include "content/common/gpu/gpu_messages.h"
12 #include "content/public/browser/render_view_host.h" 13 #include "content/public/browser/render_view_host.h"
13 #include "content/public/browser/render_widget_host_view.h" 14 #include "content/public/browser/render_widget_host_view.h"
14 #include "ipc/ipc_logging.h" 15 #include "ipc/ipc_logging.h"
15 #include "ui/gfx/size.h" 16 #include "ui/gfx/size.h"
17 #include "content/browser/renderer_host/render_widget_host_view_base.h"
18 #include "content/browser/renderer_host/render_widget_host_impl.h"
16 19
17 namespace content { 20 namespace content {
18 namespace browser_plugin { 21 namespace browser_plugin {
19 22
23 class CrappyCompositingDelegate : public RenderWidgetHostViewBase::CompositingDe legate {
24 public:
25 virtual gfx::GLSurfaceHandle GetCompositingSurface() {
26 gfx::GLSurfaceHandle handle = gfx::GLSurfaceHandle(gfx::kNullPluginWindow, t rue);
27 handle.parent_gpu_process_id = helper_->surface_params_.gpu_process_id;
28 handle.parent_client_id = helper_->surface_params_.client_id;
29 handle.parent_context_id = helper_->surface_params_.context_id;
30 handle.parent_texture_id[0] = helper_->surface_params_.texture_id[0];
31 handle.parent_texture_id[1] = helper_->surface_params_.texture_id[1];
32 handle.sync_point = helper_->surface_params_.sync_point;
33 printf("CrappyCompositingDelegate is giving textures %u and %u\n", handle.pa rent_texture_id[0], handle.parent_texture_id[1]);
34 return handle;
35 }
36
37 virtual bool ResizeNeedsNewSurface() { return false;}
Fady Samuel 2012/07/06 15:14:44 I'm confused why this is always false.
scshunt 2012/07/06 16:39:03 The Windows and GTK clients need to allocate new G
38 BrowserPluginHostHelper* helper_;
39 CrappyCompositingDelegate(BrowserPluginHostHelper* helper)
40 : helper_(helper) {
41 }
42
43 virtual void AcceleratedSurfaceBuffersSwapped(
44 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
45 int gpu_host_id) OVERRIDE {
46 printf("CrappyCompositingDelegate is acknowledging a full swap on surface %l u\n", params.surface_handle);
47
48 BrowserPlugin_SwapInfo info;
49 info.route_id = params.route_id;
50 info.gpu_host_id = gpu_host_id;
51
52 helper_->browser_plugin_host_->SendBuffersSwappedToEmbedder(params.surface_h andle, info);
53 }
54
55 virtual void AcceleratedSurfacePostSubBuffer(
56 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
57 int gpu_host_id) OVERRIDE {
58 printf("CrappyCompositingDelegate is acknowledging a partial swap\n");
Fady Samuel 2012/07/06 15:14:44 We don't do anything here?
scshunt 2012/07/06 16:39:03 This codepath never got used in my testing. This c
59 // WebPluginContents does not allow for partial invalidation, so we just inv alidate the whole thing.
60 // helper_->browser_plugin_host->SendBuffersSwappedToEmbedder(params.surface _handle);
61 // RenderWidgetHostImpl::AcknowledgeBufferPresent(params.route_id, gpu_host_ id, 0);
62 }
63
64 virtual void AcceleratedSurfaceNew(
65 int32 width_in_pixel, int32 height_in_pixel, uint64* surface_handle, Trans portDIB::Handle* shm_handle) {
66 printf("CrappyCompositingDelegate is making a new surface of width %d and he ight %d on surface %lu\n", width_in_pixel, height_in_pixel, *surface_handle);
Fady Samuel 2012/07/06 15:14:44 I'm confused by this too. Why does this work? Why
scshunt 2012/07/06 16:39:03 For texture image transport, no TransportDIB is ne
67 }
68 virtual void AcceleratedSurfaceRelease(
69 uint64 surface_handle) {
70 printf("CrappyCompositingDelegate is releasing a surface\n");
71 }
72 };
73
20 BrowserPluginHostHelper::BrowserPluginHostHelper( 74 BrowserPluginHostHelper::BrowserPluginHostHelper(
21 BrowserPluginHost* browser_plugin_host, 75 BrowserPluginHost* browser_plugin_host,
22 RenderViewHost* render_view_host) 76 RenderViewHost* render_view_host,
77 const BrowserPluginHostMsg_Surface_Params& params)
23 : RenderViewHostObserver(render_view_host), 78 : RenderViewHostObserver(render_view_host),
24 browser_plugin_host_(browser_plugin_host) { 79 browser_plugin_host_(browser_plugin_host),
80 surface_params_(params) {
81 printf("Constructing helper...");
82 if (browser_plugin_host->embedder_render_process_host()) {
83 printf(" in guest\n");
84 static_cast<RenderWidgetHostViewBase*>(render_view_host->GetView())->SetComp ositingDelegate(scoped_ptr<RenderWidgetHostViewBase::CompositingDelegate>(new Cr appyCompositingDelegate(this)).Pass());
85 } else {
86 printf(" not in guest\n");
87 }
25 } 88 }
26 89
27 BrowserPluginHostHelper::~BrowserPluginHostHelper() { 90 BrowserPluginHostHelper::~BrowserPluginHostHelper() {
28 } 91 }
29 92
30 bool BrowserPluginHostHelper::Send(IPC::Message* message) { 93 bool BrowserPluginHostHelper::Send(IPC::Message* message) {
31 return RenderViewHostObserver::Send(message); 94 return RenderViewHostObserver::Send(message);
32 } 95 }
33 96
34 bool BrowserPluginHostHelper::OnMessageReceived(const IPC::Message& message) { 97 bool BrowserPluginHostHelper::OnMessageReceived(const IPC::Message& message) {
35 bool handled = true; 98 bool handled = true;
36 IPC_BEGIN_MESSAGE_MAP(BrowserPluginHostHelper, message) 99 IPC_BEGIN_MESSAGE_MAP(BrowserPluginHostHelper, message)
37 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateFromEmbedder, 100 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateFromEmbedder,
38 OnNavigateGuestFromEmbedder) 101 OnNavigateGuestFromEmbedder)
39 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) 102 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest)
40 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateRect_ACK, OnUpdateRectACK) 103 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateRect_ACK, OnUpdateRectACK)
41 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus) 104 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus)
105 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_BuffersSwappedACK, OnSwapBuffersACK )
42 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_HandleInputEvent, 106 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_HandleInputEvent,
43 OnHandleInputEvent(*static_cast<const IPC::SyncMessage*>(&message))) 107 OnHandleInputEvent(*static_cast<const IPC::SyncMessage*>(&message)))
44 IPC_MESSAGE_UNHANDLED(handled = false) 108 IPC_MESSAGE_UNHANDLED(handled = false)
45 IPC_END_MESSAGE_MAP() 109 IPC_END_MESSAGE_MAP()
46 110
47 // We want to intercept certain messages if they are guests. 111 // We want to intercept certain messages if they are guests.
48 if (!browser_plugin_host_->embedder_render_process_host()) 112 if (!browser_plugin_host_->embedder_render_process_host())
49 return handled; 113 return handled;
50 114
51 handled = true; 115 handled = true;
52 IPC_BEGIN_MESSAGE_MAP(BrowserPluginHostHelper, message) 116 IPC_BEGIN_MESSAGE_MAP(BrowserPluginHostHelper, message)
53 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) 117 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect)
54 IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, 118 IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK,
55 OnHandleInputEventAck) 119 OnHandleInputEventAck)
56 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) 120 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
57 IPC_MESSAGE_UNHANDLED(handled = false) 121 IPC_MESSAGE_UNHANDLED(handled = false)
58 IPC_END_MESSAGE_MAP() 122 IPC_END_MESSAGE_MAP()
59 123
60 return handled; 124 return handled;
61 } 125 }
62 126
63 void BrowserPluginHostHelper::OnNavigateGuestFromEmbedder( 127 void BrowserPluginHostHelper::OnNavigateGuestFromEmbedder(
64 int instance_id, 128 int instance_id,
65 long long frame_id, 129 long long frame_id,
66 const std::string& src) { 130 const std::string& src,
131 const BrowserPluginHostMsg_Surface_Params& params) {
67 browser_plugin_host_->NavigateGuestFromEmbedder( 132 browser_plugin_host_->NavigateGuestFromEmbedder(
68 render_view_host(), 133 render_view_host(),
69 instance_id, 134 instance_id,
70 frame_id, 135 frame_id,
71 src); 136 src,
137 params);
72 } 138 }
73 139
74 void BrowserPluginHostHelper::OnResizeGuest( 140 void BrowserPluginHostHelper::OnResizeGuest(
75 int instance_id, 141 int instance_id,
76 const TransportDIB::Id& damage_buffer_id, 142 const TransportDIB::Id& damage_buffer_id,
77 int width, 143 int width,
78 int height) { 144 int height) {
79 TransportDIB* damage_buffer = NULL; 145 TransportDIB* damage_buffer = NULL;
80 #if defined(OS_WIN) 146 #if defined(OS_WIN)
81 // On Windows we need to duplicate the handle from the remote process 147 // On Windows we need to duplicate the handle from the remote process
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 188 }
123 189
124 void BrowserPluginHostHelper::OnUpdateRectACK(int instance_id, 190 void BrowserPluginHostHelper::OnUpdateRectACK(int instance_id,
125 int message_id) { 191 int message_id) {
126 192
127 BrowserPluginHost* guest = browser_plugin_host_-> 193 BrowserPluginHost* guest = browser_plugin_host_->
128 GetGuestByContainerID(instance_id); 194 GetGuestByContainerID(instance_id);
129 guest->UpdateRectACK(message_id); 195 guest->UpdateRectACK(message_id);
130 } 196 }
131 197
198 void BrowserPluginHostHelper::OnSwapBuffersACK(const BrowserPlugin_SwapInfo& inf o,
199 uint32 sync_point) {
200 printf("Received swap ACK\n");
201 RenderWidgetHostImpl::AcknowledgeBufferPresent(info.route_id, info.gpu_host_id , sync_point);
202 }
203
132 void BrowserPluginHostHelper::OnHandleInputEvent( 204 void BrowserPluginHostHelper::OnHandleInputEvent(
133 const IPC::SyncMessage& message) { 205 const IPC::SyncMessage& message) {
134 bool handled = true; 206 bool handled = true;
135 PickleIterator iter(message); 207 PickleIterator iter(message);
136 208
137 // TODO(fsamuel): This appears to be a monotonically increasing value. 209 // TODO(fsamuel): This appears to be a monotonically increasing value.
138 int instance_id = -1; 210 int instance_id = -1;
139 const char* data = NULL; 211 const char* data = NULL;
140 int data_length = -1; 212 int data_length = -1;
141 if (!iter.SkipBytes(4) || 213 if (!iter.SkipBytes(4) ||
(...skipping 15 matching lines...) Expand all
157 229
158 void BrowserPluginHostHelper::OnSetFocus(int container_instance_id, 230 void BrowserPluginHostHelper::OnSetFocus(int container_instance_id,
159 bool focused) { 231 bool focused) {
160 BrowserPluginHost* guest = browser_plugin_host_-> 232 BrowserPluginHost* guest = browser_plugin_host_->
161 GetGuestByContainerID(container_instance_id); 233 GetGuestByContainerID(container_instance_id);
162 guest->SetFocus(focused); 234 guest->SetFocus(focused);
163 } 235 }
164 236
165 } // namespace browser_plugin 237 } // namespace browser_plugin
166 } // namespace content 238 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698