Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 69 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
| 70 : context_factory_(context_factory), | 70 : context_factory_(context_factory), |
| 71 root_layer_(NULL), | 71 root_layer_(NULL), |
| 72 widget_(widget), | 72 widget_(widget), |
| 73 surface_id_allocator_(context_factory->CreateSurfaceIdAllocator()), | 73 surface_id_allocator_(context_factory->CreateSurfaceIdAllocator()), |
| 74 task_runner_(task_runner), | 74 task_runner_(task_runner), |
| 75 vsync_manager_(new CompositorVSyncManager()), | 75 vsync_manager_(new CompositorVSyncManager()), |
| 76 device_scale_factor_(0.0f), | 76 device_scale_factor_(0.0f), |
| 77 last_started_frame_(0), | 77 last_started_frame_(0), |
| 78 last_ended_frame_(0), | 78 last_ended_frame_(0), |
| 79 num_failed_recreate_attempts_(0), | |
| 80 disable_schedule_composite_(false), | 79 disable_schedule_composite_(false), |
| 81 compositor_lock_(NULL), | 80 compositor_lock_(NULL), |
| 82 layer_animator_collection_(this), | 81 layer_animator_collection_(this), |
| 83 weak_ptr_factory_(this) { | 82 weak_ptr_factory_(this) { |
| 84 root_web_layer_ = cc::Layer::Create(); | 83 root_web_layer_ = cc::Layer::Create(); |
| 85 | 84 |
| 86 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 85 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 87 | 86 |
| 88 cc::LayerTreeSettings settings; | 87 cc::LayerTreeSettings settings; |
| 89 // When impl-side painting is enabled, this will ensure PictureLayers always | 88 // When impl-side painting is enabled, this will ensure PictureLayers always |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 void Compositor::Layout() { | 294 void Compositor::Layout() { |
| 296 // We're sending damage that will be addressed during this composite | 295 // We're sending damage that will be addressed during this composite |
| 297 // cycle, so we don't need to schedule another composite to address it. | 296 // cycle, so we don't need to schedule another composite to address it. |
| 298 disable_schedule_composite_ = true; | 297 disable_schedule_composite_ = true; |
| 299 if (root_layer_) | 298 if (root_layer_) |
| 300 root_layer_->SendDamagedRects(); | 299 root_layer_->SendDamagedRects(); |
| 301 disable_schedule_composite_ = false; | 300 disable_schedule_composite_ = false; |
| 302 } | 301 } |
| 303 | 302 |
| 304 void Compositor::RequestNewOutputSurface() { | 303 void Compositor::RequestNewOutputSurface() { |
| 305 bool fallback = | 304 context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr()); |
| 306 num_failed_recreate_attempts_ >= OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK; | |
| 307 context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr(), | |
| 308 fallback); | |
| 309 } | 305 } |
| 310 | 306 |
| 311 void Compositor::DidInitializeOutputSurface() { | 307 void Compositor::DidInitializeOutputSurface() { |
| 312 num_failed_recreate_attempts_ = 0; | |
| 313 } | 308 } |
| 314 | 309 |
| 315 void Compositor::DidFailToInitializeOutputSurface() { | 310 void Compositor::DidFailToInitializeOutputSurface() { |
| 316 num_failed_recreate_attempts_++; | 311 // The OutputSurface should already be bound/initialized before being given to |
| 317 | 312 // the Compositor. |
| 318 // Tolerate a certain number of recreation failures to work around races | 313 NOTREACHED(); |
|
no sievers
2015/02/25 01:51:00
Although there is also |worker_context_provider_|
enne (OOO)
2015/02/25 19:37:33
I think it'd be fine to document that this can onl
no sievers
2015/02/25 20:52:12
Sounds good then. I guess it is in the name :)
| |
| 319 // in the output-surface-lost machinery. | |
| 320 if (num_failed_recreate_attempts_ >= MAX_OUTPUT_SURFACE_RETRIES) | |
| 321 LOG(FATAL) << "Failed to create a fallback OutputSurface."; | |
| 322 | |
| 323 base::MessageLoop::current()->PostTask( | |
| 324 FROM_HERE, base::Bind(&Compositor::RequestNewOutputSurface, | |
| 325 weak_ptr_factory_.GetWeakPtr())); | |
| 326 } | 314 } |
| 327 | 315 |
| 328 void Compositor::DidCommit() { | 316 void Compositor::DidCommit() { |
| 329 DCHECK(!IsLocked()); | 317 DCHECK(!IsLocked()); |
| 330 FOR_EACH_OBSERVER(CompositorObserver, | 318 FOR_EACH_OBSERVER(CompositorObserver, |
| 331 observer_list_, | 319 observer_list_, |
| 332 OnCompositingDidCommit(this)); | 320 OnCompositingDidCommit(this)); |
| 333 } | 321 } |
| 334 | 322 |
| 335 void Compositor::DidCommitAndDrawFrame() { | 323 void Compositor::DidCommitAndDrawFrame() { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 observer_list_, | 372 observer_list_, |
| 385 OnCompositingLockStateChanged(this)); | 373 OnCompositingLockStateChanged(this)); |
| 386 } | 374 } |
| 387 | 375 |
| 388 void Compositor::CancelCompositorLock() { | 376 void Compositor::CancelCompositorLock() { |
| 389 if (compositor_lock_) | 377 if (compositor_lock_) |
| 390 compositor_lock_->CancelLock(); | 378 compositor_lock_->CancelLock(); |
| 391 } | 379 } |
| 392 | 380 |
| 393 } // namespace ui | 381 } // namespace ui |
| OLD | NEW |