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/software_browser_compositor_output_surface.h"
7 #include "base/memory/ref_counted.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/time/time.h"
10 #include "cc/output/compositor_frame.h"
11 #include "cc/output/output_surface_client.h"
12 #include "cc/output/software_output_device.h"
13 #include "content/browser/compositor/browser_compositor_output_surface_proxy.h"
14 #include "content/browser/renderer_host/render_widget_host_impl.h"
15 #include "ui/events/latency_info.h"
16 #include "ui/gfx/vsync_provider.h"
20 SoftwareBrowserCompositorOutputSurface::SoftwareBrowserCompositorOutputSurface(
21 scoped_refptr
<BrowserCompositorOutputSurfaceProxy
> surface_proxy
,
22 scoped_ptr
<cc::SoftwareOutputDevice
> software_device
,
24 IDMap
<BrowserCompositorOutputSurface
>* output_surface_map
,
25 const scoped_refptr
<ui::CompositorVSyncManager
>& vsync_manager
)
26 : BrowserCompositorOutputSurface(software_device
.Pass(),
30 output_surface_proxy_(surface_proxy
) {}
32 SoftwareBrowserCompositorOutputSurface::
33 ~SoftwareBrowserCompositorOutputSurface() {}
35 void SoftwareBrowserCompositorOutputSurface::SwapBuffers(
36 cc::CompositorFrame
* frame
) {
37 for (size_t i
= 0; i
< frame
->metadata
.latency_info
.size(); i
++) {
38 frame
->metadata
.latency_info
[i
].AddLatencyNumber(
39 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT
, 0, 0);
41 base::MessageLoop::current()->PostTask(
44 &RenderWidgetHostImpl::CompositorFrameDrawn
,
45 frame
->metadata
.latency_info
));
47 gfx::VSyncProvider
* vsync_provider
= software_device()->GetVSyncProvider();
49 vsync_provider
->GetVSyncParameters(
50 base::Bind(&BrowserCompositorOutputSurfaceProxy::
51 OnUpdateVSyncParametersOnCompositorThread
,
52 output_surface_proxy_
,
55 PostSwapBuffersComplete();
56 client_
->DidSwapBuffers();
59 #if defined(OS_MACOSX)
60 void SoftwareBrowserCompositorOutputSurface::OnSurfaceDisplayed() {
61 // See GpuBrowserCompositorOutputSurface for when and how this is used.
62 NOTREACHED() << "Not expected for software surfaces.";
66 } // namespace content