Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(577)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 2317493003: cc: Toward merging DrawFrame and SwapBuffers in DelegatingRenderer. (Closed)
Patch Set: merge-draw-swap Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 // drawn. 1716 // drawn.
1717 if (active_tree_->hud_layer()) { 1717 if (active_tree_->hud_layer()) {
1718 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); 1718 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture");
1719 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, 1719 active_tree_->hud_layer()->UpdateHudTexture(draw_mode,
1720 resource_provider_.get()); 1720 resource_provider_.get());
1721 } 1721 }
1722 1722
1723 renderer_->DrawFrame(&frame->render_passes); 1723 renderer_->DrawFrame(&frame->render_passes);
1724 // The render passes should be consumed by the renderer. 1724 // The render passes should be consumed by the renderer.
1725 DCHECK(frame->render_passes.empty()); 1725 DCHECK(frame->render_passes.empty());
1726
1727 // The next frame should start by assuming nothing has changed, and changes
1728 // are noted as they occur.
1729 // TODO(boliu): If we did a temporary software renderer frame, propogate the
1730 // damage forward to the next frame.
1731 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) {
1732 (*frame->render_surface_layer_list)[i]
1733 ->render_surface()
1734 ->damage_tracker()
1735 ->DidDrawDamagedArea();
1736 }
1737 active_tree_->ResetAllChangeTracking();
1738
1739 active_tree_->set_has_ever_been_drawn(true);
1740 devtools_instrumentation::DidDrawFrame(id_);
1741 benchmark_instrumentation::IssueImplThreadRenderingStatsEvent(
1742 rendering_stats_instrumentation_->impl_thread_rendering_stats());
1743 rendering_stats_instrumentation_->AccumulateAndClearImplThreadStats();
1744 } 1726 }
1745 1727
1746 void LayerTreeHostImpl::DidDrawAllLayers(const FrameData& frame) { 1728 void LayerTreeHostImpl::DidDrawAllLayers(const FrameData& frame) {
1747 for (size_t i = 0; i < frame.will_draw_layers.size(); ++i) 1729 for (size_t i = 0; i < frame.will_draw_layers.size(); ++i)
1748 frame.will_draw_layers[i]->DidDraw(resource_provider_.get()); 1730 frame.will_draw_layers[i]->DidDraw(resource_provider_.get());
1749 1731
1750 for (auto* it : video_frame_controllers_) 1732 for (auto* it : video_frame_controllers_)
1751 it->DidDrawFrame(); 1733 it->DidDrawFrame();
1752 } 1734 }
1753 1735
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1874 1856
1875 // We have released tilings for both active and pending tree. 1857 // We have released tilings for both active and pending tree.
1876 // We would not have any content to draw until the pending tree is activated. 1858 // We would not have any content to draw until the pending tree is activated.
1877 // Prevent the active tree from drawing until activation. 1859 // Prevent the active tree from drawing until activation.
1878 // TODO(crbug.com/469175): Replace with RequiresHighResToDraw. 1860 // TODO(crbug.com/469175): Replace with RequiresHighResToDraw.
1879 SetRequiresHighResToDraw(); 1861 SetRequiresHighResToDraw();
1880 } 1862 }
1881 1863
1882 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { 1864 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) {
1883 ResetRequiresHighResToDraw(); 1865 ResetRequiresHighResToDraw();
1866
1884 if (frame.has_no_damage) { 1867 if (frame.has_no_damage) {
1885 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); 1868 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS);
1886 return false; 1869 return false;
1887 } 1870 }
1871
1888 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); 1872 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata();
1889 metadata.may_contain_video = frame.may_contain_video; 1873 metadata.may_contain_video = frame.may_contain_video;
1890 active_tree()->FinishSwapPromises(&metadata); 1874 active_tree()->FinishSwapPromises(&metadata);
1891 for (auto& latency : metadata.latency_info) { 1875 for (auto& latency : metadata.latency_info) {
1892 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow", 1876 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow",
1893 TRACE_ID_DONT_MANGLE(latency.trace_id()), 1877 TRACE_ID_DONT_MANGLE(latency.trace_id()),
1894 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, 1878 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT,
1895 "step", "SwapBuffers"); 1879 "step", "SwapBuffers");
1896 // Only add the latency component once for renderer swap, not the browser 1880 // Only add the latency component once for renderer swap, not the browser
1897 // swap. 1881 // swap.
1898 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, 1882 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0,
1899 nullptr)) { 1883 nullptr)) {
1900 latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 1884 latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT,
1901 0, 0); 1885 0, 0);
1902 } 1886 }
1903 } 1887 }
1904 renderer_->SwapBuffers(std::move(metadata)); 1888 renderer_->SwapBuffers(std::move(metadata));
1889
1890 // The next frame should start by assuming nothing has changed, and changes
1891 // are noted as they occur.
1892 // TODO(boliu): If we did a temporary software renderer frame, propogate the
1893 // damage forward to the next frame.
1894 for (size_t i = 0; i < frame.render_surface_layer_list->size(); i++) {
1895 auto* surface = (*frame.render_surface_layer_list)[i]->render_surface();
1896 surface->damage_tracker()->DidDrawDamagedArea();
1897 }
1898 active_tree_->ResetAllChangeTracking();
1899
1900 active_tree_->set_has_ever_been_drawn(true);
1901 devtools_instrumentation::DidDrawFrame(id_);
1902 benchmark_instrumentation::IssueImplThreadRenderingStatsEvent(
1903 rendering_stats_instrumentation_->impl_thread_rendering_stats());
1904 rendering_stats_instrumentation_->AccumulateAndClearImplThreadStats();
1905 return true; 1905 return true;
1906 } 1906 }
1907 1907
1908 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { 1908 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) {
1909 current_begin_frame_tracker_.Start(args); 1909 current_begin_frame_tracker_.Start(args);
1910 1910
1911 if (is_likely_to_require_a_draw_) { 1911 if (is_likely_to_require_a_draw_) {
1912 // Optimistically schedule a draw. This will let us expect the tile manager 1912 // Optimistically schedule a draw. This will let us expect the tile manager
1913 // to complete its work so that we can draw new tiles within the impl frame 1913 // to complete its work so that we can draw new tiles within the impl frame
1914 // we are beginning now. 1914 // we are beginning now.
(...skipping 2268 matching lines...) Expand 10 before | Expand all | Expand 10 after
4183 return task_runner_provider_->HasImplThread(); 4183 return task_runner_provider_->HasImplThread();
4184 } 4184 }
4185 4185
4186 bool LayerTreeHostImpl::CommitToActiveTree() const { 4186 bool LayerTreeHostImpl::CommitToActiveTree() const {
4187 // In single threaded mode we skip the pending tree and commit directly to the 4187 // In single threaded mode we skip the pending tree and commit directly to the
4188 // active tree. 4188 // active tree.
4189 return !task_runner_provider_->HasImplThread(); 4189 return !task_runner_provider_->HasImplThread();
4190 } 4190 }
4191 4191
4192 } // namespace cc 4192 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698