OLD | NEW |
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 Loading... |
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 Loading... |
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 background) |
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 is_background_(background), |
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), |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 if (!is_swapped_out_ && RenderProcess::current()) | 428 if (!is_swapped_out_ && RenderProcess::current()) |
426 RenderProcess::current()->ReleaseProcess(); | 429 RenderProcess::current()->ReleaseProcess(); |
427 } | 430 } |
428 | 431 |
429 // static | 432 // static |
430 RenderWidget* RenderWidget::Create(int32 opener_id, | 433 RenderWidget* RenderWidget::Create(int32 opener_id, |
431 blink::WebPopupType popup_type, | 434 blink::WebPopupType popup_type, |
432 const blink::WebScreenInfo& screen_info) { | 435 const blink::WebScreenInfo& screen_info) { |
433 DCHECK(opener_id != MSG_ROUTING_NONE); | 436 DCHECK(opener_id != MSG_ROUTING_NONE); |
434 scoped_refptr<RenderWidget> widget( | 437 scoped_refptr<RenderWidget> widget( |
435 new RenderWidget(popup_type, screen_info, false, false)); | 438 new RenderWidget(popup_type, screen_info, false, false, false)); |
436 if (widget->Init(opener_id)) { // adds reference on success. | 439 if (widget->Init(opener_id)) { // adds reference on success. |
437 return widget.get(); | 440 return widget.get(); |
438 } | 441 } |
439 return NULL; | 442 return NULL; |
440 } | 443 } |
441 | 444 |
442 // static | 445 // static |
443 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { | 446 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { |
444 switch (render_widget->popup_type_) { | 447 switch (render_widget->popup_type_) { |
445 case blink::WebPopupTypeNone: // Nothing to create. | 448 case blink::WebPopupTypeNone: // Nothing to create. |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 | 876 |
874 GURL RenderWidget::GetURLForGraphicsContext3D() { | 877 GURL RenderWidget::GetURLForGraphicsContext3D() { |
875 return GURL(); | 878 return GURL(); |
876 } | 879 } |
877 | 880 |
878 bool RenderWidget::ForceCompositingModeEnabled() { | 881 bool RenderWidget::ForceCompositingModeEnabled() { |
879 return false; | 882 return false; |
880 } | 883 } |
881 | 884 |
882 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) { | 885 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) { |
| 886 if (is_background_) { |
| 887 // Background RenderWidgets never produce visible output, so generate a |
| 888 // NullOutputSurface that does nothing for them, and avoids allocating |
| 889 // GPU contexts. |
| 890 return scoped_ptr<cc::OutputSurface>(new NullOutputSurface()); |
| 891 } |
883 | 892 |
884 #if defined(OS_ANDROID) | 893 #if defined(OS_ANDROID) |
885 if (SynchronousCompositorFactory* factory = | 894 if (SynchronousCompositorFactory* factory = |
886 SynchronousCompositorFactory::GetInstance()) { | 895 SynchronousCompositorFactory::GetInstance()) { |
887 return factory->CreateOutputSurface(routing_id()); | 896 return factory->CreateOutputSurface(routing_id()); |
888 } | 897 } |
889 #endif | 898 #endif |
890 | 899 |
891 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 900 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
892 bool use_software = fallback; | 901 bool use_software = fallback; |
(...skipping 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2879 | 2888 |
2880 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { | 2889 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { |
2881 swapped_out_frames_.AddObserver(frame); | 2890 swapped_out_frames_.AddObserver(frame); |
2882 } | 2891 } |
2883 | 2892 |
2884 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { | 2893 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { |
2885 swapped_out_frames_.RemoveObserver(frame); | 2894 swapped_out_frames_.RemoveObserver(frame); |
2886 } | 2895 } |
2887 | 2896 |
2888 } // namespace content | 2897 } // namespace content |
OLD | NEW |