| 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 270       double hide_threshold; | 270       double hide_threshold; | 
| 271       if (base::StringToDouble(top_threshold_str, &hide_threshold) && | 271       if (base::StringToDouble(top_threshold_str, &hide_threshold) && | 
| 272           hide_threshold >= 0.f && hide_threshold <= 1.f) | 272           hide_threshold >= 0.f && hide_threshold <= 1.f) | 
| 273         settings.top_controls_hide_threshold = hide_threshold; | 273         settings.top_controls_hide_threshold = hide_threshold; | 
| 274   } | 274   } | 
| 275 | 275 | 
| 276   settings.use_pinch_virtual_viewport = | 276   settings.use_pinch_virtual_viewport = | 
| 277       cmd->HasSwitch(cc::switches::kEnablePinchVirtualViewport); | 277       cmd->HasSwitch(cc::switches::kEnablePinchVirtualViewport); | 
| 278   settings.allow_antialiasing &= | 278   settings.allow_antialiasing &= | 
| 279       !cmd->HasSwitch(cc::switches::kDisableCompositedAntialiasing); | 279       !cmd->HasSwitch(cc::switches::kDisableCompositedAntialiasing); | 
|  | 280   settings.single_thread_proxy_scheduler = | 
|  | 281       !cmd->HasSwitch(switches::kDisableSingleThreadProxyScheduler); | 
| 280 | 282 | 
| 281   // These flags should be mirrored by UI versions in ui/compositor/. | 283   // These flags should be mirrored by UI versions in ui/compositor/. | 
| 282   settings.initial_debug_state.show_debug_borders = | 284   settings.initial_debug_state.show_debug_borders = | 
| 283       cmd->HasSwitch(cc::switches::kShowCompositedLayerBorders); | 285       cmd->HasSwitch(cc::switches::kShowCompositedLayerBorders); | 
| 284   settings.initial_debug_state.show_fps_counter = | 286   settings.initial_debug_state.show_fps_counter = | 
| 285       cmd->HasSwitch(cc::switches::kShowFPSCounter); | 287       cmd->HasSwitch(cc::switches::kShowFPSCounter); | 
| 286   settings.initial_debug_state.show_layer_animation_bounds_rects = | 288   settings.initial_debug_state.show_layer_animation_bounds_rects = | 
| 287       cmd->HasSwitch(cc::switches::kShowLayerAnimationBounds); | 289       cmd->HasSwitch(cc::switches::kShowLayerAnimationBounds); | 
| 288   settings.initial_debug_state.show_paint_rects = | 290   settings.initial_debug_state.show_paint_rects = | 
| 289       cmd->HasSwitch(switches::kShowPaintRects); | 291       cmd->HasSwitch(switches::kShowPaintRects); | 
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 402 #endif | 404 #endif | 
| 403 | 405 | 
| 404   compositor->Initialize(settings); | 406   compositor->Initialize(settings); | 
| 405 | 407 | 
| 406   return compositor.Pass(); | 408   return compositor.Pass(); | 
| 407 } | 409 } | 
| 408 | 410 | 
| 409 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, | 411 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, | 
| 410                                                bool threaded) | 412                                                bool threaded) | 
| 411     : threaded_(threaded), | 413     : threaded_(threaded), | 
| 412       suppress_schedule_composite_(false), |  | 
| 413       widget_(widget) { | 414       widget_(widget) { | 
| 414 } | 415 } | 
| 415 | 416 | 
| 416 RenderWidgetCompositor::~RenderWidgetCompositor() {} | 417 RenderWidgetCompositor::~RenderWidgetCompositor() {} | 
| 417 | 418 | 
| 418 const base::WeakPtr<cc::InputHandler>& | 419 const base::WeakPtr<cc::InputHandler>& | 
| 419 RenderWidgetCompositor::GetInputHandler() { | 420 RenderWidgetCompositor::GetInputHandler() { | 
| 420   return layer_tree_host_->GetInputHandler(); | 421   return layer_tree_host_->GetInputHandler(); | 
| 421 } | 422 } | 
| 422 | 423 | 
| 423 void RenderWidgetCompositor::SetSuppressScheduleComposite(bool suppress) { |  | 
| 424   if (suppress_schedule_composite_ == suppress) |  | 
| 425     return; |  | 
| 426 |  | 
| 427   if (suppress) |  | 
| 428     TRACE_EVENT_ASYNC_BEGIN0("gpu", |  | 
| 429         "RenderWidgetCompositor::SetSuppressScheduleComposite", this); |  | 
| 430   else |  | 
| 431     TRACE_EVENT_ASYNC_END0("gpu", |  | 
| 432         "RenderWidgetCompositor::SetSuppressScheduleComposite", this); |  | 
| 433   suppress_schedule_composite_ = suppress; |  | 
| 434 } |  | 
| 435 |  | 
| 436 bool RenderWidgetCompositor::BeginMainFrameRequested() const { | 424 bool RenderWidgetCompositor::BeginMainFrameRequested() const { | 
| 437   return layer_tree_host_->BeginMainFrameRequested(); | 425   return layer_tree_host_->BeginMainFrameRequested(); | 
| 438 } | 426 } | 
| 439 | 427 | 
| 440 void RenderWidgetCompositor::UpdateAnimations(base::TimeTicks time) { |  | 
| 441   layer_tree_host_->UpdateClientAnimations(time); |  | 
| 442 } |  | 
| 443 |  | 
| 444 void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() { | 428 void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() { | 
| 445   layer_tree_host_->SetNeedsDisplayOnAllLayers(); | 429   layer_tree_host_->SetNeedsDisplayOnAllLayers(); | 
| 446 } | 430 } | 
| 447 | 431 | 
| 448 void RenderWidgetCompositor::SetRasterizeOnlyVisibleContent() { | 432 void RenderWidgetCompositor::SetRasterizeOnlyVisibleContent() { | 
| 449   cc::LayerTreeDebugState current = layer_tree_host_->debug_state(); | 433   cc::LayerTreeDebugState current = layer_tree_host_->debug_state(); | 
| 450   current.rasterize_only_visible_content = true; | 434   current.rasterize_only_visible_content = true; | 
| 451   layer_tree_host_->SetDebugState(current); | 435   layer_tree_host_->SetDebugState(current); | 
| 452 } | 436 } | 
| 453 | 437 | 
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 542         this, | 526         this, | 
| 543         this, | 527         this, | 
| 544         shared_bitmap_manager, | 528         shared_bitmap_manager, | 
| 545         settings, | 529         settings, | 
| 546         base::MessageLoopProxy::current()); | 530         base::MessageLoopProxy::current()); | 
| 547   } | 531   } | 
| 548   DCHECK(layer_tree_host_); | 532   DCHECK(layer_tree_host_); | 
| 549 } | 533 } | 
| 550 | 534 | 
| 551 void RenderWidgetCompositor::setSurfaceReady() { | 535 void RenderWidgetCompositor::setSurfaceReady() { | 
| 552   layer_tree_host_->SetLayerTreeHostClientReady(); | 536   // In tests without a RenderThreadImpl, don't set ready as this kicks | 
|  | 537   // off creating output surfaces that the test can't create. | 
|  | 538   if (RenderThreadImpl::current()) | 
|  | 539     layer_tree_host_->SetLayerTreeHostClientReady(); | 
| 553 } | 540 } | 
| 554 | 541 | 
| 555 void RenderWidgetCompositor::setRootLayer(const blink::WebLayer& layer) { | 542 void RenderWidgetCompositor::setRootLayer(const blink::WebLayer& layer) { | 
| 556   layer_tree_host_->SetRootLayer( | 543   layer_tree_host_->SetRootLayer( | 
| 557       static_cast<const WebLayerImpl*>(&layer)->layer()); | 544       static_cast<const WebLayerImpl*>(&layer)->layer()); | 
| 558 } | 545 } | 
| 559 | 546 | 
| 560 void RenderWidgetCompositor::clearRootLayer() { | 547 void RenderWidgetCompositor::clearRootLayer() { | 
| 561   layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>()); | 548   layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>()); | 
| 562 } | 549 } | 
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 695   } | 682   } | 
| 696 } | 683 } | 
| 697 | 684 | 
| 698 void RenderWidgetCompositor::compositeAndReadbackAsync( | 685 void RenderWidgetCompositor::compositeAndReadbackAsync( | 
| 699     blink::WebCompositeAndReadbackAsyncCallback* callback) { | 686     blink::WebCompositeAndReadbackAsyncCallback* callback) { | 
| 700   DCHECK(layer_tree_host_->root_layer()); | 687   DCHECK(layer_tree_host_->root_layer()); | 
| 701   scoped_ptr<cc::CopyOutputRequest> request = | 688   scoped_ptr<cc::CopyOutputRequest> request = | 
| 702       cc::CopyOutputRequest::CreateBitmapRequest( | 689       cc::CopyOutputRequest::CreateBitmapRequest( | 
| 703           base::Bind(&CompositeAndReadbackAsyncCallback, callback)); | 690           base::Bind(&CompositeAndReadbackAsyncCallback, callback)); | 
| 704   layer_tree_host_->root_layer()->RequestCopyOfOutput(request.Pass()); | 691   layer_tree_host_->root_layer()->RequestCopyOfOutput(request.Pass()); | 
| 705   if (!threaded_) { | 692 | 
| 706     widget_->webwidget()->animate(0.0); | 693   if (!threaded_ && | 
| 707     widget_->webwidget()->layout(); | 694       !layer_tree_host_->settings().single_thread_proxy_scheduler) { | 
| 708     layer_tree_host_->Composite(gfx::FrameTime::Now()); | 695     layer_tree_host_->Composite(gfx::FrameTime::Now()); | 
| 709   } | 696   } | 
| 710 } | 697 } | 
| 711 | 698 | 
| 712 void RenderWidgetCompositor::finishAllRendering() { | 699 void RenderWidgetCompositor::finishAllRendering() { | 
| 713   layer_tree_host_->FinishAllRendering(); | 700   layer_tree_host_->FinishAllRendering(); | 
| 714 } | 701 } | 
| 715 | 702 | 
| 716 void RenderWidgetCompositor::setDeferCommits(bool defer_commits) { | 703 void RenderWidgetCompositor::setDeferCommits(bool defer_commits) { | 
| 717   layer_tree_host_->SetDeferCommits(defer_commits); | 704   layer_tree_host_->SetDeferCommits(defer_commits); | 
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 793 void RenderWidgetCompositor::DidCommitAndDrawFrame() { | 780 void RenderWidgetCompositor::DidCommitAndDrawFrame() { | 
| 794   widget_->didCommitAndDrawCompositorFrame(); | 781   widget_->didCommitAndDrawCompositorFrame(); | 
| 795 } | 782 } | 
| 796 | 783 | 
| 797 void RenderWidgetCompositor::DidCompleteSwapBuffers() { | 784 void RenderWidgetCompositor::DidCompleteSwapBuffers() { | 
| 798   widget_->didCompleteSwapBuffers(); | 785   widget_->didCompleteSwapBuffers(); | 
| 799   if (!threaded_) | 786   if (!threaded_) | 
| 800     widget_->OnSwapBuffersComplete(); | 787     widget_->OnSwapBuffersComplete(); | 
| 801 } | 788 } | 
| 802 | 789 | 
| 803 void RenderWidgetCompositor::ScheduleComposite() { |  | 
| 804   if (!suppress_schedule_composite_) |  | 
| 805     widget_->scheduleComposite(); |  | 
| 806 } |  | 
| 807 |  | 
| 808 void RenderWidgetCompositor::ScheduleAnimation() { | 790 void RenderWidgetCompositor::ScheduleAnimation() { | 
| 809   widget_->scheduleAnimation(); | 791   widget_->scheduleAnimation(); | 
| 810 } | 792 } | 
| 811 | 793 | 
| 812 void RenderWidgetCompositor::DidPostSwapBuffers() { | 794 void RenderWidgetCompositor::DidPostSwapBuffers() { | 
| 813   widget_->OnSwapBuffersPosted(); | 795   widget_->OnSwapBuffersPosted(); | 
| 814 } | 796 } | 
| 815 | 797 | 
| 816 void RenderWidgetCompositor::DidAbortSwapBuffers() { | 798 void RenderWidgetCompositor::DidAbortSwapBuffers() { | 
| 817   widget_->OnSwapBuffersAborted(); | 799   widget_->OnSwapBuffersAborted(); | 
| 818 } | 800 } | 
| 819 | 801 | 
| 820 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { | 802 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { | 
| 821   cc::ContextProvider* provider = | 803   cc::ContextProvider* provider = | 
| 822       RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | 804       RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | 
| 823   provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 805   provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 
| 824 } | 806 } | 
| 825 | 807 | 
| 826 }  // namespace content | 808 }  // namespace content | 
| OLD | NEW | 
|---|