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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 Display::~Display() { | 46 Display::~Display() { |
47 manager_->RemoveObserver(this); | 47 manager_->RemoveObserver(this); |
48 if (aggregator_) { | 48 if (aggregator_) { |
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 // TODO(enne): unregister begin frame source |
| 56 // manager_->SetBeginFrameSourceForNamespace(display_client_namespace, |
| 57 // nullptr); |
55 } | 58 } |
56 | 59 |
57 bool Display::Initialize(scoped_ptr<OutputSurface> output_surface, | 60 bool Display::Initialize(scoped_ptr<OutputSurface> output_surface, |
58 DisplayScheduler* scheduler) { | 61 DisplayScheduler* scheduler) { |
| 62 // TODO(enne): Register begin frame source (maybe have DisplayClient do this?) |
| 63 // manager_->SetBeginFrameSourceForNamespace(display_client_namespace, |
| 64 // scheduler_->begin_frame_source_for_children()); |
59 output_surface_ = std::move(output_surface); | 65 output_surface_ = std::move(output_surface); |
60 scheduler_ = scheduler; | 66 scheduler_ = scheduler; |
61 return output_surface_->BindToClient(this); | 67 return output_surface_->BindToClient(this); |
62 } | 68 } |
63 | 69 |
64 void Display::SetSurfaceId(SurfaceId id, float device_scale_factor) { | 70 void Display::SetSurfaceId(SurfaceId id, float device_scale_factor) { |
65 if (current_surface_id_ == id && device_scale_factor_ == device_scale_factor) | 71 if (current_surface_id_ == id && device_scale_factor_ == device_scale_factor) |
66 return; | 72 return; |
67 | 73 |
68 TRACE_EVENT0("cc", "Display::SetSurfaceId"); | 74 TRACE_EVENT0("cc", "Display::SetSurfaceId"); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 if (!renderer) | 133 if (!renderer) |
128 return; | 134 return; |
129 renderer_ = std::move(renderer); | 135 renderer_ = std::move(renderer); |
130 } | 136 } |
131 | 137 |
132 resource_provider_ = std::move(resource_provider); | 138 resource_provider_ = std::move(resource_provider); |
133 // TODO(jbauman): Outputting an incomplete quad list doesn't work when using | 139 // TODO(jbauman): Outputting an incomplete quad list doesn't work when using |
134 // overlays. | 140 // overlays. |
135 bool output_partial_list = renderer_->Capabilities().using_partial_swap && | 141 bool output_partial_list = renderer_->Capabilities().using_partial_swap && |
136 !output_surface_->GetOverlayCandidateValidator(); | 142 !output_surface_->GetOverlayCandidateValidator(); |
137 aggregator_.reset(new SurfaceAggregator( | 143 aggregator_.reset(new SurfaceAggregator(manager_, resource_provider_.get(), |
138 this, manager_, resource_provider_.get(), output_partial_list)); | 144 output_partial_list)); |
139 } | 145 } |
140 | 146 |
141 void Display::DidLoseOutputSurface() { | 147 void Display::DidLoseOutputSurface() { |
142 if (scheduler_) | 148 if (scheduler_) |
143 scheduler_->OutputSurfaceLost(); | 149 scheduler_->OutputSurfaceLost(); |
144 // WARNING: The client may delete the Display in this method call. Do not | 150 // WARNING: The client may delete the Display in this method call. Do not |
145 // make any additional references to members after this call. | 151 // make any additional references to members after this call. |
146 client_->OutputSurfaceLost(); | 152 client_->OutputSurfaceLost(); |
147 } | 153 } |
148 | 154 |
149 void Display::UpdateRootSurfaceResourcesLocked() { | 155 void Display::UpdateRootSurfaceResourcesLocked() { |
150 Surface* surface = manager_->GetSurfaceForId(current_surface_id_); | 156 Surface* surface = manager_->GetSurfaceForId(current_surface_id_); |
151 bool root_surface_resources_locked = !surface || !surface->GetEligibleFrame(); | 157 bool root_surface_resources_locked = !surface || !surface->GetEligibleFrame(); |
152 if (scheduler_) | 158 if (scheduler_) |
153 scheduler_->SetRootSurfaceResourcesLocked(root_surface_resources_locked); | 159 scheduler_->SetRootSurfaceResourcesLocked(root_surface_resources_locked); |
154 } | 160 } |
155 | 161 |
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() { | 162 bool Display::DrawAndSwap() { |
182 TRACE_EVENT0("cc", "Display::DrawAndSwap"); | 163 TRACE_EVENT0("cc", "Display::DrawAndSwap"); |
183 | 164 |
184 if (current_surface_id_.is_null()) { | 165 if (current_surface_id_.is_null()) { |
185 TRACE_EVENT_INSTANT0("cc", "No root surface.", TRACE_EVENT_SCOPE_THREAD); | 166 TRACE_EVENT_INSTANT0("cc", "No root surface.", TRACE_EVENT_SCOPE_THREAD); |
186 return false; | 167 return false; |
187 } | 168 } |
188 | 169 |
189 InitializeRenderer(); | 170 InitializeRenderer(); |
190 if (!output_surface_) { | 171 if (!output_surface_) { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 345 |
365 if (surface_id == current_surface_id_) | 346 if (surface_id == current_surface_id_) |
366 UpdateRootSurfaceResourcesLocked(); | 347 UpdateRootSurfaceResourcesLocked(); |
367 } | 348 } |
368 | 349 |
369 SurfaceId Display::CurrentSurfaceId() { | 350 SurfaceId Display::CurrentSurfaceId() { |
370 return current_surface_id_; | 351 return current_surface_id_; |
371 } | 352 } |
372 | 353 |
373 } // namespace cc | 354 } // namespace cc |
OLD | NEW |