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

Side by Side Diff: ui/compositor/compositor.cc

Issue 808003002: Fix compositor integration in ui/compositor (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « ui/compositor/compositor.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/compositor/compositor.h" 5 #include "ui/compositor/compositor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 if (root_layer_) 196 if (root_layer_)
197 root_layer_->SetCompositor(NULL); 197 root_layer_->SetCompositor(NULL);
198 198
199 // Stop all outstanding draws before telling the ContextFactory to tear 199 // Stop all outstanding draws before telling the ContextFactory to tear
200 // down any contexts that the |host_| may rely upon. 200 // down any contexts that the |host_| may rely upon.
201 host_.reset(); 201 host_.reset();
202 202
203 context_factory_->RemoveCompositor(this); 203 context_factory_->RemoveCompositor(this);
204 } 204 }
205 205
206 void Compositor::SetOutputSurface(scoped_ptr<cc::OutputSurface> surface) {
207 host_->SetOutputSurface(surface.Pass());
208 }
209
206 void Compositor::ScheduleDraw() { 210 void Compositor::ScheduleDraw() {
207 if (compositor_thread_loop_.get()) { 211 if (compositor_thread_loop_.get()) {
208 host_->SetNeedsCommit(); 212 host_->SetNeedsCommit();
209 } else if (!defer_draw_scheduling_) { 213 } else if (!defer_draw_scheduling_) {
210 defer_draw_scheduling_ = true; 214 defer_draw_scheduling_ = true;
211 task_runner_->PostTask( 215 task_runner_->PostTask(
212 FROM_HERE, 216 FROM_HERE,
213 base::Bind(&Compositor::Draw, weak_ptr_factory_.GetWeakPtr())); 217 base::Bind(&Compositor::Draw, weak_ptr_factory_.GetWeakPtr()));
214 } 218 }
215 } 219 }
216 220
217 void Compositor::DidInitializeOutputSurface() { 221 void Compositor::DidInitializeOutputSurface() {
218 num_failed_recreate_attempts_ = 0;
219 } 222 }
220 223
221 void Compositor::DidFailToInitializeOutputSurface() { 224 void Compositor::DidFailToInitializeOutputSurface() {
222 num_failed_recreate_attempts_++; 225 NOTREACHED() << "We don't support fallback";
223
224 // Tolerate a certain number of recreation failures to work around races
225 // in the output-surface-lost machinery.
226 if (num_failed_recreate_attempts_ >= MAX_OUTPUT_SURFACE_RETRIES)
227 LOG(FATAL) << "Failed to create a fallback OutputSurface.";
228
229 base::MessageLoop::current()->PostTask(
230 FROM_HERE, base::Bind(&Compositor::RequestNewOutputSurface,
231 weak_ptr_factory_.GetWeakPtr()));
232 } 226 }
233 227
234 void Compositor::SetRootLayer(Layer* root_layer) { 228 void Compositor::SetRootLayer(Layer* root_layer) {
235 if (root_layer_ == root_layer) 229 if (root_layer_ == root_layer)
236 return; 230 return;
237 if (root_layer_) 231 if (root_layer_)
238 root_layer_->SetCompositor(NULL); 232 root_layer_->SetCompositor(NULL);
239 root_layer_ = root_layer; 233 root_layer_ = root_layer;
240 if (root_layer_ && !root_layer_->GetCompositor()) 234 if (root_layer_ && !root_layer_->GetCompositor())
241 root_layer_->SetCompositor(this); 235 root_layer_->SetCompositor(this);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 void Compositor::Layout() { 372 void Compositor::Layout() {
379 // We're sending damage that will be addressed during this composite 373 // We're sending damage that will be addressed during this composite
380 // cycle, so we don't need to schedule another composite to address it. 374 // cycle, so we don't need to schedule another composite to address it.
381 disable_schedule_composite_ = true; 375 disable_schedule_composite_ = true;
382 if (root_layer_) 376 if (root_layer_)
383 root_layer_->SendDamagedRects(); 377 root_layer_->SendDamagedRects();
384 disable_schedule_composite_ = false; 378 disable_schedule_composite_ = false;
385 } 379 }
386 380
387 void Compositor::RequestNewOutputSurface() { 381 void Compositor::RequestNewOutputSurface() {
388 bool fallback = 382 bool fallback = false;
389 num_failed_recreate_attempts_ >= OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK; 383 context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr(),
390 context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr().get(),
391 fallback); 384 fallback);
392 } 385 }
393 386
394 void Compositor::DidCommit() { 387 void Compositor::DidCommit() {
395 DCHECK(!IsLocked()); 388 DCHECK(!IsLocked());
396 FOR_EACH_OBSERVER(CompositorObserver, 389 FOR_EACH_OBSERVER(CompositorObserver,
397 observer_list_, 390 observer_list_,
398 OnCompositingDidCommit(this)); 391 OnCompositingDidCommit(this));
399 } 392 }
400 393
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 // Call ScheduleDraw() instead of Draw() in order to allow other 492 // Call ScheduleDraw() instead of Draw() in order to allow other
500 // CompositorObservers to be notified before starting another 493 // CompositorObservers to be notified before starting another
501 // draw cycle. 494 // draw cycle.
502 ScheduleDraw(); 495 ScheduleDraw();
503 } 496 }
504 FOR_EACH_OBSERVER( 497 FOR_EACH_OBSERVER(
505 CompositorObserver, observer_list_, OnCompositingEnded(this)); 498 CompositorObserver, observer_list_, OnCompositingEnded(this));
506 } 499 }
507 500
508 } // namespace ui 501 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/compositor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698