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 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1800 } | 1800 } |
1801 } | 1801 } |
1802 | 1802 |
1803 void RenderWidget::AutoResizeCompositor() { | 1803 void RenderWidget::AutoResizeCompositor() { |
1804 physical_backing_size_ = gfx::ToCeiledSize(gfx::ScaleSize(size_, | 1804 physical_backing_size_ = gfx::ToCeiledSize(gfx::ScaleSize(size_, |
1805 device_scale_factor_)); | 1805 device_scale_factor_)); |
1806 if (compositor_) | 1806 if (compositor_) |
1807 compositor_->setViewportSize(size_, physical_backing_size_); | 1807 compositor_->setViewportSize(size_, physical_backing_size_); |
1808 } | 1808 } |
1809 | 1809 |
| 1810 // FIXME: To be removed as soon as chromium and blink side changes land |
| 1811 // didActivateCompositor with parameters is still kept in order to land |
| 1812 // these changes s-chromium - https://codereview.chromium.org/137893025/. |
| 1813 // s-blink - https://codereview.chromium.org/138523003/ |
1810 void RenderWidget::didActivateCompositor(int input_handler_identifier) { | 1814 void RenderWidget::didActivateCompositor(int input_handler_identifier) { |
1811 TRACE_EVENT0("gpu", "RenderWidget::didActivateCompositor"); | 1815 TRACE_EVENT0("gpu", "RenderWidget::didActivateCompositor"); |
1812 | 1816 |
1813 #if !defined(OS_MACOSX) | 1817 #if !defined(OS_MACOSX) |
1814 if (!is_accelerated_compositing_active_) { | 1818 if (!is_accelerated_compositing_active_) { |
1815 // When not in accelerated compositing mode, in certain cases (e.g. waiting | 1819 // When not in accelerated compositing mode, in certain cases (e.g. waiting |
1816 // for a resize or if no backing store) the RenderWidgetHost is blocking the | 1820 // for a resize or if no backing store) the RenderWidgetHost is blocking the |
1817 // browser's UI thread for some time, waiting for an UpdateRect. If we are | 1821 // browser's UI thread for some time, waiting for an UpdateRect. If we are |
1818 // going to switch to accelerated compositing, the GPU process may need | 1822 // going to switch to accelerated compositing, the GPU process may need |
1819 // round-trips to the browser's UI thread before finishing the frame, | 1823 // round-trips to the browser's UI thread before finishing the frame, |
1820 // causing deadlocks if we delay the UpdateRect until we receive the | 1824 // causing deadlocks if we delay the UpdateRect until we receive the |
1821 // OnSwapBuffersComplete. So send a dummy message that will unblock the | 1825 // OnSwapBuffersComplete. So send a dummy message that will unblock the |
1822 // browser's UI thread. This is not necessary on Mac, because SwapBuffers | 1826 // browser's UI thread. This is not necessary on Mac, because SwapBuffers |
1823 // now unblocks GetBackingStore on Mac. | 1827 // now unblocks GetBackingStore on Mac. |
1824 Send(new ViewHostMsg_UpdateIsDelayed(routing_id_)); | 1828 Send(new ViewHostMsg_UpdateIsDelayed(routing_id_)); |
1825 } | 1829 } |
1826 #endif | 1830 #endif |
1827 | 1831 |
1828 is_accelerated_compositing_active_ = true; | 1832 is_accelerated_compositing_active_ = true; |
1829 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( | 1833 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( |
1830 routing_id_, is_accelerated_compositing_active_)); | 1834 routing_id_, is_accelerated_compositing_active_)); |
1831 | 1835 |
1832 if (!was_accelerated_compositing_ever_active_) { | 1836 if (!was_accelerated_compositing_ever_active_) { |
1833 was_accelerated_compositing_ever_active_ = true; | 1837 was_accelerated_compositing_ever_active_ = true; |
1834 webwidget_->enterForceCompositingMode(true); | 1838 webwidget_->enterForceCompositingMode(true); |
1835 } | 1839 } |
1836 } | 1840 } |
1837 | 1841 |
| 1842 void RenderWidget::didActivateCompositor() { |
| 1843 TRACE_EVENT0("gpu", "RenderWidget::didActivateCompositor"); |
| 1844 |
| 1845 #if !defined(OS_MACOSX) |
| 1846 if (!is_accelerated_compositing_active_) { |
| 1847 // When not in accelerated compositing mode, in certain cases (e.g. waiting |
| 1848 // for a resize or if no backing store) the RenderWidgetHost is blocking the |
| 1849 // browser's UI thread for some time, waiting for an UpdateRect. If we are |
| 1850 // going to switch to accelerated compositing, the GPU process may need |
| 1851 // round-trips to the browser's UI thread before finishing the frame, |
| 1852 // causing deadlocks if we delay the UpdateRect until we receive the |
| 1853 // OnSwapBuffersComplete. So send a dummy message that will unblock the |
| 1854 // browser's UI thread. This is not necessary on Mac, because SwapBuffers |
| 1855 // now unblocks GetBackingStore on Mac. |
| 1856 Send(new ViewHostMsg_UpdateIsDelayed(routing_id_)); |
| 1857 } |
| 1858 #endif |
| 1859 |
| 1860 is_accelerated_compositing_active_ = true; |
| 1861 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( |
| 1862 routing_id_, is_accelerated_compositing_active_)); |
| 1863 |
| 1864 if (!was_accelerated_compositing_ever_active_) { |
| 1865 was_accelerated_compositing_ever_active_ = true; |
| 1866 webwidget_->enterForceCompositingMode(true); |
| 1867 } |
| 1868 } |
| 1869 |
1838 void RenderWidget::didDeactivateCompositor() { | 1870 void RenderWidget::didDeactivateCompositor() { |
1839 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor"); | 1871 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor"); |
1840 | 1872 |
1841 is_accelerated_compositing_active_ = false; | 1873 is_accelerated_compositing_active_ = false; |
1842 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( | 1874 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( |
1843 routing_id_, is_accelerated_compositing_active_)); | 1875 routing_id_, is_accelerated_compositing_active_)); |
1844 | 1876 |
1845 if (using_asynchronous_swapbuffers_) | 1877 if (using_asynchronous_swapbuffers_) |
1846 using_asynchronous_swapbuffers_ = false; | 1878 using_asynchronous_swapbuffers_ = false; |
1847 | 1879 |
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2784 | 2816 |
2785 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { | 2817 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { |
2786 swapped_out_frames_.AddObserver(frame); | 2818 swapped_out_frames_.AddObserver(frame); |
2787 } | 2819 } |
2788 | 2820 |
2789 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { | 2821 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { |
2790 swapped_out_frames_.RemoveObserver(frame); | 2822 swapped_out_frames_.RemoveObserver(frame); |
2791 } | 2823 } |
2792 | 2824 |
2793 } // namespace content | 2825 } // namespace content |
OLD | NEW |