1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/compositor/browser_compositor_output_surface_proxy.h"
8 #include "content/browser/compositor/browser_compositor_output_surface.h"
9 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
10 #include "content/common/gpu/gpu_messages.h"
14 BrowserCompositorOutputSurfaceProxy::BrowserCompositorOutputSurfaceProxy(
15 IDMap
<BrowserCompositorOutputSurface
>* surface_map
)
16 : surface_map_(surface_map
),
17 connected_to_gpu_process_host_id_(0) {}
19 BrowserCompositorOutputSurfaceProxy::~BrowserCompositorOutputSurfaceProxy() {}
21 void BrowserCompositorOutputSurfaceProxy::ConnectToGpuProcessHost(
22 base::SingleThreadTaskRunner
* compositor_thread_task_runner
) {
23 BrowserGpuChannelHostFactory
* factory
=
24 BrowserGpuChannelHostFactory::instance();
26 int gpu_process_host_id
= factory
->GpuProcessHostId();
27 if (connected_to_gpu_process_host_id_
== gpu_process_host_id
)
30 const uint32 kMessagesToFilter
[] = { GpuHostMsg_UpdateVSyncParameters::ID
};
31 factory
->SetHandlerForControlMessages(
33 arraysize(kMessagesToFilter
),
34 base::Bind(&BrowserCompositorOutputSurfaceProxy::
35 OnMessageReceivedOnCompositorThread
,
37 compositor_thread_task_runner
);
38 connected_to_gpu_process_host_id_
= gpu_process_host_id
;
41 void BrowserCompositorOutputSurfaceProxy::OnMessageReceivedOnCompositorThread(
42 const IPC::Message
& message
) {
43 IPC_BEGIN_MESSAGE_MAP(BrowserCompositorOutputSurfaceProxy
, message
)
44 IPC_MESSAGE_HANDLER(GpuHostMsg_UpdateVSyncParameters
,
45 OnUpdateVSyncParametersOnCompositorThread
);
50 BrowserCompositorOutputSurfaceProxy::OnUpdateVSyncParametersOnCompositorThread(
52 base::TimeTicks timebase
,
53 base::TimeDelta interval
) {
54 BrowserCompositorOutputSurface
* surface
= surface_map_
->Lookup(surface_id
);
56 surface
->OnUpdateVSyncParametersFromGpu(timebase
, interval
);
58 } // namespace content