OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1675 // drawn. | 1675 // drawn. |
1676 if (active_tree_->hud_layer()) { | 1676 if (active_tree_->hud_layer()) { |
1677 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); | 1677 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); |
1678 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, | 1678 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, |
1679 resource_provider_.get()); | 1679 resource_provider_.get()); |
1680 } | 1680 } |
1681 | 1681 |
1682 renderer_->DrawFrame(&frame->render_passes); | 1682 renderer_->DrawFrame(&frame->render_passes); |
1683 // The render passes should be consumed by the renderer. | 1683 // The render passes should be consumed by the renderer. |
1684 DCHECK(frame->render_passes.empty()); | 1684 DCHECK(frame->render_passes.empty()); |
1685 | |
1686 // The next frame should start by assuming nothing has changed, and changes | |
1687 // are noted as they occur. | |
1688 // TODO(boliu): If we did a temporary software renderer frame, propogate the | |
1689 // damage forward to the next frame. | |
1690 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) { | |
1691 (*frame->render_surface_layer_list)[i] | |
1692 ->render_surface() | |
1693 ->damage_tracker() | |
1694 ->DidDrawDamagedArea(); | |
1695 } | |
1696 active_tree_->ResetAllChangeTracking(); | |
1697 | |
1698 active_tree_->set_has_ever_been_drawn(true); | |
1699 devtools_instrumentation::DidDrawFrame(id_); | |
1700 benchmark_instrumentation::IssueImplThreadRenderingStatsEvent( | |
1701 rendering_stats_instrumentation_->impl_thread_rendering_stats()); | |
1702 rendering_stats_instrumentation_->AccumulateAndClearImplThreadStats(); | |
1703 } | 1685 } |
1704 | 1686 |
1705 void LayerTreeHostImpl::DidDrawAllLayers(const FrameData& frame) { | 1687 void LayerTreeHostImpl::DidDrawAllLayers(const FrameData& frame) { |
1706 for (size_t i = 0; i < frame.will_draw_layers.size(); ++i) | 1688 for (size_t i = 0; i < frame.will_draw_layers.size(); ++i) |
1707 frame.will_draw_layers[i]->DidDraw(resource_provider_.get()); | 1689 frame.will_draw_layers[i]->DidDraw(resource_provider_.get()); |
1708 | 1690 |
1709 for (auto* it : video_frame_controllers_) | 1691 for (auto* it : video_frame_controllers_) |
1710 it->DidDrawFrame(); | 1692 it->DidDrawFrame(); |
1711 } | 1693 } |
1712 | 1694 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1833 | 1815 |
1834 // We have released tilings for both active and pending tree. | 1816 // We have released tilings for both active and pending tree. |
1835 // We would not have any content to draw until the pending tree is activated. | 1817 // We would not have any content to draw until the pending tree is activated. |
1836 // Prevent the active tree from drawing until activation. | 1818 // Prevent the active tree from drawing until activation. |
1837 // TODO(crbug.com/469175): Replace with RequiresHighResToDraw. | 1819 // TODO(crbug.com/469175): Replace with RequiresHighResToDraw. |
1838 SetRequiresHighResToDraw(); | 1820 SetRequiresHighResToDraw(); |
1839 } | 1821 } |
1840 | 1822 |
1841 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { | 1823 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { |
1842 ResetRequiresHighResToDraw(); | 1824 ResetRequiresHighResToDraw(); |
| 1825 |
1843 if (frame.has_no_damage) { | 1826 if (frame.has_no_damage) { |
1844 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); | 1827 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); |
1845 return false; | 1828 return false; |
1846 } | 1829 } |
| 1830 |
1847 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); | 1831 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); |
1848 metadata.may_contain_video = frame.may_contain_video; | 1832 metadata.may_contain_video = frame.may_contain_video; |
1849 active_tree()->FinishSwapPromises(&metadata); | 1833 active_tree()->FinishSwapPromises(&metadata); |
1850 for (auto& latency : metadata.latency_info) { | 1834 for (auto& latency : metadata.latency_info) { |
1851 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow", | 1835 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow", |
1852 TRACE_ID_DONT_MANGLE(latency.trace_id()), | 1836 TRACE_ID_DONT_MANGLE(latency.trace_id()), |
1853 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, | 1837 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, |
1854 "step", "SwapBuffers"); | 1838 "step", "SwapBuffers"); |
1855 // Only add the latency component once for renderer swap, not the browser | 1839 // Only add the latency component once for renderer swap, not the browser |
1856 // swap. | 1840 // swap. |
1857 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, | 1841 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, |
1858 nullptr)) { | 1842 nullptr)) { |
1859 latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, | 1843 latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, |
1860 0, 0); | 1844 0, 0); |
1861 } | 1845 } |
1862 } | 1846 } |
1863 renderer_->SwapBuffers(std::move(metadata)); | 1847 renderer_->SwapBuffers(std::move(metadata)); |
| 1848 |
| 1849 // The next frame should start by assuming nothing has changed, and changes |
| 1850 // are noted as they occur. |
| 1851 // TODO(boliu): If we did a temporary software renderer frame, propogate the |
| 1852 // damage forward to the next frame. |
| 1853 for (size_t i = 0; i < frame.render_surface_layer_list->size(); i++) { |
| 1854 auto* surface = (*frame.render_surface_layer_list)[i]->render_surface(); |
| 1855 surface->damage_tracker()->DidDrawDamagedArea(); |
| 1856 } |
| 1857 active_tree_->ResetAllChangeTracking(); |
| 1858 |
| 1859 active_tree_->set_has_ever_been_drawn(true); |
| 1860 devtools_instrumentation::DidDrawFrame(id_); |
| 1861 benchmark_instrumentation::IssueImplThreadRenderingStatsEvent( |
| 1862 rendering_stats_instrumentation_->impl_thread_rendering_stats()); |
| 1863 rendering_stats_instrumentation_->AccumulateAndClearImplThreadStats(); |
1864 return true; | 1864 return true; |
1865 } | 1865 } |
1866 | 1866 |
1867 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1867 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
1868 current_begin_frame_tracker_.Start(args); | 1868 current_begin_frame_tracker_.Start(args); |
1869 | 1869 |
1870 if (is_likely_to_require_a_draw_) { | 1870 if (is_likely_to_require_a_draw_) { |
1871 // Optimistically schedule a draw. This will let us expect the tile manager | 1871 // Optimistically schedule a draw. This will let us expect the tile manager |
1872 // to complete its work so that we can draw new tiles within the impl frame | 1872 // to complete its work so that we can draw new tiles within the impl frame |
1873 // we are beginning now. | 1873 // we are beginning now. |
(...skipping 2322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4196 if (is_visible) { | 4196 if (is_visible) { |
4197 worker_context_visibility_ = | 4197 worker_context_visibility_ = |
4198 worker_context->CacheController()->ClientBecameVisible(); | 4198 worker_context->CacheController()->ClientBecameVisible(); |
4199 } else { | 4199 } else { |
4200 worker_context->CacheController()->ClientBecameNotVisible( | 4200 worker_context->CacheController()->ClientBecameNotVisible( |
4201 std::move(worker_context_visibility_)); | 4201 std::move(worker_context_visibility_)); |
4202 } | 4202 } |
4203 } | 4203 } |
4204 | 4204 |
4205 } // namespace cc | 4205 } // namespace cc |
OLD | NEW |