Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: content/renderer/gpu/render_widget_compositor.cc

Issue 134623005: Make SingleThreadProxy a SchedulerClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add scoped_abort_remaining_swap_promises.h Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/gpu/render_widget_compositor.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 double hide_threshold; 272 double hide_threshold;
273 if (base::StringToDouble(top_threshold_str, &hide_threshold) && 273 if (base::StringToDouble(top_threshold_str, &hide_threshold) &&
274 hide_threshold >= 0.f && hide_threshold <= 1.f) 274 hide_threshold >= 0.f && hide_threshold <= 1.f)
275 settings.top_controls_hide_threshold = hide_threshold; 275 settings.top_controls_hide_threshold = hide_threshold;
276 } 276 }
277 277
278 settings.use_pinch_virtual_viewport = 278 settings.use_pinch_virtual_viewport =
279 cmd->HasSwitch(cc::switches::kEnablePinchVirtualViewport); 279 cmd->HasSwitch(cc::switches::kEnablePinchVirtualViewport);
280 settings.allow_antialiasing &= 280 settings.allow_antialiasing &=
281 !cmd->HasSwitch(cc::switches::kDisableCompositedAntialiasing); 281 !cmd->HasSwitch(cc::switches::kDisableCompositedAntialiasing);
282 settings.single_thread_proxy_scheduler =
283 !cmd->HasSwitch(switches::kDisableSingleThreadProxyScheduler);
282 284
283 // These flags should be mirrored by UI versions in ui/compositor/. 285 // These flags should be mirrored by UI versions in ui/compositor/.
284 settings.initial_debug_state.show_debug_borders = 286 settings.initial_debug_state.show_debug_borders =
285 cmd->HasSwitch(cc::switches::kShowCompositedLayerBorders); 287 cmd->HasSwitch(cc::switches::kShowCompositedLayerBorders);
286 settings.initial_debug_state.show_fps_counter = 288 settings.initial_debug_state.show_fps_counter =
287 cmd->HasSwitch(cc::switches::kShowFPSCounter); 289 cmd->HasSwitch(cc::switches::kShowFPSCounter);
288 settings.initial_debug_state.show_layer_animation_bounds_rects = 290 settings.initial_debug_state.show_layer_animation_bounds_rects =
289 cmd->HasSwitch(cc::switches::kShowLayerAnimationBounds); 291 cmd->HasSwitch(cc::switches::kShowLayerAnimationBounds);
290 settings.initial_debug_state.show_paint_rects = 292 settings.initial_debug_state.show_paint_rects =
291 cmd->HasSwitch(switches::kShowPaintRects); 293 cmd->HasSwitch(switches::kShowPaintRects);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 #endif 406 #endif
405 407
406 compositor->Initialize(settings); 408 compositor->Initialize(settings);
407 409
408 return compositor.Pass(); 410 return compositor.Pass();
409 } 411 }
410 412
411 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, 413 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget,
412 bool threaded) 414 bool threaded)
413 : threaded_(threaded), 415 : threaded_(threaded),
414 suppress_schedule_composite_(false),
415 widget_(widget) { 416 widget_(widget) {
416 } 417 }
417 418
418 RenderWidgetCompositor::~RenderWidgetCompositor() {} 419 RenderWidgetCompositor::~RenderWidgetCompositor() {}
419 420
420 const base::WeakPtr<cc::InputHandler>& 421 const base::WeakPtr<cc::InputHandler>&
421 RenderWidgetCompositor::GetInputHandler() { 422 RenderWidgetCompositor::GetInputHandler() {
422 return layer_tree_host_->GetInputHandler(); 423 return layer_tree_host_->GetInputHandler();
423 } 424 }
424 425
425 void RenderWidgetCompositor::SetSuppressScheduleComposite(bool suppress) {
426 if (suppress_schedule_composite_ == suppress)
427 return;
428
429 if (suppress)
430 TRACE_EVENT_ASYNC_BEGIN0(
431 "gpu", "RenderWidgetCompositor::SetSuppressScheduleComposite", this);
432 else
433 TRACE_EVENT_ASYNC_END0(
434 "gpu", "RenderWidgetCompositor::SetSuppressScheduleComposite", this);
435 suppress_schedule_composite_ = suppress;
436 }
437
438 bool RenderWidgetCompositor::BeginMainFrameRequested() const { 426 bool RenderWidgetCompositor::BeginMainFrameRequested() const {
439 return layer_tree_host_->BeginMainFrameRequested(); 427 return layer_tree_host_->BeginMainFrameRequested();
440 } 428 }
441 429
442 void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() { 430 void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() {
443 layer_tree_host_->SetNeedsDisplayOnAllLayers(); 431 layer_tree_host_->SetNeedsDisplayOnAllLayers();
444 } 432 }
445 433
446 void RenderWidgetCompositor::SetRasterizeOnlyVisibleContent() { 434 void RenderWidgetCompositor::SetRasterizeOnlyVisibleContent() {
447 cc::LayerTreeDebugState current = layer_tree_host_->debug_state(); 435 cc::LayerTreeDebugState current = layer_tree_host_->debug_state();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 this, 528 this,
541 this, 529 this,
542 shared_bitmap_manager, 530 shared_bitmap_manager,
543 settings, 531 settings,
544 base::MessageLoopProxy::current()); 532 base::MessageLoopProxy::current());
545 } 533 }
546 DCHECK(layer_tree_host_); 534 DCHECK(layer_tree_host_);
547 } 535 }
548 536
549 void RenderWidgetCompositor::setSurfaceReady() { 537 void RenderWidgetCompositor::setSurfaceReady() {
550 layer_tree_host_->SetLayerTreeHostClientReady(); 538 // In tests without a RenderThreadImpl, don't set ready as this kicks
539 // off creating output surfaces that the test can't create.
540 if (RenderThreadImpl::current())
541 layer_tree_host_->SetLayerTreeHostClientReady();
551 } 542 }
552 543
553 void RenderWidgetCompositor::setRootLayer(const blink::WebLayer& layer) { 544 void RenderWidgetCompositor::setRootLayer(const blink::WebLayer& layer) {
554 layer_tree_host_->SetRootLayer( 545 layer_tree_host_->SetRootLayer(
555 static_cast<const cc_blink::WebLayerImpl*>(&layer)->layer()); 546 static_cast<const cc_blink::WebLayerImpl*>(&layer)->layer());
556 } 547 }
557 548
558 void RenderWidgetCompositor::clearRootLayer() { 549 void RenderWidgetCompositor::clearRootLayer() {
559 layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>()); 550 layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>());
560 } 551 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 } 685 }
695 } 686 }
696 687
697 void RenderWidgetCompositor::compositeAndReadbackAsync( 688 void RenderWidgetCompositor::compositeAndReadbackAsync(
698 blink::WebCompositeAndReadbackAsyncCallback* callback) { 689 blink::WebCompositeAndReadbackAsyncCallback* callback) {
699 DCHECK(layer_tree_host_->root_layer()); 690 DCHECK(layer_tree_host_->root_layer());
700 scoped_ptr<cc::CopyOutputRequest> request = 691 scoped_ptr<cc::CopyOutputRequest> request =
701 cc::CopyOutputRequest::CreateBitmapRequest( 692 cc::CopyOutputRequest::CreateBitmapRequest(
702 base::Bind(&CompositeAndReadbackAsyncCallback, callback)); 693 base::Bind(&CompositeAndReadbackAsyncCallback, callback));
703 layer_tree_host_->root_layer()->RequestCopyOfOutput(request.Pass()); 694 layer_tree_host_->root_layer()->RequestCopyOfOutput(request.Pass());
704 if (!threaded_) { 695
705 widget_->webwidget()->animate(0.0); 696 if (!threaded_ &&
706 widget_->webwidget()->layout(); 697 !layer_tree_host_->settings().single_thread_proxy_scheduler) {
707 layer_tree_host_->Composite(gfx::FrameTime::Now()); 698 layer_tree_host_->Composite(gfx::FrameTime::Now());
708 } 699 }
709 } 700 }
710 701
711 void RenderWidgetCompositor::finishAllRendering() { 702 void RenderWidgetCompositor::finishAllRendering() {
712 layer_tree_host_->FinishAllRendering(); 703 layer_tree_host_->FinishAllRendering();
713 } 704 }
714 705
715 void RenderWidgetCompositor::setDeferCommits(bool defer_commits) { 706 void RenderWidgetCompositor::setDeferCommits(bool defer_commits) {
716 layer_tree_host_->SetDeferCommits(defer_commits); 707 layer_tree_host_->SetDeferCommits(defer_commits);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 void RenderWidgetCompositor::DidCommitAndDrawFrame() { 784 void RenderWidgetCompositor::DidCommitAndDrawFrame() {
794 widget_->didCommitAndDrawCompositorFrame(); 785 widget_->didCommitAndDrawCompositorFrame();
795 } 786 }
796 787
797 void RenderWidgetCompositor::DidCompleteSwapBuffers() { 788 void RenderWidgetCompositor::DidCompleteSwapBuffers() {
798 widget_->didCompleteSwapBuffers(); 789 widget_->didCompleteSwapBuffers();
799 if (!threaded_) 790 if (!threaded_)
800 widget_->OnSwapBuffersComplete(); 791 widget_->OnSwapBuffersComplete();
801 } 792 }
802 793
803 void RenderWidgetCompositor::ScheduleComposite() {
804 if (!suppress_schedule_composite_)
805 widget_->scheduleComposite();
806 }
807
808 void RenderWidgetCompositor::ScheduleAnimation() { 794 void RenderWidgetCompositor::ScheduleAnimation() {
809 widget_->scheduleAnimation(); 795 widget_->scheduleAnimation();
810 } 796 }
811 797
812 void RenderWidgetCompositor::DidPostSwapBuffers() { 798 void RenderWidgetCompositor::DidPostSwapBuffers() {
813 widget_->OnSwapBuffersPosted(); 799 widget_->OnSwapBuffersPosted();
814 } 800 }
815 801
816 void RenderWidgetCompositor::DidAbortSwapBuffers() { 802 void RenderWidgetCompositor::DidAbortSwapBuffers() {
817 widget_->OnSwapBuffersAborted(); 803 widget_->OnSwapBuffersAborted();
818 } 804 }
819 805
820 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { 806 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() {
821 cc::ContextProvider* provider = 807 cc::ContextProvider* provider =
822 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); 808 RenderThreadImpl::current()->SharedMainThreadContextProvider().get();
823 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); 809 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM();
824 } 810 }
825 811
826 } // namespace content 812 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/gpu/render_widget_compositor.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698