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/logging.h" | 10 #include "base/logging.h" |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 void RenderWidget::SetExternalPopupOriginAdjustmentsForEmulation( | 551 void RenderWidget::SetExternalPopupOriginAdjustmentsForEmulation( |
552 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator) { | 552 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator) { |
553 popup->SetOriginScaleForEmulation(emulator->scale()); | 553 popup->SetOriginScaleForEmulation(emulator->scale()); |
554 } | 554 } |
555 | 555 |
556 void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) { | 556 void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) { |
557 if (screen_metrics_emulator_) | 557 if (screen_metrics_emulator_) |
558 screen_metrics_emulator_->OnShowContextMenu(params); | 558 screen_metrics_emulator_->OnShowContextMenu(params); |
559 } | 559 } |
560 | 560 |
561 void RenderWidget::ScheduleAnimation() { | |
562 if (animation_update_pending_) | |
563 return; | |
564 | |
565 TRACE_EVENT0("gpu", "RenderWidget::ScheduleAnimation"); | |
566 animation_update_pending_ = true; | |
567 if (!animation_timer_.IsRunning()) { | |
568 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this, | |
569 &RenderWidget::AnimationCallback); | |
570 } | |
571 } | |
572 | |
573 void RenderWidget::ScheduleComposite() { | |
574 if (RenderThreadImpl::current()->compositor_message_loop_proxy().get() && | |
575 compositor_) { | |
576 compositor_->setNeedsAnimate(); | |
danakj
2013/12/05 18:28:16
git cl format
trchen
2013/12/06 03:42:39
Done.
| |
577 } else { | |
578 // TODO(nduca): replace with something a little less hacky. The reason this | |
579 // hack is still used is because the Invalidate-DoDeferredUpdate loop | |
580 // contains a lot of host-renderer synchronization logic that is still | |
581 // important for the accelerated compositing case. The option of simply | |
582 // duplicating all that code is less desirable than "faking out" the | |
583 // invalidation path using a magical damage rect. | |
584 didInvalidateRect(WebRect(0, 0, 1, 1)); | |
585 } | |
586 } | |
587 | |
561 void RenderWidget::ScheduleCompositeWithForcedRedraw() { | 588 void RenderWidget::ScheduleCompositeWithForcedRedraw() { |
562 if (compositor_) { | 589 if (compositor_) { |
563 // Regardless of whether threaded compositing is enabled, always | 590 // Regardless of whether threaded compositing is enabled, always |
564 // use this mechanism to force the compositor to redraw. However, | 591 // use this mechanism to force the compositor to redraw. However, |
565 // the invalidation code path below is still needed for the | 592 // the invalidation code path below is still needed for the |
566 // non-threaded case. | 593 // non-threaded case. |
567 compositor_->SetNeedsForcedRedraw(); | 594 compositor_->SetNeedsForcedRedraw(); |
568 } | 595 } |
569 scheduleComposite(); | 596 ScheduleComposite(); |
570 } | 597 } |
571 | 598 |
572 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { | 599 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { |
573 bool handled = true; | 600 bool handled = true; |
574 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) | 601 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) |
575 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) | 602 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) |
576 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, | 603 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, |
577 OnCursorVisibilityChange) | 604 OnCursorVisibilityChange) |
578 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) | 605 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) |
579 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) | 606 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
794 needs_repainting_on_restore_ = false; | 821 needs_repainting_on_restore_ = false; |
795 | 822 |
796 // Tag the next paint as a restore ack, which is picked up by | 823 // Tag the next paint as a restore ack, which is picked up by |
797 // DoDeferredUpdate when it sends out the next PaintRect message. | 824 // DoDeferredUpdate when it sends out the next PaintRect message. |
798 set_next_paint_is_restore_ack(); | 825 set_next_paint_is_restore_ack(); |
799 | 826 |
800 // Generate a full repaint. | 827 // Generate a full repaint. |
801 if (!is_accelerated_compositing_active_) { | 828 if (!is_accelerated_compositing_active_) { |
802 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); | 829 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); |
803 } else { | 830 } else { |
804 if (compositor_) | 831 ScheduleCompositeWithForcedRedraw(); |
805 compositor_->SetNeedsForcedRedraw(); | |
806 scheduleComposite(); | |
807 } | 832 } |
808 } | 833 } |
809 | 834 |
810 void RenderWidget::OnWasSwappedOut() { | 835 void RenderWidget::OnWasSwappedOut() { |
811 // If we have been swapped out and no one else is using this process, | 836 // If we have been swapped out and no one else is using this process, |
812 // it's safe to exit now. If we get swapped back in, we will call | 837 // it's safe to exit now. If we get swapped back in, we will call |
813 // AddRefProcess in SetSwappedOut. | 838 // AddRefProcess in SetSwappedOut. |
814 if (is_swapped_out_) | 839 if (is_swapped_out_) |
815 RenderProcess::current()->ReleaseProcess(); | 840 RenderProcess::current()->ReleaseProcess(); |
816 } | 841 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
961 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); | 986 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); |
962 updates_pending_swap_.pop_front(); | 987 updates_pending_swap_.pop_front(); |
963 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate | 988 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate |
964 // compositing pass, hence doesn't require an UpdateRect message. | 989 // compositing pass, hence doesn't require an UpdateRect message. |
965 if (msg) | 990 if (msg) |
966 Send(msg); | 991 Send(msg); |
967 } | 992 } |
968 num_swapbuffers_complete_pending_ = 0; | 993 num_swapbuffers_complete_pending_ = 0; |
969 using_asynchronous_swapbuffers_ = false; | 994 using_asynchronous_swapbuffers_ = false; |
970 // Schedule another frame so the compositor learns about it. | 995 // Schedule another frame so the compositor learns about it. |
971 scheduleComposite(); | 996 ScheduleComposite(); |
972 } | 997 } |
973 | 998 |
974 void RenderWidget::OnSwapBuffersPosted() { | 999 void RenderWidget::OnSwapBuffersPosted() { |
975 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted"); | 1000 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted"); |
976 | 1001 |
977 if (using_asynchronous_swapbuffers_) { | 1002 if (using_asynchronous_swapbuffers_) { |
978 ViewHostMsg_UpdateRect* msg = NULL; | 1003 ViewHostMsg_UpdateRect* msg = NULL; |
979 // pending_update_params_ can be NULL if the swap doesn't correspond to an | 1004 // pending_update_params_ can be NULL if the swap doesn't correspond to an |
980 // DoDeferredUpdate compositing pass, hence doesn't require an UpdateRect | 1005 // DoDeferredUpdate compositing pass, hence doesn't require an UpdateRect |
981 // message. | 1006 // message. |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1908 params.flags = next_paint_flags_; | 1933 params.flags = next_paint_flags_; |
1909 params.scroll_offset = GetScrollOffset(); | 1934 params.scroll_offset = GetScrollOffset(); |
1910 params.needs_ack = false; | 1935 params.needs_ack = false; |
1911 params.scale_factor = device_scale_factor_; | 1936 params.scale_factor = device_scale_factor_; |
1912 | 1937 |
1913 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); | 1938 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); |
1914 next_paint_flags_ = 0; | 1939 next_paint_flags_ = 0; |
1915 need_update_rect_for_auto_resize_ = false; | 1940 need_update_rect_for_auto_resize_ = false; |
1916 } | 1941 } |
1917 | 1942 |
1918 void RenderWidget::scheduleComposite() { | 1943 // Renamed. Staged for removal. |
1919 if (RenderThreadImpl::current()->compositor_message_loop_proxy().get() && | 1944 void RenderWidget::scheduleAnimation() { scheduleUpdate(); } |
1920 compositor_) { | |
1921 compositor_->setNeedsAnimate(); | |
1922 } else { | |
1923 // TODO(nduca): replace with something a little less hacky. The reason this | |
1924 // hack is still used is because the Invalidate-DoDeferredUpdate loop | |
1925 // contains a lot of host-renderer synchronization logic that is still | |
1926 // important for the accelerated compositing case. The option of simply | |
1927 // duplicating all that code is less desirable than "faking out" the | |
1928 // invalidation path using a magical damage rect. | |
1929 didInvalidateRect(WebRect(0, 0, 1, 1)); | |
1930 } | |
1931 } | |
1932 | 1945 |
1933 void RenderWidget::scheduleAnimation() { | 1946 void RenderWidget::scheduleUpdate() { |
1934 if (animation_update_pending_) | 1947 if (compositor_) |
1935 return; | 1948 compositor_->setNeedsUpdateLayers(); |
1936 | 1949 else |
1937 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation"); | 1950 ScheduleAnimation(); |
1938 animation_update_pending_ = true; | |
1939 if (!animation_timer_.IsRunning()) { | |
1940 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this, | |
1941 &RenderWidget::AnimationCallback); | |
1942 } | |
1943 } | 1951 } |
1944 | 1952 |
1945 void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) { | 1953 void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) { |
1946 // TODO(darin): Eliminate this temporary. | 1954 // TODO(darin): Eliminate this temporary. |
1947 WebCursor cursor; | 1955 WebCursor cursor; |
1948 InitializeCursorFromWebKitCursorInfo(&cursor, cursor_info); | 1956 InitializeCursorFromWebKitCursorInfo(&cursor, cursor_info); |
1949 // Only send a SetCursor message if we need to make a change. | 1957 // Only send a SetCursor message if we need to make a change. |
1950 if (!current_cursor_.IsEqual(cursor)) { | 1958 if (!current_cursor_.IsEqual(cursor)) { |
1951 current_cursor_ = cursor; | 1959 current_cursor_ = cursor; |
1952 Send(new ViewHostMsg_SetCursor(routing_id_, cursor)); | 1960 Send(new ViewHostMsg_SetCursor(routing_id_, cursor)); |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2337 | 2345 |
2338 void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) { | 2346 void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) { |
2339 if (device_scale_factor_ == device_scale_factor) | 2347 if (device_scale_factor_ == device_scale_factor) |
2340 return; | 2348 return; |
2341 | 2349 |
2342 device_scale_factor_ = device_scale_factor; | 2350 device_scale_factor_ = device_scale_factor; |
2343 | 2351 |
2344 if (!is_accelerated_compositing_active_) { | 2352 if (!is_accelerated_compositing_active_) { |
2345 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); | 2353 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); |
2346 } else { | 2354 } else { |
2347 scheduleComposite(); | 2355 ScheduleComposite(); |
2348 } | 2356 } |
2349 } | 2357 } |
2350 | 2358 |
2351 PepperPluginInstanceImpl* RenderWidget::GetBitmapForOptimizedPluginPaint( | 2359 PepperPluginInstanceImpl* RenderWidget::GetBitmapForOptimizedPluginPaint( |
2352 const gfx::Rect& paint_bounds, | 2360 const gfx::Rect& paint_bounds, |
2353 TransportDIB** dib, | 2361 TransportDIB** dib, |
2354 gfx::Rect* location, | 2362 gfx::Rect* location, |
2355 gfx::Rect* clip, | 2363 gfx::Rect* clip, |
2356 float* scale_factor) { | 2364 float* scale_factor) { |
2357 // Bare RenderWidgets don't support optimized plugin painting. | 2365 // Bare RenderWidgets don't support optimized plugin painting. |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2839 GetURLForGraphicsContext3D(), | 2847 GetURLForGraphicsContext3D(), |
2840 gpu_channel_host.get(), | 2848 gpu_channel_host.get(), |
2841 use_echo_for_swap_ack, | 2849 use_echo_for_swap_ack, |
2842 attributes, | 2850 attributes, |
2843 false /* bind generates resources */, | 2851 false /* bind generates resources */, |
2844 limits)); | 2852 limits)); |
2845 return context.Pass(); | 2853 return context.Pass(); |
2846 } | 2854 } |
2847 | 2855 |
2848 } // namespace content | 2856 } // namespace content |
OLD | NEW |