| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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       compositor_thread_loop_(context_factory->GetCompositorMessageLoop()), | 74       compositor_thread_loop_(context_factory->GetCompositorMessageLoop()), | 
| 75       task_runner_(task_runner), | 75       task_runner_(task_runner), | 
| 76       vsync_manager_(new CompositorVSyncManager()), | 76       vsync_manager_(new CompositorVSyncManager()), | 
| 77       device_scale_factor_(0.0f), | 77       device_scale_factor_(0.0f), | 
| 78       last_started_frame_(0), | 78       last_started_frame_(0), | 
| 79       last_ended_frame_(0), | 79       last_ended_frame_(0), | 
|  | 80       num_failed_recreate_attempts_(0), | 
| 80       disable_schedule_composite_(false), | 81       disable_schedule_composite_(false), | 
| 81       compositor_lock_(NULL), | 82       compositor_lock_(NULL), | 
| 82       defer_draw_scheduling_(false), | 83       defer_draw_scheduling_(false), | 
| 83       waiting_on_compositing_end_(false), | 84       waiting_on_compositing_end_(false), | 
| 84       draw_on_compositing_end_(false), | 85       draw_on_compositing_end_(false), | 
| 85       swap_state_(SWAP_NONE), | 86       swap_state_(SWAP_NONE), | 
| 86       layer_animator_collection_(this), | 87       layer_animator_collection_(this), | 
| 87       weak_ptr_factory_(this) { | 88       weak_ptr_factory_(this) { | 
| 88   root_web_layer_ = cc::Layer::Create(); | 89   root_web_layer_ = cc::Layer::Create(); | 
| 89 | 90 | 
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 349 | 350 | 
| 350 void Compositor::Layout() { | 351 void Compositor::Layout() { | 
| 351   // We're sending damage that will be addressed during this composite | 352   // We're sending damage that will be addressed during this composite | 
| 352   // cycle, so we don't need to schedule another composite to address it. | 353   // cycle, so we don't need to schedule another composite to address it. | 
| 353   disable_schedule_composite_ = true; | 354   disable_schedule_composite_ = true; | 
| 354   if (root_layer_) | 355   if (root_layer_) | 
| 355     root_layer_->SendDamagedRects(); | 356     root_layer_->SendDamagedRects(); | 
| 356   disable_schedule_composite_ = false; | 357   disable_schedule_composite_ = false; | 
| 357 } | 358 } | 
| 358 | 359 | 
| 359 void Compositor::RequestNewOutputSurface(bool fallback) { | 360 void Compositor::RequestNewOutputSurface() { | 
|  | 361   bool fallback = | 
|  | 362       num_failed_recreate_attempts_ >= OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK; | 
| 360   context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr(), | 363   context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr(), | 
| 361                                         fallback); | 364                                         fallback); | 
| 362 } | 365 } | 
| 363 | 366 | 
|  | 367 void Compositor::DidInitializeOutputSurface() { | 
|  | 368   num_failed_recreate_attempts_ = 0; | 
|  | 369 } | 
|  | 370 | 
|  | 371 void Compositor::DidFailToInitializeOutputSurface() { | 
|  | 372   num_failed_recreate_attempts_++; | 
|  | 373 | 
|  | 374   // Tolerate a certain number of recreation failures to work around races | 
|  | 375   // in the output-surface-lost machinery. | 
|  | 376   if (num_failed_recreate_attempts_ >= MAX_OUTPUT_SURFACE_RETRIES) | 
|  | 377     LOG(FATAL) << "Failed to create a fallback OutputSurface."; | 
|  | 378 | 
|  | 379   base::MessageLoop::current()->PostTask( | 
|  | 380       FROM_HERE, base::Bind(&Compositor::RequestNewOutputSurface, | 
|  | 381                             weak_ptr_factory_.GetWeakPtr())); | 
|  | 382 } | 
|  | 383 | 
| 364 void Compositor::DidCommit() { | 384 void Compositor::DidCommit() { | 
| 365   DCHECK(!IsLocked()); | 385   DCHECK(!IsLocked()); | 
| 366   FOR_EACH_OBSERVER(CompositorObserver, | 386   FOR_EACH_OBSERVER(CompositorObserver, | 
| 367                     observer_list_, | 387                     observer_list_, | 
| 368                     OnCompositingDidCommit(this)); | 388                     OnCompositingDidCommit(this)); | 
| 369 } | 389 } | 
| 370 | 390 | 
| 371 void Compositor::DidCommitAndDrawFrame() { | 391 void Compositor::DidCommitAndDrawFrame() { | 
| 372   base::TimeTicks start_time = gfx::FrameTime::Now(); | 392   base::TimeTicks start_time = gfx::FrameTime::Now(); | 
| 373   FOR_EACH_OBSERVER(CompositorObserver, | 393   FOR_EACH_OBSERVER(CompositorObserver, | 
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 463     // Call ScheduleDraw() instead of Draw() in order to allow other | 483     // Call ScheduleDraw() instead of Draw() in order to allow other | 
| 464     // CompositorObservers to be notified before starting another | 484     // CompositorObservers to be notified before starting another | 
| 465     // draw cycle. | 485     // draw cycle. | 
| 466     ScheduleDraw(); | 486     ScheduleDraw(); | 
| 467   } | 487   } | 
| 468   FOR_EACH_OBSERVER( | 488   FOR_EACH_OBSERVER( | 
| 469       CompositorObserver, observer_list_, OnCompositingEnded(this)); | 489       CompositorObserver, observer_list_, OnCompositingEnded(this)); | 
| 470 } | 490 } | 
| 471 | 491 | 
| 472 }  // namespace ui | 492 }  // namespace ui | 
| OLD | NEW | 
|---|