OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/renderer/gpu/render_widget_compositor.h" | 5 #include "content/renderer/gpu/render_widget_compositor.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 #endif | 403 #endif |
404 | 404 |
405 compositor->Initialize(settings); | 405 compositor->Initialize(settings); |
406 | 406 |
407 return compositor.Pass(); | 407 return compositor.Pass(); |
408 } | 408 } |
409 | 409 |
410 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, | 410 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, |
411 bool threaded) | 411 bool threaded) |
412 : threaded_(threaded), | 412 : threaded_(threaded), |
413 suppress_schedule_composite_(false), | |
414 widget_(widget) { | 413 widget_(widget) { |
415 } | 414 } |
416 | 415 |
417 RenderWidgetCompositor::~RenderWidgetCompositor() {} | 416 RenderWidgetCompositor::~RenderWidgetCompositor() {} |
418 | 417 |
419 const base::WeakPtr<cc::InputHandler>& | 418 const base::WeakPtr<cc::InputHandler>& |
420 RenderWidgetCompositor::GetInputHandler() { | 419 RenderWidgetCompositor::GetInputHandler() { |
421 return layer_tree_host_->GetInputHandler(); | 420 return layer_tree_host_->GetInputHandler(); |
422 } | 421 } |
423 | 422 |
424 void RenderWidgetCompositor::SetSuppressScheduleComposite(bool suppress) { | |
425 if (suppress_schedule_composite_ == suppress) | |
426 return; | |
427 | |
428 if (suppress) | |
429 TRACE_EVENT_ASYNC_BEGIN0("gpu", | |
430 "RenderWidgetCompositor::SetSuppressScheduleComposite", this); | |
431 else | |
432 TRACE_EVENT_ASYNC_END0("gpu", | |
433 "RenderWidgetCompositor::SetSuppressScheduleComposite", this); | |
434 suppress_schedule_composite_ = suppress; | |
435 } | |
436 | |
437 bool RenderWidgetCompositor::BeginMainFrameRequested() const { | 423 bool RenderWidgetCompositor::BeginMainFrameRequested() const { |
438 return layer_tree_host_->BeginMainFrameRequested(); | 424 return layer_tree_host_->BeginMainFrameRequested(); |
439 } | 425 } |
440 | 426 |
441 void RenderWidgetCompositor::UpdateAnimations(base::TimeTicks time) { | |
442 layer_tree_host_->UpdateClientAnimations(time); | |
443 } | |
444 | |
445 void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() { | 427 void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() { |
446 layer_tree_host_->SetNeedsDisplayOnAllLayers(); | 428 layer_tree_host_->SetNeedsDisplayOnAllLayers(); |
447 } | 429 } |
448 | 430 |
449 void RenderWidgetCompositor::SetRasterizeOnlyVisibleContent() { | 431 void RenderWidgetCompositor::SetRasterizeOnlyVisibleContent() { |
450 cc::LayerTreeDebugState current = layer_tree_host_->debug_state(); | 432 cc::LayerTreeDebugState current = layer_tree_host_->debug_state(); |
451 current.rasterize_only_visible_content = true; | 433 current.rasterize_only_visible_content = true; |
452 layer_tree_host_->SetDebugState(current); | 434 layer_tree_host_->SetDebugState(current); |
453 } | 435 } |
454 | 436 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
527 layer_tree_host_ = cc::LayerTreeHost::CreateThreaded( | 509 layer_tree_host_ = cc::LayerTreeHost::CreateThreaded( |
528 this, shared_bitmap_manager, settings, compositor_message_loop_proxy); | 510 this, shared_bitmap_manager, settings, compositor_message_loop_proxy); |
529 } else { | 511 } else { |
530 layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded( | 512 layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded( |
531 this, this, shared_bitmap_manager, settings); | 513 this, this, shared_bitmap_manager, settings); |
532 } | 514 } |
533 DCHECK(layer_tree_host_); | 515 DCHECK(layer_tree_host_); |
534 } | 516 } |
535 | 517 |
536 void RenderWidgetCompositor::setSurfaceReady() { | 518 void RenderWidgetCompositor::setSurfaceReady() { |
537 layer_tree_host_->SetLayerTreeHostClientReady(); | 519 // In tests without a RenderThreadImpl, don't set ready as this kicks |
520 // off creating output surfaces that the test can't create. | |
521 if (RenderThreadImpl::current()) | |
522 layer_tree_host_->SetLayerTreeHostClientReady(); | |
538 } | 523 } |
539 | 524 |
540 void RenderWidgetCompositor::setRootLayer(const blink::WebLayer& layer) { | 525 void RenderWidgetCompositor::setRootLayer(const blink::WebLayer& layer) { |
541 layer_tree_host_->SetRootLayer( | 526 layer_tree_host_->SetRootLayer( |
542 static_cast<const WebLayerImpl*>(&layer)->layer()); | 527 static_cast<const WebLayerImpl*>(&layer)->layer()); |
543 } | 528 } |
544 | 529 |
545 void RenderWidgetCompositor::clearRootLayer() { | 530 void RenderWidgetCompositor::clearRootLayer() { |
546 layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>()); | 531 layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>()); |
547 } | 532 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
680 } | 665 } |
681 } | 666 } |
682 | 667 |
683 void RenderWidgetCompositor::compositeAndReadbackAsync( | 668 void RenderWidgetCompositor::compositeAndReadbackAsync( |
684 blink::WebCompositeAndReadbackAsyncCallback* callback) { | 669 blink::WebCompositeAndReadbackAsyncCallback* callback) { |
685 DCHECK(layer_tree_host_->root_layer()); | 670 DCHECK(layer_tree_host_->root_layer()); |
686 scoped_ptr<cc::CopyOutputRequest> request = | 671 scoped_ptr<cc::CopyOutputRequest> request = |
687 cc::CopyOutputRequest::CreateBitmapRequest( | 672 cc::CopyOutputRequest::CreateBitmapRequest( |
688 base::Bind(&CompositeAndReadbackAsyncCallback, callback)); | 673 base::Bind(&CompositeAndReadbackAsyncCallback, callback)); |
689 layer_tree_host_->root_layer()->RequestCopyOfOutput(request.Pass()); | 674 layer_tree_host_->root_layer()->RequestCopyOfOutput(request.Pass()); |
690 if (!threaded_) { | 675 |
691 widget_->webwidget()->animate(0.0); | 676 if (!threaded_) |
692 widget_->webwidget()->layout(); | 677 layer_tree_host_->CompositeNoSwap(gfx::FrameTime::Now()); |
enne (OOO)
2014/07/10 20:37:42
This is the most unfortunate part of this patch.
| |
693 layer_tree_host_->Composite(gfx::FrameTime::Now()); | |
694 } | |
695 } | 678 } |
696 | 679 |
697 void RenderWidgetCompositor::finishAllRendering() { | 680 void RenderWidgetCompositor::finishAllRendering() { |
698 layer_tree_host_->FinishAllRendering(); | 681 layer_tree_host_->FinishAllRendering(); |
699 } | 682 } |
700 | 683 |
701 void RenderWidgetCompositor::setDeferCommits(bool defer_commits) { | 684 void RenderWidgetCompositor::setDeferCommits(bool defer_commits) { |
702 layer_tree_host_->SetDeferCommits(defer_commits); | 685 layer_tree_host_->SetDeferCommits(defer_commits); |
703 } | 686 } |
704 | 687 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
778 void RenderWidgetCompositor::DidCommitAndDrawFrame() { | 761 void RenderWidgetCompositor::DidCommitAndDrawFrame() { |
779 widget_->didCommitAndDrawCompositorFrame(); | 762 widget_->didCommitAndDrawCompositorFrame(); |
780 } | 763 } |
781 | 764 |
782 void RenderWidgetCompositor::DidCompleteSwapBuffers() { | 765 void RenderWidgetCompositor::DidCompleteSwapBuffers() { |
783 widget_->didCompleteSwapBuffers(); | 766 widget_->didCompleteSwapBuffers(); |
784 if (!threaded_) | 767 if (!threaded_) |
785 widget_->OnSwapBuffersComplete(); | 768 widget_->OnSwapBuffersComplete(); |
786 } | 769 } |
787 | 770 |
788 void RenderWidgetCompositor::ScheduleComposite() { | |
789 if (!suppress_schedule_composite_) | |
790 widget_->scheduleComposite(); | |
791 } | |
792 | |
793 void RenderWidgetCompositor::ScheduleAnimation() { | 771 void RenderWidgetCompositor::ScheduleAnimation() { |
794 widget_->scheduleAnimation(); | 772 widget_->scheduleAnimation(); |
795 } | 773 } |
796 | 774 |
797 void RenderWidgetCompositor::DidPostSwapBuffers() { | 775 void RenderWidgetCompositor::DidPostSwapBuffers() { |
798 widget_->OnSwapBuffersPosted(); | 776 widget_->OnSwapBuffersPosted(); |
799 } | 777 } |
800 | 778 |
801 void RenderWidgetCompositor::DidAbortSwapBuffers() { | 779 void RenderWidgetCompositor::DidAbortSwapBuffers() { |
802 widget_->OnSwapBuffersAborted(); | 780 widget_->OnSwapBuffersAborted(); |
803 } | 781 } |
804 | 782 |
805 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { | 783 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { |
806 cc::ContextProvider* provider = | 784 cc::ContextProvider* provider = |
807 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | 785 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); |
808 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 786 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); |
809 } | 787 } |
810 | 788 |
811 } // namespace content | 789 } // namespace content |
OLD | NEW |