1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
|
// TODO(jam): move this file to src/content once we have an interface that the
// embedder provides. We can then use it to get the resource and resize the
// window.
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/gpu_process_host_ui_shim.h"
#include "base/command_line.h"
#include "base/id_map.h"
#include "base/process_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/gpu_data_manager.h"
#include "chrome/browser/io_thread.h"
#include "content/browser/browser_thread.h"
#include "content/browser/gpu_process_host.h"
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
#include "content/common/content_switches.h"
#include "content/common/gpu_messages.h"
#include "gpu/common/gpu_trace_event.h"
#include "ui/gfx/gl/gl_context.h"
#if defined(OS_LINUX)
// These two #includes need to come after gpu_messages.h.
#include <gdk/gdkwindow.h> // NOLINT
#include <gdk/gdkx.h> // NOLINT
#include "ui/base/x/x11_util.h"
#include "ui/gfx/gtk_native_view_id_manager.h"
#include "ui/gfx/size.h"
#endif // defined(OS_LINUX)
namespace {
// One of the linux specific headers defines this as a macro.
#ifdef DestroyAll
#undef DestroyAll
#endif
int g_last_host_id = 0;
IDMap<GpuProcessHostUIShim> g_hosts_by_id;
class SendOnIOThreadTask : public Task {
public:
SendOnIOThreadTask(int host_id, IPC::Message* msg)
: host_id_(host_id),
msg_(msg) {
}
private:
void Run() {
GpuProcessHost* host = GpuProcessHost::FromID(host_id_);
if (host)
host->Send(msg_.release());
}
int host_id_;
scoped_ptr<IPC::Message> msg_;
};
class UIThreadSender : public IPC::Channel::Sender {
public:
virtual bool Send(IPC::Message* msg) {
// The GPU process must never send a synchronous IPC message to the browser
// process. This could result in deadlock. Unfortunately linux does this for
// GpuHostMsg_ResizeXID. TODO(apatrick): fix this before issuing any GL calls
// on the browser process' GPU thread.
#if !defined(OS_LINUX)
DCHECK(!msg->is_sync());
#endif
// When the GpuChannelManager sends an IPC, post it to the UI thread without
// using IPC.
bool success = BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
new RouteToGpuProcessHostUIShimTask(0, *msg));
delete msg;
return success;
}
};
void ForwardMessageToGpuThread(GpuChannelManager* gpu_channel_manager,
IPC::Message* msg) {
bool success = gpu_channel_manager->OnMessageReceived(*msg);
// If the message was not handled, it is likely it was intended for the
// GpuChildThread, which does not exist in single process and in process GPU
// mode.
DCHECK(success);
delete msg;
}
} // namespace
RouteToGpuProcessHostUIShimTask::RouteToGpuProcessHostUIShimTask(
int host_id,
const IPC::Message& msg)
: host_id_(host_id),
msg_(msg) {
}
RouteToGpuProcessHostUIShimTask::~RouteToGpuProcessHostUIShimTask() {
}
void RouteToGpuProcessHostUIShimTask::Run() {
GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(host_id_);
if (ui_shim)
ui_shim->OnMessageReceived(msg_);
}
class GpuProcessHostUIShim::ViewSurface {
public:
explicit ViewSurface(ViewID view_id);
~ViewSurface();
gfx::PluginWindowHandle surface() { return surface_; }
private:
RenderWidgetHostView* GetRenderWidgetHostView();
ViewID view_id_;
gfx::PluginWindowHandle surface_;
};
GpuProcessHostUIShim::ViewSurface::ViewSurface(ViewID view_id)
: view_id_(view_id), surface_(gfx::kNullPluginWindow) {
RenderWidgetHostView* view = GetRenderWidgetHostView();
if (view)
surface_ = view->AcquireCompositingSurface();
}
GpuProcessHostUIShim::ViewSurface::~ViewSurface() {
if (!surface_)
return;
RenderWidgetHostView* view = GetRenderWidgetHostView();
if (view)
view->ReleaseCompositingSurface(surface_);
}
// We do separate lookups for the RenderWidgetHostView when acquiring
// and releasing surfaces (rather than caching) because the
// RenderWidgetHostView could die without warning. In such a case,
// it's the RenderWidgetHostView's responsibility to cleanup.
RenderWidgetHostView* GpuProcessHostUIShim::ViewSurface::
GetRenderWidgetHostView() {
RenderProcessHost* process = RenderProcessHost::FromID(view_id_.first);
RenderWidgetHost* host = NULL;
if (process) {
host = static_cast<RenderWidgetHost*>(
process->GetListenerByID(view_id_.second));
}
RenderWidgetHostView* view = NULL;
if (host)
view = host->view();
return view;
}
GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id,
content::CauseForGpuLaunch cause_for_gpu_launch)
: host_id_(host_id),
gpu_process_(base::kNullProcessHandle),
gpu_channel_manager_(NULL),
ui_thread_sender_(NULL) {
g_hosts_by_id.AddWithID(this, host_id_);
gpu_data_manager_ = GpuDataManager::GetInstance();
DCHECK(gpu_data_manager_);
if (host_id == 0) {
gpu_process_ = base::GetCurrentProcessHandle();
ui_thread_sender_ = new UIThreadSender;
gpu_channel_manager_ = new GpuChannelManager(
ui_thread_sender_,
NULL,
g_browser_process->io_thread()->message_loop(),
g_browser_process->shutdown_event());
} else {
// Post a task to create the corresponding GpuProcessHost.
// The GpuProcessHostUIShim will be destroyed if either the browser exits,
// in which case it calls GpuProcessHostUIShim::DestroyAll, or the
// GpuProcessHost is destroyed, which happens when the corresponding GPU
// process terminates or fails to launch.
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
NewRunnableFunction(
&GpuProcessHost::Create,
host_id,
GpuDataManager::GetInstance()->GetGpuFeatureFlags(),
cause_for_gpu_launch));
}
}
// static
GpuProcessHostUIShim* GpuProcessHostUIShim::GetForRenderer(int renderer_id,
content::CauseForGpuLaunch cause_for_gpu_launch) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Don't grant further access to GPU if it is not allowed.
GpuDataManager* gpu_data_manager = GpuDataManager::GetInstance();
if (gpu_data_manager != NULL && !gpu_data_manager->GpuAccessAllowed())
return NULL;
// The current policy is to ignore the renderer ID and use a single GPU
// process for all renderers. Later this will be extended to allow the
// use of multiple GPU processes.
if (!g_hosts_by_id.IsEmpty()) {
IDMap<GpuProcessHostUIShim>::iterator it(&g_hosts_by_id);
return it.GetCurrentValue();
}
int host_id;
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) ||
CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) {
if (!g_browser_process->gpu_thread())
return NULL;
// Initialize GL on the GPU thread.
// TODO(apatrick): Handle failure to initialize (asynchronously).
if (!BrowserThread::PostTask(
BrowserThread::GPU,
FROM_HERE,
NewRunnableFunction(&gfx::GLContext::InitializeOneOff))) {
return NULL;
}
host_id = 0;
} else {
host_id = ++g_last_host_id;
}
return new GpuProcessHostUIShim(host_id, cause_for_gpu_launch);
}
// static
void GpuProcessHostUIShim::Destroy(int host_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
delete FromID(host_id);
}
// static
void GpuProcessHostUIShim::DestroyAll() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
while (!g_hosts_by_id.IsEmpty()) {
IDMap<GpuProcessHostUIShim>::iterator it(&g_hosts_by_id);
delete it.GetCurrentValue();
}
}
// static
void GpuProcessHostUIShim::NotifyGpuProcessLaunched(
int host_id,
base::ProcessHandle gpu_process) {
DCHECK(gpu_process);
GpuProcessHostUIShim* ui_shim = FromID(host_id);
DCHECK(ui_shim);
ui_shim->gpu_process_ = gpu_process;
}
// static
GpuProcessHostUIShim* GpuProcessHostUIShim::FromID(int host_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
return g_hosts_by_id.Lookup(host_id);
}
bool GpuProcessHostUIShim::Send(IPC::Message* msg) {
DCHECK(CalledOnValidThread());
bool success;
if (host_id_ == 0) {
success = BrowserThread::PostTask(
BrowserThread::GPU,
FROM_HERE,
NewRunnableFunction(ForwardMessageToGpuThread,
gpu_channel_manager_,
msg));
} else {
success = BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
new SendOnIOThreadTask(host_id_, msg));
}
return success;
}
// Post a Task to execute callbacks on a error conditions in order to
// clear the call stacks (and aid debugging).
namespace {
void EstablishChannelCallbackDispatcher(
GpuProcessHostUIShim::EstablishChannelCallback* callback,
const IPC::ChannelHandle& channel_handle,
base::ProcessHandle renderer_process_for_gpu,
const GPUInfo& gpu_info) {
scoped_ptr<GpuProcessHostUIShim::EstablishChannelCallback>
wrapped_callback(callback);
wrapped_callback->Run(channel_handle, renderer_process_for_gpu, gpu_info);
}
void EstablishChannelError(
GpuProcessHostUIShim::EstablishChannelCallback* callback,
const IPC::ChannelHandle& channel_handle,
base::ProcessHandle renderer_process_for_gpu,
const GPUInfo& gpu_info) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
NewRunnableFunction(&EstablishChannelCallbackDispatcher,
callback,
channel_handle,
renderer_process_for_gpu,
gpu_info));
}
void SynchronizeCallbackDispatcher(
GpuProcessHostUIShim::SynchronizeCallback* callback) {
scoped_ptr<GpuProcessHostUIShim::SynchronizeCallback>
wrapped_callback(callback);
wrapped_callback->Run();
}
void SynchronizeError(
GpuProcessHostUIShim::SynchronizeCallback* callback) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
NewRunnableFunction(&SynchronizeCallbackDispatcher, callback));
}
void CreateCommandBufferCallbackDispatcher(
GpuProcessHostUIShim::CreateCommandBufferCallback* callback,
int32 route_id) {
scoped_ptr<GpuProcessHostUIShim::CreateCommandBufferCallback>
wrapped_callback(callback);
callback->Run(route_id);
}
void CreateCommandBufferError(
GpuProcessHostUIShim::CreateCommandBufferCallback* callback,
int32 route_id) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
NewRunnableFunction(&CreateCommandBufferCallbackDispatcher,
callback, route_id));
}
} // namespace
void GpuProcessHostUIShim::SendOutstandingReplies() {
// First send empty channel handles for all EstablishChannel requests.
while (!channel_requests_.empty()) {
linked_ptr<EstablishChannelCallback> callback = channel_requests_.front();
channel_requests_.pop();
EstablishChannelError(callback.release(),
IPC::ChannelHandle(),
base::kNullProcessHandle,
GPUInfo());
}
// Now unblock all renderers waiting for synchronization replies.
while (!synchronize_requests_.empty()) {
linked_ptr<SynchronizeCallback> callback = synchronize_requests_.front();
synchronize_requests_.pop();
SynchronizeError(callback.release());
}
}
bool GpuProcessHostUIShim::OnMessageReceived(const IPC::Message& message) {
DCHECK(CalledOnValidThread());
if (message.routing_id() != MSG_ROUTING_CONTROL)
return false;
return OnControlMessageReceived(message);
}
void GpuProcessHostUIShim::EstablishGpuChannel(
int renderer_id,
EstablishChannelCallback *callback) {
DCHECK(CalledOnValidThread());
GPU_TRACE_EVENT0("gpu", "GpuProcessHostUIShim::EstablishGpuChannel");
linked_ptr<EstablishChannelCallback> wrapped_callback(callback);
// If GPU features are already blacklisted, no need to establish the channel.
if (!gpu_data_manager_->GpuAccessAllowed()) {
EstablishChannelError(
wrapped_callback.release(), IPC::ChannelHandle(),
base::kNullProcessHandle, GPUInfo());
return;
}
if (Send(new GpuMsg_EstablishChannel(renderer_id))) {
channel_requests_.push(wrapped_callback);
} else {
EstablishChannelError(
wrapped_callback.release(), IPC::ChannelHandle(),
base::kNullProcessHandle, GPUInfo());
}
}
void GpuProcessHostUIShim::Synchronize(SynchronizeCallback* callback) {
DCHECK(CalledOnValidThread());
linked_ptr<SynchronizeCallback> wrapped_callback(callback);
if (Send(new GpuMsg_Synchronize())) {
synchronize_requests_.push(wrapped_callback);
} else {
SynchronizeError(wrapped_callback.release());
}
}
void GpuProcessHostUIShim::CreateViewCommandBuffer(
int32 render_view_id,
int32 renderer_id,
const GPUCreateCommandBufferConfig& init_params,
CreateCommandBufferCallback* callback) {
DCHECK(CalledOnValidThread());
linked_ptr<CreateCommandBufferCallback> wrapped_callback(callback);
ViewID view_id(renderer_id, render_view_id);
// There should only be one such command buffer (for the compositor). In
// practice, if the GPU process lost a context, GraphicsContext3D with
// associated command buffer and view surface will not be gone until new
// one is in place and all layers are reattached.
linked_ptr<ViewSurface> view_surface;
ViewSurfaceMap::iterator it = acquired_surfaces_.find(view_id);
if (it != acquired_surfaces_.end())
view_surface = (*it).second;
else
view_surface.reset(new ViewSurface(view_id));
if (view_surface->surface() != gfx::kNullPluginWindow &&
Send(new GpuMsg_CreateViewCommandBuffer(
view_surface->surface(), render_view_id, renderer_id, init_params))) {
create_command_buffer_requests_.push(wrapped_callback);
acquired_surfaces_.insert(std::pair<ViewID, linked_ptr<ViewSurface> >(
view_id, view_surface));
} else {
CreateCommandBufferError(wrapped_callback.release(), MSG_ROUTING_NONE);
}
}
#if defined(OS_MACOSX)
void GpuProcessHostUIShim::DidDestroyAcceleratedSurface(int renderer_id,
int render_view_id) {
// Destroy the command buffer that owns the accelerated surface.
Send(new GpuMsg_DestroyCommandBuffer(renderer_id, render_view_id));
}
void GpuProcessHostUIShim::SendToGpuHost(int host_id, IPC::Message* msg) {
GpuProcessHostUIShim* ui_shim = FromID(host_id);
if (!ui_shim)
return;
ui_shim->Send(msg);
}
#endif
void GpuProcessHostUIShim::CollectGpuInfoAsynchronously() {
DCHECK(CalledOnValidThread());
Send(new GpuMsg_CollectGraphicsInfo());
}
void GpuProcessHostUIShim::SendAboutGpuCrash() {
DCHECK(CalledOnValidThread());
Send(new GpuMsg_Crash());
}
void GpuProcessHostUIShim::SendAboutGpuHang() {
DCHECK(CalledOnValidThread());
Send(new GpuMsg_Hang());
}
GpuProcessHostUIShim::~GpuProcessHostUIShim() {
DCHECK(CalledOnValidThread());
g_hosts_by_id.Remove(host_id_);
#if defined(OS_WIN)
if (gpu_process_)
CloseHandle(gpu_process_);
#endif
// Ensure these are destroyed on the GPU thread.
if (gpu_channel_manager_) {
BrowserThread::DeleteSoon(BrowserThread::GPU,
FROM_HERE,
gpu_channel_manager_);
gpu_channel_manager_ = NULL;
}
if (ui_thread_sender_) {
BrowserThread::DeleteSoon(BrowserThread::GPU,
FROM_HERE,
ui_thread_sender_);
ui_thread_sender_ = NULL;
}
}
void GpuProcessHostUIShim::AddCustomLogMessage(int level,
const std::string& header,
const std::string& message) {
OnLogMessage(level, header, message);
}
bool GpuProcessHostUIShim::OnControlMessageReceived(
const IPC::Message& message) {
DCHECK(CalledOnValidThread());
IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message)
IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished,
OnChannelEstablished)
IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated,
OnCommandBufferCreated)
IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer,
OnDestroyCommandBuffer)
IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected,
OnGraphicsInfoCollected)
IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage,
OnLogMessage)
IPC_MESSAGE_HANDLER(GpuHostMsg_SynchronizeReply,
OnSynchronizeReply)
#if defined(OS_LINUX) && !defined(TOUCH_UI)
IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_ResizeXID, OnResizeXID)
#elif defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface,
OnAcceleratedSurfaceSetIOSurface)
IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
OnAcceleratedSurfaceBuffersSwapped)
#elif defined(OS_WIN)
IPC_MESSAGE_HANDLER(GpuHostMsg_ScheduleComposite, OnScheduleComposite);
#endif
IPC_MESSAGE_UNHANDLED_ERROR()
IPC_END_MESSAGE_MAP()
return true;
}
void GpuProcessHostUIShim::OnChannelEstablished(
const IPC::ChannelHandle& channel_handle) {
// The GPU process should have launched at this point and this object should
// have been notified of its process handle.
DCHECK(gpu_process_);
linked_ptr<EstablishChannelCallback> callback = channel_requests_.front();
channel_requests_.pop();
// Currently if any of the GPU features are blacklisted, we don't establish a
// GPU channel.
if (!channel_handle.name.empty() &&
!gpu_data_manager_->GpuAccessAllowed()) {
Send(new GpuMsg_CloseChannel(channel_handle));
EstablishChannelError(callback.release(),
IPC::ChannelHandle(),
base::kNullProcessHandle,
GPUInfo());
AddCustomLogMessage(logging::LOG_WARNING, "WARNING",
"Hardware acceleration is unavailable.");
return;
}
callback->Run(channel_handle, gpu_process_, gpu_data_manager_->gpu_info());
}
void GpuProcessHostUIShim::OnSynchronizeReply() {
// Guard against race conditions in abrupt GPU process termination.
if (!synchronize_requests_.empty()) {
linked_ptr<SynchronizeCallback> callback(synchronize_requests_.front());
synchronize_requests_.pop();
callback->Run();
}
}
void GpuProcessHostUIShim::OnCommandBufferCreated(const int32 route_id) {
if (!create_command_buffer_requests_.empty()) {
linked_ptr<CreateCommandBufferCallback> callback =
create_command_buffer_requests_.front();
create_command_buffer_requests_.pop();
if (route_id == MSG_ROUTING_NONE)
CreateCommandBufferError(callback.release(), route_id);
else
callback->Run(route_id);
}
}
void GpuProcessHostUIShim::OnDestroyCommandBuffer(
gfx::PluginWindowHandle window, int32 renderer_id,
int32 render_view_id) {
ViewID view_id(renderer_id, render_view_id);
ViewSurfaceMap::iterator it = acquired_surfaces_.find(view_id);
if (it != acquired_surfaces_.end())
acquired_surfaces_.erase(it);
}
void GpuProcessHostUIShim::OnGraphicsInfoCollected(const GPUInfo& gpu_info) {
gpu_data_manager_->UpdateGpuInfo(gpu_info);
}
void GpuProcessHostUIShim::OnLogMessage(int level,
const std::string& header,
const std::string& message) {
DictionaryValue* dict = new DictionaryValue();
dict->SetInteger("level", level);
dict->SetString("header", header);
dict->SetString("message", message);
gpu_data_manager_->AddLogMessage(dict);
}
#if defined(OS_LINUX) && !defined(TOUCH_UI)
void GpuProcessHostUIShim::OnResizeXID(unsigned long xid, gfx::Size size,
IPC::Message *reply_msg) {
GdkWindow* window = reinterpret_cast<GdkWindow*>(gdk_xid_table_lookup(xid));
if (window) {
Display* display = GDK_WINDOW_XDISPLAY(window);
gdk_window_resize(window, size.width(), size.height());
XSync(display, False);
}
GpuHostMsg_ResizeXID::WriteReplyParams(reply_msg, (window != NULL));
Send(reply_msg);
}
#elif defined(OS_MACOSX)
void GpuProcessHostUIShim::OnAcceleratedSurfaceSetIOSurface(
const GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params& params) {
RenderViewHost* host = RenderViewHost::FromID(params.renderer_id,
params.render_view_id);
if (!host)
return;
RenderWidgetHostView* view = host->view();
if (!view)
return;
view->AcceleratedSurfaceSetIOSurface(params.window,
params.width,
params.height,
params.identifier);
}
void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped(
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) {
RenderViewHost* host = RenderViewHost::FromID(params.renderer_id,
params.render_view_id);
if (!host)
return;
RenderWidgetHostView* view = host->view();
if (!view)
return;
view->AcceleratedSurfaceBuffersSwapped(
// Parameters needed to swap the IOSurface.
params.window,
params.surface_id,
// Parameters needed to formulate an acknowledgment.
params.renderer_id,
params.route_id,
host_id_,
params.swap_buffers_count);
}
#elif defined(OS_WIN)
void GpuProcessHostUIShim::OnScheduleComposite(int renderer_id,
int render_view_id) {
RenderViewHost* host = RenderViewHost::FromID(renderer_id,
render_view_id);
if (!host) {
return;
}
host->ScheduleComposite();
}
#endif
|