| 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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 delete g_compositor_thread; | 546 delete g_compositor_thread; |
| 546 g_compositor_thread = NULL; | 547 g_compositor_thread = NULL; |
| 547 } | 548 } |
| 548 | 549 |
| 549 DCHECK(g_compositor_initialized) << "Compositor::Initialize() didn't happen."; | 550 DCHECK(g_compositor_initialized) << "Compositor::Initialize() didn't happen."; |
| 550 g_compositor_initialized = false; | 551 g_compositor_initialized = false; |
| 551 } | 552 } |
| 552 | 553 |
| 553 void Compositor::ScheduleDraw() { | 554 void Compositor::ScheduleDraw() { |
| 554 if (g_compositor_thread) { | 555 if (g_compositor_thread) { |
| 555 host_->Composite(base::TimeTicks::Now()); | 556 host_->Composite(gfx::FrameTime::Now()); |
| 556 } else if (!defer_draw_scheduling_) { | 557 } else if (!defer_draw_scheduling_) { |
| 557 defer_draw_scheduling_ = true; | 558 defer_draw_scheduling_ = true; |
| 558 base::MessageLoop::current()->PostTask( | 559 base::MessageLoop::current()->PostTask( |
| 559 FROM_HERE, | 560 FROM_HERE, |
| 560 base::Bind(&Compositor::Draw, schedule_draw_factory_.GetWeakPtr())); | 561 base::Bind(&Compositor::Draw, schedule_draw_factory_.GetWeakPtr())); |
| 561 } | 562 } |
| 562 } | 563 } |
| 563 | 564 |
| 564 void Compositor::SetRootLayer(Layer* root_layer) { | 565 void Compositor::SetRootLayer(Layer* root_layer) { |
| 565 if (root_layer_ == root_layer) | 566 if (root_layer_ == root_layer) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 593 | 594 |
| 594 if (!root_layer_) | 595 if (!root_layer_) |
| 595 return; | 596 return; |
| 596 | 597 |
| 597 last_started_frame_++; | 598 last_started_frame_++; |
| 598 PendingSwap pending_swap(DRAW_SWAP, posted_swaps_.get()); | 599 PendingSwap pending_swap(DRAW_SWAP, posted_swaps_.get()); |
| 599 if (!IsLocked()) { | 600 if (!IsLocked()) { |
| 600 // TODO(nduca): Temporary while compositor calls | 601 // TODO(nduca): Temporary while compositor calls |
| 601 // compositeImmediately() directly. | 602 // compositeImmediately() directly. |
| 602 Layout(); | 603 Layout(); |
| 603 host_->Composite(base::TimeTicks::Now()); | 604 host_->Composite(gfx::FrameTime::Now()); |
| 604 | 605 |
| 605 #if defined(OS_WIN) | 606 #if defined(OS_WIN) |
| 606 // While we resize, we are usually a few frames behind. By blocking | 607 // While we resize, we are usually a few frames behind. By blocking |
| 607 // the UI thread here we minize the area that is mis-painted, specially | 608 // the UI thread here we minize the area that is mis-painted, specially |
| 608 // in the non-client area. See RenderWidgetHostViewAura::SetBounds for | 609 // in the non-client area. See RenderWidgetHostViewAura::SetBounds for |
| 609 // more details and bug 177115. | 610 // more details and bug 177115. |
| 610 if (next_draw_is_resize_ && (last_ended_frame_ > 1)) { | 611 if (next_draw_is_resize_ && (last_ended_frame_ > 1)) { |
| 611 next_draw_is_resize_ = false; | 612 next_draw_is_resize_ = false; |
| 612 host_->FinishAllRendering(); | 613 host_->FinishAllRendering(); |
| 613 } | 614 } |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 // CompositorObservers to be notified before starting another | 805 // CompositorObservers to be notified before starting another |
| 805 // draw cycle. | 806 // draw cycle. |
| 806 ScheduleDraw(); | 807 ScheduleDraw(); |
| 807 } | 808 } |
| 808 FOR_EACH_OBSERVER(CompositorObserver, | 809 FOR_EACH_OBSERVER(CompositorObserver, |
| 809 observer_list_, | 810 observer_list_, |
| 810 OnCompositingEnded(this)); | 811 OnCompositingEnded(this)); |
| 811 } | 812 } |
| 812 | 813 |
| 813 } // namespace ui | 814 } // namespace ui |
| OLD | NEW |