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/browser_compositor_overlay_candidate_validator.h"
11 #include "content/browser/compositor/reflector_impl.h"
12 #include "content/common/gpu/client/context_provider_command_buffer.h"
16 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
17 const scoped_refptr
<cc::ContextProvider
>& context_provider
,
18 const scoped_refptr
<ui::CompositorVSyncManager
>& vsync_manager
,
19 scoped_ptr
<BrowserCompositorOverlayCandidateValidator
>
20 overlay_candidate_validator
)
21 : OutputSurface(context_provider
),
22 vsync_manager_(vsync_manager
),
24 overlay_candidate_validator_
= overlay_candidate_validator
.Pass();
28 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
29 scoped_ptr
<cc::SoftwareOutputDevice
> software_device
,
30 const scoped_refptr
<ui::CompositorVSyncManager
>& vsync_manager
)
31 : OutputSurface(software_device
.Pass()),
32 vsync_manager_(vsync_manager
),
37 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() {
39 reflector_
->DetachFromOutputSurface();
43 vsync_manager_
->RemoveObserver(this);
46 void BrowserCompositorOutputSurface::Initialize() {
47 capabilities_
.max_frames_pending
= 1;
48 capabilities_
.adjust_deadline_for_parent
= false;
51 bool BrowserCompositorOutputSurface::BindToClient(
52 cc::OutputSurfaceClient
* client
) {
53 if (!OutputSurface::BindToClient(client
))
55 // Don't want vsync notifications until there is a client.
56 vsync_manager_
->AddObserver(this);
60 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters(
61 base::TimeTicks timebase
,
62 base::TimeDelta interval
) {
64 CommitVSyncParameters(timebase
, interval
);
67 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu(
68 base::TimeTicks timebase
,
69 base::TimeDelta interval
) {
71 vsync_manager_
->UpdateVSyncParameters(timebase
, interval
);
74 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl
* reflector
) {
75 // Software mirroring is done by doing a GL copy out of the framebuffer - if
76 // we have overlays then that data will be missing.
77 if (overlay_candidate_validator_
) {
78 overlay_candidate_validator_
->SetSoftwareMirrorMode(reflector
!= nullptr);
80 reflector_
= reflector
;
83 cc::OverlayCandidateValidator
*
84 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const {
85 return overlay_candidate_validator_
.get();
88 } // namespace content