Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / browser / compositor / browser_compositor_output_surface.cc
blob6839457196ed4eb2fccdf4c621ad2054e5a00b47
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"
7 #include "base/bind.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"
14 namespace content {
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),
23 reflector_(nullptr) {
24 overlay_candidate_validator_ = overlay_candidate_validator.Pass();
25 Initialize();
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),
33 reflector_(nullptr) {
34 Initialize();
37 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() {
38 if (reflector_)
39 reflector_->DetachFromOutputSurface();
40 DCHECK(!reflector_);
41 if (!HasClient())
42 return;
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))
54 return false;
55 // Don't want vsync notifications until there is a client.
56 vsync_manager_->AddObserver(this);
57 return true;
60 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters(
61 base::TimeTicks timebase,
62 base::TimeDelta interval) {
63 DCHECK(HasClient());
64 CommitVSyncParameters(timebase, interval);
67 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu(
68 base::TimeTicks timebase,
69 base::TimeDelta interval) {
70 DCHECK(HasClient());
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