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/display.h" | 5 #include "cc/surfaces/display.h" |
| 6 | 6 |
| 7 #include "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "cc/debug/benchmark_instrumentation.h" | 9 #include "cc/debug/benchmark_instrumentation.h" |
| 10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 if (!renderer) | 124 if (!renderer) |
| 125 return; | 125 return; |
| 126 renderer_ = renderer.Pass(); | 126 renderer_ = renderer.Pass(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 resource_provider_ = resource_provider.Pass(); | 129 resource_provider_ = resource_provider.Pass(); |
| 130 // TODO(jbauman): Outputting an incomplete quad list doesn't work when using | 130 // TODO(jbauman): Outputting an incomplete quad list doesn't work when using |
| 131 // overlays. | 131 // overlays. |
| 132 bool output_partial_list = renderer_->Capabilities().using_partial_swap && | 132 bool output_partial_list = renderer_->Capabilities().using_partial_swap && |
| 133 !output_surface_->GetOverlayCandidateValidator(); | 133 !output_surface_->GetOverlayCandidateValidator(); |
| 134 aggregator_.reset(new SurfaceAggregator(manager_, resource_provider_.get(), | 134 aggregator_.reset(new SurfaceAggregator( |
| 135 output_partial_list)); | 135 this, manager_, resource_provider_.get(), output_partial_list)); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void Display::DidLoseOutputSurface() { | 138 void Display::DidLoseOutputSurface() { |
| 139 if (scheduler_) | 139 if (scheduler_) |
| 140 scheduler_->OutputSurfaceLost(); | 140 scheduler_->OutputSurfaceLost(); |
| 141 // WARNING: The client may delete the Display in this method call. Do not | 141 // WARNING: The client may delete the Display in this method call. Do not |
| 142 // make any additional references to members after this call. | 142 // make any additional references to members after this call. |
| 143 client_->OutputSurfaceLost(); | 143 client_->OutputSurfaceLost(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void Display::UpdateRootSurfaceResourcesLocked() { | 146 void Display::UpdateRootSurfaceResourcesLocked() { |
| 147 Surface* surface = manager_->GetSurfaceForId(current_surface_id_); | 147 Surface* surface = manager_->GetSurfaceForId(current_surface_id_); |
| 148 bool root_surface_resources_locked = !surface || !surface->GetEligibleFrame(); | 148 bool root_surface_resources_locked = !surface || !surface->GetEligibleFrame(); |
| 149 if (scheduler_) | 149 if (scheduler_) |
| 150 scheduler_->SetRootSurfaceResourcesLocked(root_surface_resources_locked); | 150 scheduler_->SetRootSurfaceResourcesLocked(root_surface_resources_locked); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void Display::AddSurface(Surface* surface) { | |
| 154 // Checking for the output_surface ensures Display::Initialize has been | |
| 155 // called and that scheduler_ won't change its value. | |
| 156 DCHECK(output_surface_); | |
| 157 | |
| 158 // TODO(brianderson): Make sure all users of Display provide a | |
| 159 // DisplayScheduler. crbug.com/476676 | |
|
mithro-old
2015/10/01 03:00:23
nit: Can you put http:// before this URL so it bec
brianderson
2015/10/07 20:54:48
Done.
| |
| 160 if (!scheduler_) | |
| 161 return; | |
| 162 | |
| 163 surface->AddBeginFrameSource(scheduler_->begin_frame_source_for_children()); | |
| 164 } | |
| 165 | |
| 166 void Display::RemoveSurface(Surface* surface) { | |
| 167 // Checking for the output_surface ensures Display::Initialize has been | |
| 168 // called and that scheduler_ won't change its value. | |
| 169 DCHECK(output_surface_); | |
| 170 | |
| 171 // TODO(brianderson): Make sure all users of Display provide a | |
| 172 // DisplayScheduler. crbug.com/476676 | |
| 173 if (!scheduler_) | |
| 174 return; | |
| 175 | |
| 176 surface->RemoveBeginFrameSource( | |
| 177 scheduler_->begin_frame_source_for_children()); | |
| 178 } | |
| 179 | |
| 153 bool Display::DrawAndSwap() { | 180 bool Display::DrawAndSwap() { |
| 154 TRACE_EVENT0("cc", "Display::DrawAndSwap"); | 181 TRACE_EVENT0("cc", "Display::DrawAndSwap"); |
| 155 | 182 |
| 156 if (current_surface_id_.is_null()) { | 183 if (current_surface_id_.is_null()) { |
| 157 TRACE_EVENT_INSTANT0("cc", "No root surface.", TRACE_EVENT_SCOPE_THREAD); | 184 TRACE_EVENT_INSTANT0("cc", "No root surface.", TRACE_EVENT_SCOPE_THREAD); |
| 158 return false; | 185 return false; |
| 159 } | 186 } |
| 160 | 187 |
| 161 InitializeRenderer(); | 188 InitializeRenderer(); |
| 162 if (!output_surface_) { | 189 if (!output_surface_) { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 | 354 |
| 328 if (surface_id == current_surface_id_) | 355 if (surface_id == current_surface_id_) |
| 329 UpdateRootSurfaceResourcesLocked(); | 356 UpdateRootSurfaceResourcesLocked(); |
| 330 } | 357 } |
| 331 | 358 |
| 332 SurfaceId Display::CurrentSurfaceId() { | 359 SurfaceId Display::CurrentSurfaceId() { |
| 333 return current_surface_id_; | 360 return current_surface_id_; |
| 334 } | 361 } |
| 335 | 362 |
| 336 } // namespace cc | 363 } // namespace cc |
| OLD | NEW |