| 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 // WebView's HardwareRenderer will never have a scheduler. |
| 159 if (!scheduler_) |
| 160 return; |
| 161 |
| 162 surface->AddBeginFrameSource(scheduler_->begin_frame_source_for_children()); |
| 163 } |
| 164 |
| 165 void Display::RemoveSurface(Surface* surface) { |
| 166 // Checking for the output_surface ensures Display::Initialize has been |
| 167 // called and that scheduler_ won't change its value. |
| 168 DCHECK(output_surface_); |
| 169 |
| 170 // WebView's HardwareRenderer will never have a scheduler. |
| 171 if (!scheduler_) |
| 172 return; |
| 173 |
| 174 surface->RemoveBeginFrameSource( |
| 175 scheduler_->begin_frame_source_for_children()); |
| 176 } |
| 177 |
| 153 bool Display::DrawAndSwap() { | 178 bool Display::DrawAndSwap() { |
| 154 TRACE_EVENT0("cc", "Display::DrawAndSwap"); | 179 TRACE_EVENT0("cc", "Display::DrawAndSwap"); |
| 155 | 180 |
| 156 if (current_surface_id_.is_null()) { | 181 if (current_surface_id_.is_null()) { |
| 157 TRACE_EVENT_INSTANT0("cc", "No root surface.", TRACE_EVENT_SCOPE_THREAD); | 182 TRACE_EVENT_INSTANT0("cc", "No root surface.", TRACE_EVENT_SCOPE_THREAD); |
| 158 return false; | 183 return false; |
| 159 } | 184 } |
| 160 | 185 |
| 161 InitializeRenderer(); | 186 InitializeRenderer(); |
| 162 if (!output_surface_) { | 187 if (!output_surface_) { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 352 |
| 328 if (surface_id == current_surface_id_) | 353 if (surface_id == current_surface_id_) |
| 329 UpdateRootSurfaceResourcesLocked(); | 354 UpdateRootSurfaceResourcesLocked(); |
| 330 } | 355 } |
| 331 | 356 |
| 332 SurfaceId Display::CurrentSurfaceId() { | 357 SurfaceId Display::CurrentSurfaceId() { |
| 333 return current_surface_id_; | 358 return current_surface_id_; |
| 334 } | 359 } |
| 335 | 360 |
| 336 } // namespace cc | 361 } // namespace cc |
| OLD | NEW |