Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: cc/surfaces/display.cc

Issue 1304063014: cc: Plumbing for BeginFrameSource based on Surfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SurfaceAggregator tests; fix some bugs revealed by tests Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 DCHECK(scheduler_);
155 surface->AddBeginFrameSource(scheduler_->begin_frame_source_for_children());
156 }
157
158 void Display::RemoveSurface(Surface* surface) {
159 DCHECK(scheduler_);
160 surface->RemoveBeginFrameSource(
161 scheduler_->begin_frame_source_for_children());
162 }
163
153 bool Display::DrawAndSwap() { 164 bool Display::DrawAndSwap() {
154 TRACE_EVENT0("cc", "Display::DrawAndSwap"); 165 TRACE_EVENT0("cc", "Display::DrawAndSwap");
155 166
156 if (current_surface_id_.is_null()) { 167 if (current_surface_id_.is_null()) {
157 TRACE_EVENT_INSTANT0("cc", "No root surface.", TRACE_EVENT_SCOPE_THREAD); 168 TRACE_EVENT_INSTANT0("cc", "No root surface.", TRACE_EVENT_SCOPE_THREAD);
158 return false; 169 return false;
159 } 170 }
160 171
161 InitializeRenderer(); 172 InitializeRenderer();
162 if (!output_surface_) { 173 if (!output_surface_) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 338
328 if (surface_id == current_surface_id_) 339 if (surface_id == current_surface_id_)
329 UpdateRootSurfaceResourcesLocked(); 340 UpdateRootSurfaceResourcesLocked();
330 } 341 }
331 342
332 SurfaceId Display::CurrentSurfaceId() { 343 SurfaceId Display::CurrentSurfaceId() {
333 return current_surface_id_; 344 return current_surface_id_;
334 } 345 }
335 346
336 } // namespace cc 347 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698