| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { | 49 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { |
| 50 Surface* surface = manager_->GetSurfaceForId(id_entry.first); | 50 Surface* surface = manager_->GetSurfaceForId(id_entry.first); |
| 51 if (surface) | 51 if (surface) |
| 52 surface->RunDrawCallbacks(SurfaceDrawStatus::DRAW_SKIPPED); | 52 surface->RunDrawCallbacks(SurfaceDrawStatus::DRAW_SKIPPED); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 bool Display::Initialize(scoped_ptr<OutputSurface> output_surface, | 57 bool Display::Initialize(scoped_ptr<OutputSurface> output_surface, |
| 58 DisplayScheduler* scheduler) { | 58 DisplayScheduler* scheduler) { |
| 59 // TODO(enne): register/unregister BeginFrameSource with SurfaceManager here. |
| 59 output_surface_ = std::move(output_surface); | 60 output_surface_ = std::move(output_surface); |
| 60 scheduler_ = scheduler; | 61 scheduler_ = scheduler; |
| 61 return output_surface_->BindToClient(this); | 62 return output_surface_->BindToClient(this); |
| 62 } | 63 } |
| 63 | 64 |
| 64 void Display::SetSurfaceId(SurfaceId id, float device_scale_factor) { | 65 void Display::SetSurfaceId(SurfaceId id, float device_scale_factor) { |
| 65 if (current_surface_id_ == id && device_scale_factor_ == device_scale_factor) | 66 if (current_surface_id_ == id && device_scale_factor_ == device_scale_factor) |
| 66 return; | 67 return; |
| 67 | 68 |
| 68 TRACE_EVENT0("cc", "Display::SetSurfaceId"); | 69 TRACE_EVENT0("cc", "Display::SetSurfaceId"); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 if (!renderer) | 128 if (!renderer) |
| 128 return; | 129 return; |
| 129 renderer_ = std::move(renderer); | 130 renderer_ = std::move(renderer); |
| 130 } | 131 } |
| 131 | 132 |
| 132 resource_provider_ = std::move(resource_provider); | 133 resource_provider_ = std::move(resource_provider); |
| 133 // TODO(jbauman): Outputting an incomplete quad list doesn't work when using | 134 // TODO(jbauman): Outputting an incomplete quad list doesn't work when using |
| 134 // overlays. | 135 // overlays. |
| 135 bool output_partial_list = renderer_->Capabilities().using_partial_swap && | 136 bool output_partial_list = renderer_->Capabilities().using_partial_swap && |
| 136 !output_surface_->GetOverlayCandidateValidator(); | 137 !output_surface_->GetOverlayCandidateValidator(); |
| 137 aggregator_.reset(new SurfaceAggregator( | 138 aggregator_.reset(new SurfaceAggregator(manager_, resource_provider_.get(), |
| 138 this, manager_, resource_provider_.get(), output_partial_list)); | 139 output_partial_list)); |
| 139 } | 140 } |
| 140 | 141 |
| 141 void Display::DidLoseOutputSurface() { | 142 void Display::DidLoseOutputSurface() { |
| 142 if (scheduler_) | 143 if (scheduler_) |
| 143 scheduler_->OutputSurfaceLost(); | 144 scheduler_->OutputSurfaceLost(); |
| 144 // WARNING: The client may delete the Display in this method call. Do not | 145 // WARNING: The client may delete the Display in this method call. Do not |
| 145 // make any additional references to members after this call. | 146 // make any additional references to members after this call. |
| 146 client_->OutputSurfaceLost(); | 147 client_->OutputSurfaceLost(); |
| 147 } | 148 } |
| 148 | 149 |
| 149 void Display::UpdateRootSurfaceResourcesLocked() { | 150 void Display::UpdateRootSurfaceResourcesLocked() { |
| 150 Surface* surface = manager_->GetSurfaceForId(current_surface_id_); | 151 Surface* surface = manager_->GetSurfaceForId(current_surface_id_); |
| 151 bool root_surface_resources_locked = !surface || !surface->GetEligibleFrame(); | 152 bool root_surface_resources_locked = !surface || !surface->GetEligibleFrame(); |
| 152 if (scheduler_) | 153 if (scheduler_) |
| 153 scheduler_->SetRootSurfaceResourcesLocked(root_surface_resources_locked); | 154 scheduler_->SetRootSurfaceResourcesLocked(root_surface_resources_locked); |
| 154 } | 155 } |
| 155 | 156 |
| 156 void Display::AddSurface(Surface* surface) { | |
| 157 // Checking for the output_surface ensures Display::Initialize has been | |
| 158 // called and that scheduler_ won't change its value. | |
| 159 DCHECK(output_surface_); | |
| 160 | |
| 161 // WebView's HardwareRenderer will never have a scheduler. | |
| 162 if (!scheduler_) | |
| 163 return; | |
| 164 | |
| 165 surface->AddBeginFrameSource(scheduler_->begin_frame_source_for_children()); | |
| 166 } | |
| 167 | |
| 168 void Display::RemoveSurface(Surface* surface) { | |
| 169 // Checking for the output_surface ensures Display::Initialize has been | |
| 170 // called and that scheduler_ won't change its value. | |
| 171 DCHECK(output_surface_); | |
| 172 | |
| 173 // WebView's HardwareRenderer will never have a scheduler. | |
| 174 if (!scheduler_) | |
| 175 return; | |
| 176 | |
| 177 surface->RemoveBeginFrameSource( | |
| 178 scheduler_->begin_frame_source_for_children()); | |
| 179 } | |
| 180 | |
| 181 bool Display::DrawAndSwap() { | 157 bool Display::DrawAndSwap() { |
| 182 TRACE_EVENT0("cc", "Display::DrawAndSwap"); | 158 TRACE_EVENT0("cc", "Display::DrawAndSwap"); |
| 183 | 159 |
| 184 if (current_surface_id_.is_null()) { | 160 if (current_surface_id_.is_null()) { |
| 185 TRACE_EVENT_INSTANT0("cc", "No root surface.", TRACE_EVENT_SCOPE_THREAD); | 161 TRACE_EVENT_INSTANT0("cc", "No root surface.", TRACE_EVENT_SCOPE_THREAD); |
| 186 return false; | 162 return false; |
| 187 } | 163 } |
| 188 | 164 |
| 189 InitializeRenderer(); | 165 InitializeRenderer(); |
| 190 if (!output_surface_) { | 166 if (!output_surface_) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 | 339 |
| 364 if (surface_id == current_surface_id_) | 340 if (surface_id == current_surface_id_) |
| 365 UpdateRootSurfaceResourcesLocked(); | 341 UpdateRootSurfaceResourcesLocked(); |
| 366 } | 342 } |
| 367 | 343 |
| 368 SurfaceId Display::CurrentSurfaceId() { | 344 SurfaceId Display::CurrentSurfaceId() { |
| 369 return current_surface_id_; | 345 return current_surface_id_; |
| 370 } | 346 } |
| 371 | 347 |
| 372 } // namespace cc | 348 } // namespace cc |
| OLD | NEW |