| 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 switches::kUIDisableThreadedCompositing); | 500 switches::kUIDisableThreadedCompositing); |
| 501 #else | 501 #else |
| 502 bool use_thread = | 502 bool use_thread = |
| 503 CommandLine::ForCurrentProcess()->HasSwitch( | 503 CommandLine::ForCurrentProcess()->HasSwitch( |
| 504 switches::kUIEnableThreadedCompositing) && | 504 switches::kUIEnableThreadedCompositing) && |
| 505 !CommandLine::ForCurrentProcess()->HasSwitch( | 505 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 506 switches::kUIDisableThreadedCompositing); | 506 switches::kUIDisableThreadedCompositing); |
| 507 #endif | 507 #endif |
| 508 if (use_thread) { | 508 if (use_thread) { |
| 509 g_compositor_thread = new base::Thread("Browser Compositor"); | 509 g_compositor_thread = new base::Thread("Browser Compositor"); |
| 510 #if defined(OS_POSIX) | |
| 511 // Workaround for crbug.com/293736 | |
| 512 // On Posix, MessagePumpDefault uses system time, so delayed tasks (for | |
| 513 // compositor scheduling) work incorrectly across system time changes (e.g. | |
| 514 // tlsdate). So instead, use an IO loop, which uses libevent, that uses | |
| 515 // monotonic time (immune to these problems). | |
| 516 base::Thread::Options options; | |
| 517 options.message_loop_type = base::MessageLoop::TYPE_IO; | |
| 518 g_compositor_thread->StartWithOptions(options); | |
| 519 #else | |
| 520 g_compositor_thread->Start(); | 510 g_compositor_thread->Start(); |
| 521 #endif | |
| 522 } | 511 } |
| 523 | 512 |
| 524 DCHECK(!g_compositor_initialized) << "Compositor initialized twice."; | 513 DCHECK(!g_compositor_initialized) << "Compositor initialized twice."; |
| 525 g_compositor_initialized = true; | 514 g_compositor_initialized = true; |
| 526 } | 515 } |
| 527 | 516 |
| 528 // static | 517 // static |
| 529 bool Compositor::WasInitializedWithThread() { | 518 bool Compositor::WasInitializedWithThread() { |
| 530 DCHECK(g_compositor_initialized); | 519 DCHECK(g_compositor_initialized); |
| 531 return !!g_compositor_thread; | 520 return !!g_compositor_thread; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 } | 781 } |
| 793 | 782 |
| 794 void Compositor::NotifyEnd() { | 783 void Compositor::NotifyEnd() { |
| 795 last_ended_frame_++; | 784 last_ended_frame_++; |
| 796 FOR_EACH_OBSERVER(CompositorObserver, | 785 FOR_EACH_OBSERVER(CompositorObserver, |
| 797 observer_list_, | 786 observer_list_, |
| 798 OnCompositingEnded(this)); | 787 OnCompositingEnded(this)); |
| 799 } | 788 } |
| 800 | 789 |
| 801 } // namespace ui | 790 } // namespace ui |
| OLD | NEW |