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

Side by Side Diff: content/renderer/render_widget.cc

Issue 233093006: Stop disabling force_compositing_mode for background RenderViews. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: background: WebContentsDelegate Created 6 years, 8 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
OLDNEW
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 "content/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/debug/trace_event_synthetic_delay.h" 10 #include "base/debug/trace_event_synthetic_delay.h"
(...skipping 19 matching lines...) Expand all
30 #include "content/common/swapped_out_messages.h" 30 #include "content/common/swapped_out_messages.h"
31 #include "content/common/view_messages.h" 31 #include "content/common/view_messages.h"
32 #include "content/public/common/content_switches.h" 32 #include "content/public/common/content_switches.h"
33 #include "content/public/common/context_menu_params.h" 33 #include "content/public/common/context_menu_params.h"
34 #include "content/renderer/cursor_utils.h" 34 #include "content/renderer/cursor_utils.h"
35 #include "content/renderer/external_popup_menu.h" 35 #include "content/renderer/external_popup_menu.h"
36 #include "content/renderer/gpu/compositor_output_surface.h" 36 #include "content/renderer/gpu/compositor_output_surface.h"
37 #include "content/renderer/gpu/compositor_software_output_device.h" 37 #include "content/renderer/gpu/compositor_software_output_device.h"
38 #include "content/renderer/gpu/delegated_compositor_output_surface.h" 38 #include "content/renderer/gpu/delegated_compositor_output_surface.h"
39 #include "content/renderer/gpu/mailbox_output_surface.h" 39 #include "content/renderer/gpu/mailbox_output_surface.h"
40 #include "content/renderer/gpu/null_output_surface.h"
40 #include "content/renderer/gpu/render_widget_compositor.h" 41 #include "content/renderer/gpu/render_widget_compositor.h"
41 #include "content/renderer/ime_event_guard.h" 42 #include "content/renderer/ime_event_guard.h"
42 #include "content/renderer/input/input_handler_manager.h" 43 #include "content/renderer/input/input_handler_manager.h"
43 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 44 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
44 #include "content/renderer/render_frame_impl.h" 45 #include "content/renderer/render_frame_impl.h"
45 #include "content/renderer/render_process.h" 46 #include "content/renderer/render_process.h"
46 #include "content/renderer/render_thread_impl.h" 47 #include "content/renderer/render_thread_impl.h"
47 #include "content/renderer/renderer_webkitplatformsupport_impl.h" 48 #include "content/renderer/renderer_webkitplatformsupport_impl.h"
48 #include "content/renderer/resizing_mode_selector.h" 49 #include "content/renderer/resizing_mode_selector.h"
49 #include "ipc/ipc_sync_message.h" 50 #include "ipc/ipc_sync_message.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 params->x += offset_.x(); 342 params->x += offset_.x();
342 params->y *= scale_; 343 params->y *= scale_;
343 params->y += offset_.y(); 344 params->y += offset_.y();
344 } 345 }
345 346
346 // RenderWidget --------------------------------------------------------------- 347 // RenderWidget ---------------------------------------------------------------
347 348
348 RenderWidget::RenderWidget(blink::WebPopupType popup_type, 349 RenderWidget::RenderWidget(blink::WebPopupType popup_type,
349 const blink::WebScreenInfo& screen_info, 350 const blink::WebScreenInfo& screen_info,
350 bool swapped_out, 351 bool swapped_out,
351 bool hidden) 352 bool hidden,
353 bool never_visible)
352 : routing_id_(MSG_ROUTING_NONE), 354 : routing_id_(MSG_ROUTING_NONE),
353 surface_id_(0), 355 surface_id_(0),
354 webwidget_(NULL), 356 webwidget_(NULL),
355 opener_id_(MSG_ROUTING_NONE), 357 opener_id_(MSG_ROUTING_NONE),
356 init_complete_(false), 358 init_complete_(false),
357 current_paint_buf_(NULL), 359 current_paint_buf_(NULL),
358 overdraw_bottom_height_(0.f), 360 overdraw_bottom_height_(0.f),
359 next_paint_flags_(0), 361 next_paint_flags_(0),
360 filtered_time_per_frame_(0.0f), 362 filtered_time_per_frame_(0.0f),
361 update_reply_pending_(false), 363 update_reply_pending_(false),
362 auto_resize_mode_(false), 364 auto_resize_mode_(false),
363 need_update_rect_for_auto_resize_(false), 365 need_update_rect_for_auto_resize_(false),
364 using_asynchronous_swapbuffers_(false), 366 using_asynchronous_swapbuffers_(false),
365 num_swapbuffers_complete_pending_(0), 367 num_swapbuffers_complete_pending_(0),
366 did_show_(false), 368 did_show_(false),
367 is_hidden_(hidden), 369 is_hidden_(hidden),
370 never_visible_(never_visible),
368 is_fullscreen_(false), 371 is_fullscreen_(false),
369 needs_repainting_on_restore_(false), 372 needs_repainting_on_restore_(false),
370 has_focus_(false), 373 has_focus_(false),
371 handling_input_event_(false), 374 handling_input_event_(false),
372 handling_ime_event_(false), 375 handling_ime_event_(false),
373 handling_touchstart_event_(false), 376 handling_touchstart_event_(false),
374 closing_(false), 377 closing_(false),
375 is_swapped_out_(swapped_out), 378 is_swapped_out_(swapped_out),
376 input_method_is_active_(false), 379 input_method_is_active_(false),
377 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 380 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
378 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), 381 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
379 can_compose_inline_(true), 382 can_compose_inline_(true),
380 popup_type_(popup_type), 383 popup_type_(popup_type),
381 pending_window_rect_count_(0), 384 pending_window_rect_count_(0),
382 suppress_next_char_events_(false), 385 suppress_next_char_events_(false),
383 is_accelerated_compositing_active_(false), 386 is_accelerated_compositing_active_(false),
384 was_accelerated_compositing_ever_active_(false), 387 was_accelerated_compositing_ever_active_(false),
385 animation_update_pending_(false), 388 animation_update_pending_(false),
386 invalidation_task_posted_(false), 389 invalidation_task_posted_(false),
387 screen_info_(screen_info), 390 screen_info_(screen_info),
388 device_scale_factor_(screen_info_.deviceScaleFactor), 391 device_scale_factor_(screen_info_.deviceScaleFactor),
389 is_threaded_compositing_enabled_(false), 392 is_threaded_compositing_enabled_(false),
390 next_output_surface_id_(0), 393 next_output_surface_id_(0),
391 #if defined(OS_ANDROID) 394 #if defined(OS_ANDROID)
392 outstanding_ime_acks_(0), 395 outstanding_ime_acks_(0),
393 #endif 396 #endif
394 popup_origin_scale_for_emulation_(0.f), 397 popup_origin_scale_for_emulation_(0.f),
395 resizing_mode_selector_(new ResizingModeSelector()), 398 resizing_mode_selector_(new ResizingModeSelector()),
396 context_menu_source_type_(ui::MENU_SOURCE_MOUSE) { 399 context_menu_source_type_(ui::MENU_SOURCE_MOUSE) {
400 DCHECK(!never_visible_ || is_hidden_);
397 if (!swapped_out) 401 if (!swapped_out)
398 RenderProcess::current()->AddRefProcess(); 402 RenderProcess::current()->AddRefProcess();
399 DCHECK(RenderThread::Get()); 403 DCHECK(RenderThread::Get());
400 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( 404 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch(
401 switches::kDisableGpuVsync); 405 switches::kDisableGpuVsync);
402 is_threaded_compositing_enabled_ = 406 is_threaded_compositing_enabled_ =
403 CommandLine::ForCurrentProcess()->HasSwitch( 407 CommandLine::ForCurrentProcess()->HasSwitch(
404 switches::kEnableThreadedCompositing); 408 switches::kEnableThreadedCompositing);
405 409
406 legacy_software_mode_stats_ = cc::RenderingStatsInstrumentation::Create(); 410 legacy_software_mode_stats_ = cc::RenderingStatsInstrumentation::Create();
(...skipping 18 matching lines...) Expand all
425 if (!is_swapped_out_ && RenderProcess::current()) 429 if (!is_swapped_out_ && RenderProcess::current())
426 RenderProcess::current()->ReleaseProcess(); 430 RenderProcess::current()->ReleaseProcess();
427 } 431 }
428 432
429 // static 433 // static
430 RenderWidget* RenderWidget::Create(int32 opener_id, 434 RenderWidget* RenderWidget::Create(int32 opener_id,
431 blink::WebPopupType popup_type, 435 blink::WebPopupType popup_type,
432 const blink::WebScreenInfo& screen_info) { 436 const blink::WebScreenInfo& screen_info) {
433 DCHECK(opener_id != MSG_ROUTING_NONE); 437 DCHECK(opener_id != MSG_ROUTING_NONE);
434 scoped_refptr<RenderWidget> widget( 438 scoped_refptr<RenderWidget> widget(
435 new RenderWidget(popup_type, screen_info, false, false)); 439 new RenderWidget(popup_type, screen_info, false, false, false));
436 if (widget->Init(opener_id)) { // adds reference on success. 440 if (widget->Init(opener_id)) { // adds reference on success.
437 return widget.get(); 441 return widget.get();
438 } 442 }
439 return NULL; 443 return NULL;
440 } 444 }
441 445
442 // static 446 // static
443 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { 447 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) {
444 switch (render_widget->popup_type_) { 448 switch (render_widget->popup_type_) {
445 case blink::WebPopupTypeNone: // Nothing to create. 449 case blink::WebPopupTypeNone: // Nothing to create.
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 } 793 }
790 794
791 void RenderWidget::OnWasHidden() { 795 void RenderWidget::OnWasHidden() {
792 TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden"); 796 TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden");
793 // Go into a mode where we stop generating paint and scrolling events. 797 // Go into a mode where we stop generating paint and scrolling events.
794 SetHidden(true); 798 SetHidden(true);
795 } 799 }
796 800
797 void RenderWidget::OnWasShown(bool needs_repainting) { 801 void RenderWidget::OnWasShown(bool needs_repainting) {
798 TRACE_EVENT0("renderer", "RenderWidget::OnWasShown"); 802 TRACE_EVENT0("renderer", "RenderWidget::OnWasShown");
803 DCHECK(!never_visible_);
804
799 // During shutdown we can just ignore this message. 805 // During shutdown we can just ignore this message.
800 if (!webwidget_) 806 if (!webwidget_)
801 return; 807 return;
802 808
803 // See OnWasHidden 809 // See OnWasHidden
804 SetHidden(false); 810 SetHidden(false);
805 811
806 if (!needs_repainting && !needs_repainting_on_restore_) 812 if (!needs_repainting && !needs_repainting_on_restore_)
807 return; 813 return;
808 needs_repainting_on_restore_ = false; 814 needs_repainting_on_restore_ = false;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 879
874 GURL RenderWidget::GetURLForGraphicsContext3D() { 880 GURL RenderWidget::GetURLForGraphicsContext3D() {
875 return GURL(); 881 return GURL();
876 } 882 }
877 883
878 bool RenderWidget::ForceCompositingModeEnabled() { 884 bool RenderWidget::ForceCompositingModeEnabled() {
879 return false; 885 return false;
880 } 886 }
881 887
882 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) { 888 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) {
889 if (never_visible_) {
890 // Background RenderWidgets never produce visible output, so generate a
891 // NullOutputSurface that does nothing for them, and avoids allocating
892 // GPU contexts.
893 return scoped_ptr<cc::OutputSurface>(new NullOutputSurface());
894 }
883 895
884 #if defined(OS_ANDROID) 896 #if defined(OS_ANDROID)
885 if (SynchronousCompositorFactory* factory = 897 if (SynchronousCompositorFactory* factory =
886 SynchronousCompositorFactory::GetInstance()) { 898 SynchronousCompositorFactory::GetInstance()) {
887 return factory->CreateOutputSurface(routing_id()); 899 return factory->CreateOutputSurface(routing_id());
888 } 900 }
889 #endif 901 #endif
890 902
891 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 903 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
892 bool use_software = fallback; 904 bool use_software = fallback;
(...skipping 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after
2879 2891
2880 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { 2892 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) {
2881 swapped_out_frames_.AddObserver(frame); 2893 swapped_out_frames_.AddObserver(frame);
2882 } 2894 }
2883 2895
2884 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { 2896 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) {
2885 swapped_out_frames_.RemoveObserver(frame); 2897 swapped_out_frames_.RemoveObserver(frame);
2886 } 2898 }
2887 2899
2888 } // namespace content 2900 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698