| 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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 void RenderWidget::SetExternalPopupOriginAdjustmentsForEmulation( | 575 void RenderWidget::SetExternalPopupOriginAdjustmentsForEmulation( |
| 576 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator) { | 576 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator) { |
| 577 popup->SetOriginScaleForEmulation(emulator->scale()); | 577 popup->SetOriginScaleForEmulation(emulator->scale()); |
| 578 } | 578 } |
| 579 | 579 |
| 580 void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) { | 580 void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) { |
| 581 if (screen_metrics_emulator_) | 581 if (screen_metrics_emulator_) |
| 582 screen_metrics_emulator_->OnShowContextMenu(params); | 582 screen_metrics_emulator_->OnShowContextMenu(params); |
| 583 } | 583 } |
| 584 | 584 |
| 585 void RenderWidget::ScheduleCompositeWithForcedRedraw() { |
| 586 if (compositor_) { |
| 587 // Regardless of whether threaded compositing is enabled, always |
| 588 // use this mechanism to force the compositor to redraw. However, |
| 589 // the invalidation code path below is still needed for the |
| 590 // non-threaded case. |
| 591 compositor_->SetNeedsForcedRedraw(); |
| 592 } |
| 593 ScheduleCompositeImpl(true); |
| 594 } |
| 595 |
| 596 void RenderWidget::ScheduleCompositeImpl(bool force_redraw) { |
| 597 if (RenderThreadImpl::current()->compositor_message_loop_proxy().get() && |
| 598 compositor_) { |
| 599 if (!force_redraw) { |
| 600 compositor_->setNeedsRedraw(); |
| 601 } |
| 602 } else { |
| 603 // TODO(nduca): replace with something a little less hacky. The reason this |
| 604 // hack is still used is because the Invalidate-DoDeferredUpdate loop |
| 605 // contains a lot of host-renderer synchronization logic that is still |
| 606 // important for the accelerated compositing case. The option of simply |
| 607 // duplicating all that code is less desirable than "faking out" the |
| 608 // invalidation path using a magical damage rect. |
| 609 didInvalidateRect(WebRect(0, 0, 1, 1)); |
| 610 } |
| 611 } |
| 612 |
| 585 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { | 613 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { |
| 586 bool handled = true; | 614 bool handled = true; |
| 587 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) | 615 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) |
| 588 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) | 616 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) |
| 589 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, | 617 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, |
| 590 OnCursorVisibilityChange) | 618 OnCursorVisibilityChange) |
| 591 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) | 619 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) |
| 592 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) | 620 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) |
| 593 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) | 621 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
| 594 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) | 622 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) |
| (...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1876 params.scroll_offset = GetScrollOffset(); | 1904 params.scroll_offset = GetScrollOffset(); |
| 1877 params.needs_ack = false; | 1905 params.needs_ack = false; |
| 1878 params.scale_factor = device_scale_factor_; | 1906 params.scale_factor = device_scale_factor_; |
| 1879 | 1907 |
| 1880 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); | 1908 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); |
| 1881 next_paint_flags_ = 0; | 1909 next_paint_flags_ = 0; |
| 1882 need_update_rect_for_auto_resize_ = false; | 1910 need_update_rect_for_auto_resize_ = false; |
| 1883 } | 1911 } |
| 1884 | 1912 |
| 1885 void RenderWidget::scheduleComposite() { | 1913 void RenderWidget::scheduleComposite() { |
| 1886 if (RenderThreadImpl::current()->compositor_message_loop_proxy().get() && | 1914 ScheduleCompositeImpl(false); |
| 1887 compositor_) { | |
| 1888 compositor_->setNeedsRedraw(); | |
| 1889 } else { | |
| 1890 // TODO(nduca): replace with something a little less hacky. The reason this | |
| 1891 // hack is still used is because the Invalidate-DoDeferredUpdate loop | |
| 1892 // contains a lot of host-renderer synchronization logic that is still | |
| 1893 // important for the accelerated compositing case. The option of simply | |
| 1894 // duplicating all that code is less desirable than "faking out" the | |
| 1895 // invalidation path using a magical damage rect. | |
| 1896 didInvalidateRect(WebRect(0, 0, 1, 1)); | |
| 1897 } | |
| 1898 } | 1915 } |
| 1899 | 1916 |
| 1900 void RenderWidget::scheduleAnimation() { | 1917 void RenderWidget::scheduleAnimation() { |
| 1901 if (animation_update_pending_) | 1918 if (animation_update_pending_) |
| 1902 return; | 1919 return; |
| 1903 | 1920 |
| 1904 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation"); | 1921 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation"); |
| 1905 animation_update_pending_ = true; | 1922 animation_update_pending_ = true; |
| 1906 if (!animation_timer_.IsRunning()) { | 1923 if (!animation_timer_.IsRunning()) { |
| 1907 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this, | 1924 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this, |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2818 kDefaultCommandBufferSize, | 2835 kDefaultCommandBufferSize, |
| 2819 kDefaultStartTransferBufferSize, | 2836 kDefaultStartTransferBufferSize, |
| 2820 kDefaultMinTransferBufferSize, | 2837 kDefaultMinTransferBufferSize, |
| 2821 kDefaultMaxTransferBufferSize, | 2838 kDefaultMaxTransferBufferSize, |
| 2822 mapped_memory_reclaim_limit)) | 2839 mapped_memory_reclaim_limit)) |
| 2823 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 2840 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
| 2824 return context.Pass(); | 2841 return context.Pass(); |
| 2825 } | 2842 } |
| 2826 | 2843 |
| 2827 } // namespace content | 2844 } // namespace content |
| OLD | NEW |