| 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 13 matching lines...) Expand all Loading... |
| 24 #include "cc/layers/layer.h" | 24 #include "cc/layers/layer.h" |
| 25 #include "cc/output/context_provider.h" | 25 #include "cc/output/context_provider.h" |
| 26 #include "cc/output/output_surface.h" | 26 #include "cc/output/output_surface.h" |
| 27 #include "cc/trees/layer_tree_host.h" | 27 #include "cc/trees/layer_tree_host.h" |
| 28 #include "third_party/skia/include/core/SkBitmap.h" | 28 #include "third_party/skia/include/core/SkBitmap.h" |
| 29 #include "ui/compositor/compositor_observer.h" | 29 #include "ui/compositor/compositor_observer.h" |
| 30 #include "ui/compositor/compositor_switches.h" | 30 #include "ui/compositor/compositor_switches.h" |
| 31 #include "ui/compositor/dip_util.h" | 31 #include "ui/compositor/dip_util.h" |
| 32 #include "ui/compositor/layer.h" | 32 #include "ui/compositor/layer.h" |
| 33 #include "ui/compositor/reflector.h" | 33 #include "ui/compositor/reflector.h" |
| 34 #include "ui/gfx/frame_time.h" |
| 34 #include "ui/gl/gl_context.h" | 35 #include "ui/gl/gl_context.h" |
| 35 #include "ui/gl/gl_implementation.h" | 36 #include "ui/gl/gl_implementation.h" |
| 36 #include "ui/gl/gl_surface.h" | 37 #include "ui/gl/gl_surface.h" |
| 37 #include "ui/gl/gl_switches.h" | 38 #include "ui/gl/gl_switches.h" |
| 38 #include "webkit/common/gpu/context_provider_in_process.h" | 39 #include "webkit/common/gpu/context_provider_in_process.h" |
| 39 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" | 40 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" |
| 40 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" | 41 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" |
| 41 | 42 |
| 42 namespace { | 43 namespace { |
| 43 | 44 |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 delete g_compositor_thread; | 549 delete g_compositor_thread; |
| 549 g_compositor_thread = NULL; | 550 g_compositor_thread = NULL; |
| 550 } | 551 } |
| 551 | 552 |
| 552 DCHECK(g_compositor_initialized) << "Compositor::Initialize() didn't happen."; | 553 DCHECK(g_compositor_initialized) << "Compositor::Initialize() didn't happen."; |
| 553 g_compositor_initialized = false; | 554 g_compositor_initialized = false; |
| 554 } | 555 } |
| 555 | 556 |
| 556 void Compositor::ScheduleDraw() { | 557 void Compositor::ScheduleDraw() { |
| 557 if (g_compositor_thread) { | 558 if (g_compositor_thread) { |
| 558 host_->Composite(base::TimeTicks::Now()); | 559 host_->Composite(gfx::FrameTime::Now()); |
| 559 } else if (!defer_draw_scheduling_) { | 560 } else if (!defer_draw_scheduling_) { |
| 560 defer_draw_scheduling_ = true; | 561 defer_draw_scheduling_ = true; |
| 561 base::MessageLoop::current()->PostTask( | 562 base::MessageLoop::current()->PostTask( |
| 562 FROM_HERE, | 563 FROM_HERE, |
| 563 base::Bind(&Compositor::Draw, schedule_draw_factory_.GetWeakPtr())); | 564 base::Bind(&Compositor::Draw, schedule_draw_factory_.GetWeakPtr())); |
| 564 } | 565 } |
| 565 } | 566 } |
| 566 | 567 |
| 567 void Compositor::SetRootLayer(Layer* root_layer) { | 568 void Compositor::SetRootLayer(Layer* root_layer) { |
| 568 if (root_layer_ == root_layer) | 569 if (root_layer_ == root_layer) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 596 | 597 |
| 597 if (!root_layer_) | 598 if (!root_layer_) |
| 598 return; | 599 return; |
| 599 | 600 |
| 600 last_started_frame_++; | 601 last_started_frame_++; |
| 601 PendingSwap pending_swap(DRAW_SWAP, posted_swaps_.get()); | 602 PendingSwap pending_swap(DRAW_SWAP, posted_swaps_.get()); |
| 602 if (!IsLocked()) { | 603 if (!IsLocked()) { |
| 603 // TODO(nduca): Temporary while compositor calls | 604 // TODO(nduca): Temporary while compositor calls |
| 604 // compositeImmediately() directly. | 605 // compositeImmediately() directly. |
| 605 Layout(); | 606 Layout(); |
| 606 host_->Composite(base::TimeTicks::Now()); | 607 host_->Composite(gfx::FrameTime::Now()); |
| 607 | 608 |
| 608 #if defined(OS_WIN) | 609 #if defined(OS_WIN) |
| 609 // While we resize, we are usually a few frames behind. By blocking | 610 // While we resize, we are usually a few frames behind. By blocking |
| 610 // the UI thread here we minize the area that is mis-painted, specially | 611 // the UI thread here we minize the area that is mis-painted, specially |
| 611 // in the non-client area. See RenderWidgetHostViewAura::SetBounds for | 612 // in the non-client area. See RenderWidgetHostViewAura::SetBounds for |
| 612 // more details and bug 177115. | 613 // more details and bug 177115. |
| 613 if (next_draw_is_resize_ && (last_ended_frame_ > 1)) { | 614 if (next_draw_is_resize_ && (last_ended_frame_ > 1)) { |
| 614 next_draw_is_resize_ = false; | 615 next_draw_is_resize_ = false; |
| 615 host_->FinishAllRendering(); | 616 host_->FinishAllRendering(); |
| 616 } | 617 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 } | 734 } |
| 734 | 735 |
| 735 void Compositor::DidCommit() { | 736 void Compositor::DidCommit() { |
| 736 DCHECK(!IsLocked()); | 737 DCHECK(!IsLocked()); |
| 737 FOR_EACH_OBSERVER(CompositorObserver, | 738 FOR_EACH_OBSERVER(CompositorObserver, |
| 738 observer_list_, | 739 observer_list_, |
| 739 OnCompositingDidCommit(this)); | 740 OnCompositingDidCommit(this)); |
| 740 } | 741 } |
| 741 | 742 |
| 742 void Compositor::DidCommitAndDrawFrame() { | 743 void Compositor::DidCommitAndDrawFrame() { |
| 743 base::TimeTicks start_time = base::TimeTicks::Now(); | 744 base::TimeTicks start_time = gfx::FrameTime::Now(); |
| 744 FOR_EACH_OBSERVER(CompositorObserver, | 745 FOR_EACH_OBSERVER(CompositorObserver, |
| 745 observer_list_, | 746 observer_list_, |
| 746 OnCompositingStarted(this, start_time)); | 747 OnCompositingStarted(this, start_time)); |
| 747 } | 748 } |
| 748 | 749 |
| 749 void Compositor::DidCompleteSwapBuffers() { | 750 void Compositor::DidCompleteSwapBuffers() { |
| 750 DCHECK(g_compositor_thread); | 751 DCHECK(g_compositor_thread); |
| 751 NotifyEnd(); | 752 NotifyEnd(); |
| 752 } | 753 } |
| 753 | 754 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 // CompositorObservers to be notified before starting another | 808 // CompositorObservers to be notified before starting another |
| 808 // draw cycle. | 809 // draw cycle. |
| 809 ScheduleDraw(); | 810 ScheduleDraw(); |
| 810 } | 811 } |
| 811 FOR_EACH_OBSERVER(CompositorObserver, | 812 FOR_EACH_OBSERVER(CompositorObserver, |
| 812 observer_list_, | 813 observer_list_, |
| 813 OnCompositingEnded(this)); | 814 OnCompositingEnded(this)); |
| 814 } | 815 } |
| 815 | 816 |
| 816 } // namespace ui | 817 } // namespace ui |
| OLD | NEW |