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

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

Issue 738983002: Move output surface fallback from cc to embedders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years 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
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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 if (cmd->HasSwitch(switches::kDisableLowResTiling)) 415 if (cmd->HasSwitch(switches::kDisableLowResTiling))
416 settings.create_low_res_tiling = false; 416 settings.create_low_res_tiling = false;
417 417
418 compositor->Initialize(settings); 418 compositor->Initialize(settings);
419 419
420 return compositor.Pass(); 420 return compositor.Pass();
421 } 421 }
422 422
423 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, 423 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget,
424 bool threaded) 424 bool threaded)
425 : threaded_(threaded), 425 : num_failed_recreate_attempts_(0),
426 threaded_(threaded),
426 widget_(widget), 427 widget_(widget),
427 send_v8_idle_notification_after_commit_(true) { 428 send_v8_idle_notification_after_commit_(true),
429 weak_factory_(this) {
428 CommandLine* cmd = CommandLine::ForCurrentProcess(); 430 CommandLine* cmd = CommandLine::ForCurrentProcess();
429 431
430 if (cmd->HasSwitch(switches::kEnableV8IdleNotificationAfterCommit)) 432 if (cmd->HasSwitch(switches::kEnableV8IdleNotificationAfterCommit))
431 send_v8_idle_notification_after_commit_ = true; 433 send_v8_idle_notification_after_commit_ = true;
432 if (cmd->HasSwitch(switches::kDisableV8IdleNotificationAfterCommit)) 434 if (cmd->HasSwitch(switches::kDisableV8IdleNotificationAfterCommit))
433 send_v8_idle_notification_after_commit_ = false; 435 send_v8_idle_notification_after_commit_ = false;
434 } 436 }
435 437
436 RenderWidgetCompositor::~RenderWidgetCompositor() {} 438 RenderWidgetCompositor::~RenderWidgetCompositor() {}
437 439
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 const base::Callback<void(scoped_ptr<base::Value>)>& callback) { 517 const base::Callback<void(scoped_ptr<base::Value>)>& callback) {
516 return layer_tree_host_->ScheduleMicroBenchmark(name, value.Pass(), callback); 518 return layer_tree_host_->ScheduleMicroBenchmark(name, value.Pass(), callback);
517 } 519 }
518 520
519 bool RenderWidgetCompositor::SendMessageToMicroBenchmark( 521 bool RenderWidgetCompositor::SendMessageToMicroBenchmark(
520 int id, 522 int id,
521 scoped_ptr<base::Value> value) { 523 scoped_ptr<base::Value> value) {
522 return layer_tree_host_->SendMessageToMicroBenchmark(id, value.Pass()); 524 return layer_tree_host_->SendMessageToMicroBenchmark(id, value.Pass());
523 } 525 }
524 526
525 void RenderWidgetCompositor::Initialize(cc::LayerTreeSettings settings) { 527 void RenderWidgetCompositor::Initialize(const cc::LayerTreeSettings& settings) {
526 scoped_refptr<base::MessageLoopProxy> compositor_message_loop_proxy; 528 scoped_refptr<base::MessageLoopProxy> compositor_message_loop_proxy;
527 scoped_refptr<base::SingleThreadTaskRunner> 529 scoped_refptr<base::SingleThreadTaskRunner>
528 main_thread_compositor_task_runner(base::MessageLoopProxy::current()); 530 main_thread_compositor_task_runner(base::MessageLoopProxy::current());
529 RenderThreadImpl* render_thread = RenderThreadImpl::current(); 531 RenderThreadImpl* render_thread = RenderThreadImpl::current();
530 cc::SharedBitmapManager* shared_bitmap_manager = NULL; 532 cc::SharedBitmapManager* shared_bitmap_manager = NULL;
531 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = NULL; 533 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = NULL;
532 // render_thread may be NULL in tests. 534 // render_thread may be NULL in tests.
533 if (render_thread) { 535 if (render_thread) {
534 compositor_message_loop_proxy = 536 compositor_message_loop_proxy =
535 render_thread->compositor_message_loop_proxy(); 537 render_thread->compositor_message_loop_proxy();
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 void RenderWidgetCompositor::ApplyViewportDeltas( 845 void RenderWidgetCompositor::ApplyViewportDeltas(
844 const gfx::Vector2d& scroll_delta, 846 const gfx::Vector2d& scroll_delta,
845 float page_scale, 847 float page_scale,
846 float top_controls_delta) { 848 float top_controls_delta) {
847 widget_->webwidget()->applyViewportDeltas( 849 widget_->webwidget()->applyViewportDeltas(
848 scroll_delta, 850 scroll_delta,
849 page_scale, 851 page_scale,
850 top_controls_delta); 852 top_controls_delta);
851 } 853 }
852 854
853 void RenderWidgetCompositor::RequestNewOutputSurface(bool fallback) { 855 void RenderWidgetCompositor::RequestNewOutputSurface() {
854 layer_tree_host_->SetOutputSurface(widget_->CreateOutputSurface(fallback)); 856 bool fallback =
857 num_failed_recreate_attempts_ >= OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK;
858 scoped_ptr<cc::OutputSurface> surface(widget_->CreateOutputSurface(fallback));
859
860 if (!surface) {
861 DidFailToInitializeOutputSurface();
862 return;
863 }
864
865 layer_tree_host_->SetOutputSurface(surface.Pass());
855 } 866 }
856 867
857 void RenderWidgetCompositor::DidInitializeOutputSurface() { 868 void RenderWidgetCompositor::DidInitializeOutputSurface() {
869 num_failed_recreate_attempts_ = 0;
870 }
871
872 void RenderWidgetCompositor::DidFailToInitializeOutputSurface() {
873 ++num_failed_recreate_attempts_;
874 // Tolerate a certain number of recreation failures to work around races
875 // in the output-surface-lost machinery.
876 if (num_failed_recreate_attempts_ >= MAX_OUTPUT_SURFACE_RETRIES)
877 LOG(FATAL) << "Failed to create a fallback OutputSurface.";
no sievers 2014/12/02 20:38:07 nit: LOG_IF(FATAL, condition)
enne (OOO) 2014/12/02 21:09:33 Done.
878
879 base::MessageLoop::current()->PostTask(
880 FROM_HERE, base::Bind(&RenderWidgetCompositor::RequestNewOutputSurface,
881 weak_factory_.GetWeakPtr()));
858 } 882 }
859 883
860 void RenderWidgetCompositor::WillCommit() { 884 void RenderWidgetCompositor::WillCommit() {
861 widget_->InstrumentWillComposite(); 885 widget_->InstrumentWillComposite();
862 } 886 }
863 887
864 void RenderWidgetCompositor::DidCommit() { 888 void RenderWidgetCompositor::DidCommit() {
865 DCHECK(!temporary_copy_output_request_); 889 DCHECK(!temporary_copy_output_request_);
866 if (send_v8_idle_notification_after_commit_) { 890 if (send_v8_idle_notification_after_commit_) {
867 base::TimeDelta idle_time = begin_main_frame_time_ + 891 base::TimeDelta idle_time = begin_main_frame_time_ +
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 widget_->OnSwapBuffersAborted(); 929 widget_->OnSwapBuffersAborted();
906 } 930 }
907 931
908 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { 932 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() {
909 cc::ContextProvider* provider = 933 cc::ContextProvider* provider =
910 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); 934 RenderThreadImpl::current()->SharedMainThreadContextProvider().get();
911 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); 935 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM();
912 } 936 }
913 937
914 } // namespace content 938 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698