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.h"
8 #include "base/location.h"
9 #include "base/strings/string_number_conversions.h"
10 #include "content/browser/compositor/reflector_impl.h"
11 #include "content/common/gpu/client/context_provider_command_buffer.h"
15 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
16 const scoped_refptr
<cc::ContextProvider
>& context_provider
,
17 const scoped_refptr
<ui::CompositorVSyncManager
>& vsync_manager
)
18 : OutputSurface(context_provider
),
19 vsync_manager_(vsync_manager
),
24 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
25 scoped_ptr
<cc::SoftwareOutputDevice
> software_device
,
26 const scoped_refptr
<ui::CompositorVSyncManager
>& vsync_manager
)
27 : OutputSurface(software_device
.Pass()),
28 vsync_manager_(vsync_manager
),
33 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() {
35 reflector_
->DetachFromOutputSurface();
39 vsync_manager_
->RemoveObserver(this);
42 void BrowserCompositorOutputSurface::Initialize() {
43 capabilities_
.max_frames_pending
= 1;
44 capabilities_
.adjust_deadline_for_parent
= false;
47 bool BrowserCompositorOutputSurface::BindToClient(
48 cc::OutputSurfaceClient
* client
) {
49 if (!OutputSurface::BindToClient(client
))
51 // Don't want vsync notifications until there is a client.
52 vsync_manager_
->AddObserver(this);
56 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters(
57 base::TimeTicks timebase
,
58 base::TimeDelta interval
) {
60 CommitVSyncParameters(timebase
, interval
);
63 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu(
64 base::TimeTicks timebase
,
65 base::TimeDelta interval
) {
67 vsync_manager_
->UpdateVSyncParameters(timebase
, interval
);
70 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl
* reflector
) {
71 reflector_
= reflector
;
74 } // namespace content