Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/surfaces/onscreen_display_client.h" | 5 #include "cc/surfaces/onscreen_display_client.h" |
| 6 | 6 |
| 7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
| 8 #include "cc/output/output_surface.h" | 8 #include "cc/output/output_surface.h" |
| 9 #include "cc/scheduler/begin_frame_source.h" | 9 #include "cc/scheduler/begin_frame_source.h" |
| 10 #include "cc/surfaces/display_scheduler.h" | 10 #include "cc/surfaces/display_scheduler.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 bitmap_manager, | 28 bitmap_manager, |
| 29 gpu_memory_buffer_manager, | 29 gpu_memory_buffer_manager, |
| 30 settings)), | 30 settings)), |
| 31 output_surface_lost_(false), | 31 output_surface_lost_(false), |
| 32 disable_display_vsync_(settings.disable_display_vsync) {} | 32 disable_display_vsync_(settings.disable_display_vsync) {} |
| 33 | 33 |
| 34 OnscreenDisplayClient::~OnscreenDisplayClient() { | 34 OnscreenDisplayClient::~OnscreenDisplayClient() { |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool OnscreenDisplayClient::Initialize() { | 37 bool OnscreenDisplayClient::Initialize() { |
| 38 int max_frames_pending = | 38 DCHECK(output_surface_); |
|
brianderson
2015/11/13 20:40:41
+jbauman: Is this DCHECK valid?
| |
| 39 output_surface_ ? output_surface_->capabilities().max_frames_pending : 0; | |
| 40 if (max_frames_pending <= 0) | |
| 41 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; | |
| 42 | 39 |
| 43 BeginFrameSource* frame_source; | 40 BeginFrameSource* frame_source; |
| 44 if (disable_display_vsync_) { | 41 if (disable_display_vsync_) { |
| 45 unthrottled_frame_source_ = | 42 unthrottled_frame_source_ = |
| 46 BackToBackBeginFrameSource::Create(task_runner_.get()); | 43 BackToBackBeginFrameSource::Create(task_runner_.get()); |
| 47 frame_source = unthrottled_frame_source_.get(); | 44 frame_source = unthrottled_frame_source_.get(); |
| 48 } else { | 45 } else { |
| 49 synthetic_frame_source_ = SyntheticBeginFrameSource::Create( | 46 synthetic_frame_source_ = SyntheticBeginFrameSource::Create( |
| 50 task_runner_.get(), BeginFrameArgs::DefaultInterval()); | 47 task_runner_.get(), BeginFrameArgs::DefaultInterval()); |
| 51 frame_source = synthetic_frame_source_.get(); | 48 frame_source = synthetic_frame_source_.get(); |
| 52 } | 49 } |
| 53 | 50 |
| 54 scheduler_.reset(new DisplayScheduler( | 51 scheduler_.reset( |
| 55 display_.get(), frame_source, task_runner_.get(), max_frames_pending)); | 52 new DisplayScheduler(display_.get(), frame_source, task_runner_.get(), |
| 53 output_surface_->capabilities().max_frames_pending)); | |
| 56 | 54 |
| 57 return display_->Initialize(output_surface_.Pass(), scheduler_.get()); | 55 return display_->Initialize(output_surface_.Pass(), scheduler_.get()); |
| 58 } | 56 } |
| 59 | 57 |
| 60 void OnscreenDisplayClient::CommitVSyncParameters(base::TimeTicks timebase, | 58 void OnscreenDisplayClient::CommitVSyncParameters(base::TimeTicks timebase, |
| 61 base::TimeDelta interval) { | 59 base::TimeDelta interval) { |
| 62 if (interval == base::TimeDelta()) { | 60 if (interval == base::TimeDelta()) { |
| 63 // TODO(brianderson): We should not be receiving 0 intervals. | 61 // TODO(brianderson): We should not be receiving 0 intervals. |
| 64 interval = BeginFrameArgs::DefaultInterval(); | 62 interval = BeginFrameArgs::DefaultInterval(); |
| 65 } | 63 } |
| 66 | 64 |
| 67 surface_display_output_surface_->ReceivedVSyncParameters(timebase, interval); | 65 surface_display_output_surface_->ReceivedVSyncParameters(timebase, interval); |
| 68 if (synthetic_frame_source_.get()) | 66 if (synthetic_frame_source_.get()) |
| 69 synthetic_frame_source_->OnUpdateVSyncParameters(timebase, interval); | 67 synthetic_frame_source_->OnUpdateVSyncParameters(timebase, interval); |
| 70 } | 68 } |
| 71 | 69 |
| 72 void OnscreenDisplayClient::OutputSurfaceLost() { | 70 void OnscreenDisplayClient::OutputSurfaceLost() { |
| 73 output_surface_lost_ = true; | 71 output_surface_lost_ = true; |
| 74 surface_display_output_surface_->DidLoseOutputSurface(); | 72 surface_display_output_surface_->DidLoseOutputSurface(); |
| 75 } | 73 } |
| 76 | 74 |
| 77 void OnscreenDisplayClient::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { | 75 void OnscreenDisplayClient::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { |
| 78 surface_display_output_surface_->SetMemoryPolicy(policy); | 76 surface_display_output_surface_->SetMemoryPolicy(policy); |
| 79 } | 77 } |
| 80 | 78 |
| 81 } // namespace cc | 79 } // namespace cc |
| OLD | NEW |