Vectorize website settings icons in omnibox
[chromium-blink-merge.git] / cc / surfaces / onscreen_display_client.cc
blob29a2a7a8ab236c70fb9580e786cc353de2030a7d
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 "cc/surfaces/onscreen_display_client.h"
7 #include "base/trace_event/trace_event.h"
8 #include "cc/output/output_surface.h"
9 #include "cc/scheduler/begin_frame_source.h"
10 #include "cc/surfaces/display_scheduler.h"
11 #include "cc/surfaces/surface_display_output_surface.h"
12 #include "cc/surfaces/surface_factory.h"
13 #include "cc/surfaces/surface_manager.h"
15 namespace cc {
17 OnscreenDisplayClient::OnscreenDisplayClient(
18 scoped_ptr<OutputSurface> output_surface,
19 SurfaceManager* manager,
20 SharedBitmapManager* bitmap_manager,
21 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
22 const RendererSettings& settings,
23 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
24 : output_surface_(output_surface.Pass()),
25 display_(new Display(this,
26 manager,
27 bitmap_manager,
28 gpu_memory_buffer_manager,
29 settings)),
30 task_runner_(task_runner),
31 output_surface_lost_(false),
32 disable_display_vsync_(settings.disable_display_vsync) {
35 OnscreenDisplayClient::~OnscreenDisplayClient() {
38 bool OnscreenDisplayClient::Initialize() {
39 int max_frames_pending =
40 output_surface_ ? output_surface_->capabilities().max_frames_pending : 0;
41 if (max_frames_pending <= 0)
42 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING;
44 BeginFrameSource* frame_source;
45 if (disable_display_vsync_) {
46 unthrottled_frame_source_ =
47 BackToBackBeginFrameSource::Create(task_runner_.get());
48 frame_source = unthrottled_frame_source_.get();
49 } else {
50 synthetic_frame_source_ = SyntheticBeginFrameSource::Create(
51 task_runner_.get(), BeginFrameArgs::DefaultInterval());
52 frame_source = synthetic_frame_source_.get();
55 scheduler_.reset(new DisplayScheduler(
56 display_.get(), frame_source, task_runner_.get(), max_frames_pending));
58 return display_->Initialize(output_surface_.Pass(), scheduler_.get());
61 void OnscreenDisplayClient::CommitVSyncParameters(base::TimeTicks timebase,
62 base::TimeDelta interval) {
63 if (interval == base::TimeDelta()) {
64 // TODO(brianderson): We should not be receiving 0 intervals.
65 interval = BeginFrameArgs::DefaultInterval();
68 surface_display_output_surface_->ReceivedVSyncParameters(timebase, interval);
69 if (synthetic_frame_source_.get())
70 synthetic_frame_source_->OnUpdateVSyncParameters(timebase, interval);
73 void OnscreenDisplayClient::OutputSurfaceLost() {
74 output_surface_lost_ = true;
75 surface_display_output_surface_->DidLoseOutputSurface();
78 void OnscreenDisplayClient::SetMemoryPolicy(const ManagedMemoryPolicy& policy) {
79 surface_display_output_surface_->SetMemoryPolicy(policy);
82 } // namespace cc