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

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

Issue 2317493003: cc: Toward merging DrawFrame and SwapBuffers in DelegatingRenderer. (Closed)
Patch Set: 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 bool swapped = false;
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 } else {
1870 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata();
1871 metadata.may_contain_video = frame.may_contain_video;
1872 active_tree()->FinishSwapPromises(&metadata);
1873 for (auto& latency : metadata.latency_info) {
1874 TRACE_EVENT_WITH_FLOW1(
1875 "input,benchmark", "LatencyInfo.Flow",
1876 TRACE_ID_DONT_MANGLE(latency.trace_id()),
1877 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, "step",
1878 "SwapBuffers");
1879 // Only add the latency component once for renderer swap, not the browser
1880 // swap.
1881 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT,
1882 0, nullptr)) {
1883 latency.AddLatencyNumber(
1884 ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, 0);
1885 }
1886 }
1887 renderer_->SwapBuffers(std::move(metadata));
1888 swapped = true;
1887 } 1889 }
1888 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); 1890
1889 metadata.may_contain_video = frame.may_contain_video; 1891 // The next frame should start by assuming nothing has changed, and changes
danakj 2016/09/07 00:25:35 I think this stuff shouldn't actually happen if ha
danakj 2016/09/07 00:32:15 Fixed.
1890 active_tree()->FinishSwapPromises(&metadata); 1892 // are noted as they occur.
1891 for (auto& latency : metadata.latency_info) { 1893 // TODO(boliu): If we did a temporary software renderer frame, propogate the
1892 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow", 1894 // damage forward to the next frame.
1893 TRACE_ID_DONT_MANGLE(latency.trace_id()), 1895 for (size_t i = 0; i < frame.render_surface_layer_list->size(); i++) {
1894 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, 1896 auto* surface = (*frame.render_surface_layer_list)[i]->render_surface();
1895 "step", "SwapBuffers"); 1897 surface->damage_tracker()->DidDrawDamagedArea();
1896 // Only add the latency component once for renderer swap, not the browser
1897 // swap.
1898 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0,
1899 nullptr)) {
1900 latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT,
1901 0, 0);
1902 }
1903 } 1898 }
1904 renderer_->SwapBuffers(std::move(metadata)); 1899 active_tree_->ResetAllChangeTracking();
1905 return true; 1900
1901 active_tree_->set_has_ever_been_drawn(true);
1902 devtools_instrumentation::DidDrawFrame(id_);
1903 benchmark_instrumentation::IssueImplThreadRenderingStatsEvent(
1904 rendering_stats_instrumentation_->impl_thread_rendering_stats());
1905 rendering_stats_instrumentation_->AccumulateAndClearImplThreadStats();
1906
1907 return swapped;
1906 } 1908 }
1907 1909
1908 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { 1910 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) {
1909 current_begin_frame_tracker_.Start(args); 1911 current_begin_frame_tracker_.Start(args);
1910 1912
1911 if (is_likely_to_require_a_draw_) { 1913 if (is_likely_to_require_a_draw_) {
1912 // Optimistically schedule a draw. This will let us expect the tile manager 1914 // 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 1915 // to complete its work so that we can draw new tiles within the impl frame
1914 // we are beginning now. 1916 // we are beginning now.
1915 SetNeedsRedraw(); 1917 SetNeedsRedraw();
(...skipping 2267 matching lines...) Expand 10 before | Expand all | Expand 10 after
4183 return task_runner_provider_->HasImplThread(); 4185 return task_runner_provider_->HasImplThread();
4184 } 4186 }
4185 4187
4186 bool LayerTreeHostImpl::CommitToActiveTree() const { 4188 bool LayerTreeHostImpl::CommitToActiveTree() const {
4187 // In single threaded mode we skip the pending tree and commit directly to the 4189 // In single threaded mode we skip the pending tree and commit directly to the
4188 // active tree. 4190 // active tree.
4189 return !task_runner_provider_->HasImplThread(); 4191 return !task_runner_provider_->HasImplThread();
4190 } 4192 }
4191 4193
4192 } // namespace cc 4194 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698