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

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

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 !output_surface_->capabilities().can_force_reclaim_resources && 701 !output_surface_->capabilities().can_force_reclaim_resources &&
702 !hud_wants_to_draw_) { 702 !hud_wants_to_draw_) {
703 TRACE_EVENT0("cc", 703 TRACE_EVENT0("cc",
704 "LayerTreeHostImpl::CalculateRenderPasses::EmptyDamageRect"); 704 "LayerTreeHostImpl::CalculateRenderPasses::EmptyDamageRect");
705 frame->has_no_damage = true; 705 frame->has_no_damage = true;
706 DCHECK(!output_surface_->capabilities() 706 DCHECK(!output_surface_->capabilities()
707 .draw_and_swap_full_viewport_every_frame); 707 .draw_and_swap_full_viewport_every_frame);
708 return DRAW_SUCCESS; 708 return DRAW_SUCCESS;
709 } 709 }
710 710
711 TRACE_EVENT1("cc", 711 TRACE_EVENT_BEGIN2(
712 "LayerTreeHostImpl::CalculateRenderPasses", 712 "cc", "LayerTreeHostImpl::CalculateRenderPasses",
713 "render_surface_layer_list.size()", 713 "render_surface_layer_list.size()",
714 static_cast<uint64>(frame->render_surface_layer_list->size())); 714 static_cast<uint64>(frame->render_surface_layer_list->size()),
715 "RequiresHighResToDraw", RequiresHighResToDraw());
715 716
716 // Create the render passes in dependency order. 717 // Create the render passes in dependency order.
717 for (int surface_index = frame->render_surface_layer_list->size() - 1; 718 for (int surface_index = frame->render_surface_layer_list->size() - 1;
718 surface_index >= 0; 719 surface_index >= 0;
719 --surface_index) { 720 --surface_index) {
720 LayerImpl* render_surface_layer = 721 LayerImpl* render_surface_layer =
721 (*frame->render_surface_layer_list)[surface_index]; 722 (*frame->render_surface_layer_list)[surface_index];
722 RenderSurfaceImpl* render_surface = render_surface_layer->render_surface(); 723 RenderSurfaceImpl* render_surface = render_surface_layer->render_surface();
723 724
724 bool should_draw_into_render_pass = 725 bool should_draw_into_render_pass =
(...skipping 22 matching lines...) Expand all
747 // UpdateDrawProperties again. The value inside the Region is not actually 748 // UpdateDrawProperties again. The value inside the Region is not actually
748 // changed until UpdateDrawProperties happens, so a reference to it is safe. 749 // changed until UpdateDrawProperties happens, so a reference to it is safe.
749 const Region& unoccluded_screen_space_region = 750 const Region& unoccluded_screen_space_region =
750 active_tree_->UnoccludedScreenSpaceRegion(); 751 active_tree_->UnoccludedScreenSpaceRegion();
751 752
752 // Typically when we are missing a texture and use a checkerboard quad, we 753 // Typically when we are missing a texture and use a checkerboard quad, we
753 // still draw the frame. However when the layer being checkerboarded is moving 754 // still draw the frame. However when the layer being checkerboarded is moving
754 // due to an impl-animation, we drop the frame to avoid flashing due to the 755 // due to an impl-animation, we drop the frame to avoid flashing due to the
755 // texture suddenly appearing in the future. 756 // texture suddenly appearing in the future.
756 DrawResult draw_result = DRAW_SUCCESS; 757 DrawResult draw_result = DRAW_SUCCESS;
757 // When we have a copy request for a layer, we need to draw no matter
758 // what, as the layer may disappear after this frame.
759 bool have_copy_request = false;
760 758
761 int layers_drawn = 0; 759 int layers_drawn = 0;
762 760
763 const DrawMode draw_mode = GetDrawMode(); 761 const DrawMode draw_mode = GetDrawMode();
764 762
765 int num_missing_tiles = 0; 763 int num_missing_tiles = 0;
766 int num_incomplete_tiles = 0; 764 int num_incomplete_tiles = 0;
765 bool have_copy_request = false;
766 bool have_missing_animated_tiles = false;
767 767
768 auto end = LayerIterator<LayerImpl>::End(frame->render_surface_layer_list); 768 auto end = LayerIterator<LayerImpl>::End(frame->render_surface_layer_list);
769 for (auto it = 769 for (auto it =
770 LayerIterator<LayerImpl>::Begin(frame->render_surface_layer_list); 770 LayerIterator<LayerImpl>::Begin(frame->render_surface_layer_list);
771 it != end; ++it) { 771 it != end; ++it) {
772 RenderPassId target_render_pass_id = 772 RenderPassId target_render_pass_id =
773 it.target_render_surface_layer()->render_surface()->GetRenderPassId(); 773 it.target_render_surface_layer()->render_surface()->GetRenderPassId();
774 RenderPass* target_render_pass = 774 RenderPass* target_render_pass =
775 frame->render_passes_by_id[target_render_pass_id]; 775 frame->render_passes_by_id[target_render_pass_id];
776 776
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 append_quads_data.approximated_visible_content_area); 841 append_quads_data.approximated_visible_content_area);
842 842
843 num_missing_tiles += append_quads_data.num_missing_tiles; 843 num_missing_tiles += append_quads_data.num_missing_tiles;
844 num_incomplete_tiles += append_quads_data.num_incomplete_tiles; 844 num_incomplete_tiles += append_quads_data.num_incomplete_tiles;
845 845
846 if (append_quads_data.num_missing_tiles) { 846 if (append_quads_data.num_missing_tiles) {
847 bool layer_has_animating_transform = 847 bool layer_has_animating_transform =
848 it->screen_space_transform_is_animating() || 848 it->screen_space_transform_is_animating() ||
849 it->draw_transform_is_animating(); 849 it->draw_transform_is_animating();
850 if (layer_has_animating_transform) 850 if (layer_has_animating_transform)
851 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; 851 have_missing_animated_tiles = true;
852 }
853
854 if (append_quads_data.num_incomplete_tiles ||
855 append_quads_data.num_missing_tiles) {
856 if (RequiresHighResToDraw())
857 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT;
858 } 852 }
859 } 853 }
860 854
861 if (have_copy_request || 855 if (have_missing_animated_tiles)
862 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) 856 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS;
857
858 // When we have a copy request for a layer, we need to draw even if there
859 // would be animating checkerboards, because failing under those conditions
860 // triggers a new main frame, which may cause the copy request layer to be
861 // destroyed.
862 // TODO(danakj): Leaking scheduler internals into LayerTreeHostImpl here.
863 if (have_copy_request)
864 draw_result = DRAW_SUCCESS;
865
866 // When we require high res to draw, abort the draw (almost) always. This does
867 // not cause the scheduler to do a main frame, instead it will continue to try
868 // drawing until we finally complete, so the copy request will not be lost.
869 if (num_incomplete_tiles || num_missing_tiles) {
870 if (RequiresHighResToDraw())
871 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT;
872 }
873
874 // When this capability is set we don't have control over the surface the
875 // compositor draws to, so even though the frame may not be complete, the
876 // previous frame has already been potentially lost, so an incomplete frame is
877 // better than nothing, so this takes highest precidence.
878 if (output_surface_->capabilities().draw_and_swap_full_viewport_every_frame)
863 draw_result = DRAW_SUCCESS; 879 draw_result = DRAW_SUCCESS;
864 880
865 #if DCHECK_IS_ON() 881 #if DCHECK_IS_ON()
866 for (const auto& render_pass : frame->render_passes) { 882 for (const auto& render_pass : frame->render_passes) {
867 for (const auto& quad : render_pass->quad_list) 883 for (const auto& quad : render_pass->quad_list)
868 DCHECK(quad->shared_quad_state); 884 DCHECK(quad->shared_quad_state);
869 DCHECK(frame->render_passes_by_id.find(render_pass->id) != 885 DCHECK(frame->render_passes_by_id.find(render_pass->id) !=
870 frame->render_passes_by_id.end()); 886 frame->render_passes_by_id.end());
871 } 887 }
872 #endif 888 #endif
(...skipping 30 matching lines...) Expand all
903 UMA_HISTOGRAM_COUNTS_100( 919 UMA_HISTOGRAM_COUNTS_100(
904 "Compositing.RenderPass.AppendQuadData.NumIncompleteTiles", 920 "Compositing.RenderPass.AppendQuadData.NumIncompleteTiles",
905 num_incomplete_tiles); 921 num_incomplete_tiles);
906 } 922 }
907 923
908 // Should only have one render pass in resourceless software mode. 924 // Should only have one render pass in resourceless software mode.
909 DCHECK(draw_mode != DRAW_MODE_RESOURCELESS_SOFTWARE || 925 DCHECK(draw_mode != DRAW_MODE_RESOURCELESS_SOFTWARE ||
910 frame->render_passes.size() == 1u) 926 frame->render_passes.size() == 1u)
911 << frame->render_passes.size(); 927 << frame->render_passes.size();
912 928
929 TRACE_EVENT_END2("cc", "LayerTreeHostImpl::CalculateRenderPasses",
930 "draw_result", draw_result, "missing tiles",
931 num_missing_tiles);
932
913 return draw_result; 933 return draw_result;
914 } 934 }
915 935
916 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { 936 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() {
917 top_controls_manager_->MainThreadHasStoppedFlinging(); 937 top_controls_manager_->MainThreadHasStoppedFlinging();
918 if (input_handler_client_) 938 if (input_handler_client_)
919 input_handler_client_->MainThreadHasStoppedFlinging(); 939 input_handler_client_->MainThreadHasStoppedFlinging();
920 } 940 }
921 941
922 void LayerTreeHostImpl::DidAnimateScrollOffset() { 942 void LayerTreeHostImpl::DidAnimateScrollOffset() {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 UMA_HISTOGRAM_CUSTOM_COUNTS( 1068 UMA_HISTOGRAM_CUSTOM_COUNTS(
1049 "Compositing.NumActiveLayers", active_tree_->NumLayers(), 1, 400, 20); 1069 "Compositing.NumActiveLayers", active_tree_->NumLayers(), 1, 400, 20);
1050 1070
1051 bool update_lcd_text = false; 1071 bool update_lcd_text = false;
1052 bool ok = active_tree_->UpdateDrawProperties(update_lcd_text); 1072 bool ok = active_tree_->UpdateDrawProperties(update_lcd_text);
1053 DCHECK(ok) << "UpdateDrawProperties failed during draw"; 1073 DCHECK(ok) << "UpdateDrawProperties failed during draw";
1054 1074
1055 // This will cause NotifyTileStateChanged() to be called for any visible tiles 1075 // This will cause NotifyTileStateChanged() to be called for any visible tiles
1056 // that completed, which will add damage to the frame for them so they appear 1076 // that completed, which will add damage to the frame for them so they appear
1057 // as part of the current frame being drawn. 1077 // as part of the current frame being drawn.
1058 if (settings().impl_side_painting) 1078 if (tile_manager_)
1059 tile_manager_->UpdateVisibleTiles(global_tile_state_); 1079 tile_manager_->UpdateVisibleTiles(global_tile_state_);
1060 1080
1061 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); 1081 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList();
1062 frame->render_passes.clear(); 1082 frame->render_passes.clear();
1063 frame->render_passes_by_id.clear(); 1083 frame->render_passes_by_id.clear();
1064 frame->will_draw_layers.clear(); 1084 frame->will_draw_layers.clear();
1065 frame->has_no_damage = false; 1085 frame->has_no_damage = false;
1066 1086
1067 if (active_tree_->root_layer()) { 1087 if (active_tree_->root_layer()) {
1068 gfx::Rect device_viewport_damage_rect = viewport_damage_rect_; 1088 gfx::Rect device_viewport_damage_rect = viewport_damage_rect_;
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 // contents of its texture are updated as the last thing before the frame is 1541 // contents of its texture are updated as the last thing before the frame is
1522 // drawn. 1542 // drawn.
1523 if (active_tree_->hud_layer()) { 1543 if (active_tree_->hud_layer()) {
1524 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); 1544 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture");
1525 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, 1545 active_tree_->hud_layer()->UpdateHudTexture(draw_mode,
1526 resource_provider_.get()); 1546 resource_provider_.get());
1527 } 1547 }
1528 1548
1529 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) { 1549 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) {
1530 bool disable_picture_quad_image_filtering = 1550 bool disable_picture_quad_image_filtering =
1531 IsActivelyScrolling() || needs_animate_layers(); 1551 IsActivelyScrolling() || animation_registrar_->needs_animate_layers();
1532 1552
1533 scoped_ptr<SoftwareRenderer> temp_software_renderer = 1553 scoped_ptr<SoftwareRenderer> temp_software_renderer =
1534 SoftwareRenderer::Create(this, &settings_.renderer_settings, 1554 SoftwareRenderer::Create(this, &settings_.renderer_settings,
1535 output_surface_.get(), NULL); 1555 output_surface_.get(), NULL);
1536 temp_software_renderer->DrawFrame(&frame->render_passes, 1556 temp_software_renderer->DrawFrame(&frame->render_passes,
1537 device_scale_factor_, 1557 device_scale_factor_,
1538 DeviceViewport(), 1558 DeviceViewport(),
1539 DeviceClip(), 1559 DeviceClip(),
1540 disable_picture_quad_image_filtering); 1560 disable_picture_quad_image_filtering);
1541 } else { 1561 } else {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 } 1669 }
1650 } 1670 }
1651 1671
1652 void LayerTreeHostImpl::UpdateViewportContainerSizes() { 1672 void LayerTreeHostImpl::UpdateViewportContainerSizes() {
1653 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); 1673 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer();
1654 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); 1674 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer();
1655 1675
1656 if (!inner_container) 1676 if (!inner_container)
1657 return; 1677 return;
1658 1678
1679 // TODO(bokan): This code is currently specific to top controls. It should be
1680 // made general. crbug.com/464814.
1681 if (!TopControlsHeight()) {
1682 if (outer_container)
1683 outer_container->SetBoundsDelta(gfx::Vector2dF());
1684
1685 inner_container->SetBoundsDelta(gfx::Vector2dF());
1686 active_tree_->InnerViewportScrollLayer()->SetBoundsDelta(gfx::Vector2dF());
1687
1688 return;
1689 }
1690
1659 ViewportAnchor anchor(InnerViewportScrollLayer(), 1691 ViewportAnchor anchor(InnerViewportScrollLayer(),
1660 OuterViewportScrollLayer()); 1692 OuterViewportScrollLayer());
1661 1693
1662 // Adjust the inner viewport by shrinking/expanding the container to account 1694 // Adjust the inner viewport by shrinking/expanding the container to account
1663 // for the change in top controls height since the last Resize from Blink. 1695 // for the change in top controls height since the last Resize from Blink.
1664 float top_controls_layout_height = 1696 float top_controls_layout_height =
1665 active_tree_->top_controls_shrink_blink_size() 1697 active_tree_->top_controls_shrink_blink_size()
1666 ? active_tree_->top_controls_height() 1698 ? active_tree_->top_controls_height()
1667 : 0.f; 1699 : 0.f;
1668 inner_container->SetBoundsDelta(gfx::Vector2dF( 1700 inner_container->SetBoundsDelta(gfx::Vector2dF(
(...skipping 17 matching lines...) Expand all
1686 1718
1687 outer_container->SetBoundsDelta(delta); 1719 outer_container->SetBoundsDelta(delta);
1688 active_tree_->InnerViewportScrollLayer()->SetBoundsDelta(delta); 1720 active_tree_->InnerViewportScrollLayer()->SetBoundsDelta(delta);
1689 1721
1690 anchor.ResetViewportToAnchoredPosition(); 1722 anchor.ResetViewportToAnchoredPosition();
1691 } 1723 }
1692 1724
1693 void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() { 1725 void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() {
1694 // Only valid for the single-threaded non-scheduled/synchronous case 1726 // Only valid for the single-threaded non-scheduled/synchronous case
1695 // using the zero copy raster worker pool. 1727 // using the zero copy raster worker pool.
1696 single_thread_synchronous_task_graph_runner_->RunUntilIdle(); 1728 if (tile_manager_)
1729 single_thread_synchronous_task_graph_runner_->RunUntilIdle();
1697 } 1730 }
1698 1731
1699 void LayerTreeHostImpl::DidLoseOutputSurface() { 1732 void LayerTreeHostImpl::DidLoseOutputSurface() {
1700 if (resource_provider_) 1733 if (resource_provider_)
1701 resource_provider_->DidLoseOutputSurface(); 1734 resource_provider_->DidLoseOutputSurface();
1702 client_->DidLoseOutputSurfaceOnImplThread(); 1735 client_->DidLoseOutputSurfaceOnImplThread();
1703 } 1736 }
1704 1737
1705 bool LayerTreeHostImpl::HaveRootScrollLayer() const { 1738 bool LayerTreeHostImpl::HaveRootScrollLayer() const {
1706 return !!InnerViewportScrollLayer(); 1739 return !!InnerViewportScrollLayer();
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D); 2083 ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D);
2051 2084
2052 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( 2085 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create(
2053 task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), 2086 task_runner, TileTaskWorkerPool::GetTaskGraphRunner(),
2054 context_provider, resource_provider_.get(), 2087 context_provider, resource_provider_.get(),
2055 staging_resource_pool_.get()); 2088 staging_resource_pool_.get());
2056 return; 2089 return;
2057 } 2090 }
2058 } 2091 }
2059 2092
2093 // Synchronous single-threaded mode depends on tiles being ready to
2094 // draw when raster is complete. Therefore, it must use one of zero
2095 // copy, software raster, or GPU raster (in the branches above).
2096 DCHECK(!IsSynchronousSingleThreaded());
2097
2060 *resource_pool = ResourcePool::Create( 2098 *resource_pool = ResourcePool::Create(
2061 resource_provider_.get(), GL_TEXTURE_2D); 2099 resource_provider_.get(), GL_TEXTURE_2D);
2062 2100
2063 *tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create( 2101 *tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create(
2064 task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), context_provider, 2102 task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), context_provider,
2065 resource_provider_.get(), 2103 resource_provider_.get(),
2066 GetMaxTransferBufferUsageBytes(context_provider->ContextCapabilities(), 2104 GetMaxTransferBufferUsageBytes(context_provider->ContextCapabilities(),
2067 settings_.renderer_settings.refresh_rate)); 2105 settings_.renderer_settings.refresh_rate));
2068 } 2106 }
2069 2107
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2112 proxy_->blocking_main_thread_task_runner(), 2150 proxy_->blocking_main_thread_task_runner(),
2113 settings_.renderer_settings.highp_threshold_min, 2151 settings_.renderer_settings.highp_threshold_min,
2114 settings_.renderer_settings.use_rgba_4444_textures, 2152 settings_.renderer_settings.use_rgba_4444_textures,
2115 settings_.renderer_settings.texture_id_allocation_chunk_size); 2153 settings_.renderer_settings.texture_id_allocation_chunk_size);
2116 2154
2117 if (output_surface_->capabilities().deferred_gl_initialization) 2155 if (output_surface_->capabilities().deferred_gl_initialization)
2118 EnforceZeroBudget(true); 2156 EnforceZeroBudget(true);
2119 2157
2120 CreateAndSetRenderer(); 2158 CreateAndSetRenderer();
2121 2159
2122 if (settings_.impl_side_painting) 2160 if (settings_.impl_side_painting && settings_.raster_enabled)
2123 CreateAndSetTileManager(); 2161 CreateAndSetTileManager();
2124 RecreateTreeResources(); 2162 RecreateTreeResources();
2125 2163
2126 // Initialize vsync parameters to sane values. 2164 // Initialize vsync parameters to sane values.
2127 const base::TimeDelta display_refresh_interval = 2165 const base::TimeDelta display_refresh_interval =
2128 base::TimeDelta::FromMicroseconds( 2166 base::TimeDelta::FromMicroseconds(
2129 base::Time::kMicrosecondsPerSecond / 2167 base::Time::kMicrosecondsPerSecond /
2130 settings_.renderer_settings.refresh_rate); 2168 settings_.renderer_settings.refresh_rate);
2131 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval); 2169 CommitVSyncParameters(base::TimeTicks(), display_refresh_interval);
2132 2170
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
3105 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateScrollbars"); 3143 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateScrollbars");
3106 std::set<ScrollbarAnimationController*> controllers_copy = 3144 std::set<ScrollbarAnimationController*> controllers_copy =
3107 scrollbar_animation_controllers_; 3145 scrollbar_animation_controllers_;
3108 for (auto& it : controllers_copy) 3146 for (auto& it : controllers_copy)
3109 it->Animate(monotonic_time); 3147 it->Animate(monotonic_time);
3110 3148
3111 SetNeedsAnimate(); 3149 SetNeedsAnimate();
3112 } 3150 }
3113 3151
3114 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { 3152 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) {
3115 if (!settings_.accelerated_animation_enabled || 3153 if (!settings_.accelerated_animation_enabled || !active_tree_->root_layer())
3116 !needs_animate_layers() ||
3117 !active_tree_->root_layer())
3118 return; 3154 return;
3119 3155
3120 TRACE_EVENT0("cc", "LayerTreeHostImpl::AnimateLayers"); 3156 if (animation_registrar_->AnimateLayers(monotonic_time))
3121 AnimationRegistrar::AnimationControllerMap controllers_copy = 3157 SetNeedsAnimate();
3122 animation_registrar_->active_animation_controllers();
3123 for (auto& it : controllers_copy)
3124 it.second->Animate(monotonic_time);
3125
3126 SetNeedsAnimate();
3127 } 3158 }
3128 3159
3129 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { 3160 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) {
3130 if (!settings_.accelerated_animation_enabled || !needs_animate_layers() || 3161 if (!settings_.accelerated_animation_enabled || !active_tree_->root_layer())
3131 !active_tree_->root_layer())
3132 return; 3162 return;
3133 3163
3134 TRACE_EVENT0("cc", "LayerTreeHostImpl::UpdateAnimationState");
3135 scoped_ptr<AnimationEventsVector> events = 3164 scoped_ptr<AnimationEventsVector> events =
3136 make_scoped_ptr(new AnimationEventsVector); 3165 animation_registrar_->CreateEvents();
3137 AnimationRegistrar::AnimationControllerMap active_controllers_copy = 3166 const bool has_active_animations = animation_registrar_->UpdateAnimationState(
3138 animation_registrar_->active_animation_controllers(); 3167 start_ready_animations, events.get());
3139 for (auto& it : active_controllers_copy)
3140 it.second->UpdateState(start_ready_animations, events.get());
3141 3168
3142 if (!events->empty()) { 3169 if (!events->empty())
3143 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass()); 3170 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass());
3144 }
3145 3171
3146 SetNeedsAnimate(); 3172 if (has_active_animations)
3173 SetNeedsAnimate();
3147 } 3174 }
3148 3175
3149 void LayerTreeHostImpl::ActivateAnimations() { 3176 void LayerTreeHostImpl::ActivateAnimations() {
3150 if (!settings_.accelerated_animation_enabled || !needs_animate_layers() || 3177 if (!settings_.accelerated_animation_enabled || !active_tree_->root_layer())
3151 !active_tree_->root_layer())
3152 return; 3178 return;
3153 3179
3154 TRACE_EVENT0("cc", "LayerTreeHostImpl::ActivateAnimations"); 3180 if (animation_registrar_->ActivateAnimations())
3155 AnimationRegistrar::AnimationControllerMap active_controllers_copy = 3181 SetNeedsAnimate();
3156 animation_registrar_->active_animation_controllers();
3157 for (auto& it : active_controllers_copy)
3158 it.second->ActivateAnimations();
3159
3160 SetNeedsAnimate();
3161 } 3182 }
3162 3183
3163 std::string LayerTreeHostImpl::LayerTreeAsJson() const { 3184 std::string LayerTreeHostImpl::LayerTreeAsJson() const {
3164 std::string str; 3185 std::string str;
3165 if (active_tree_->root_layer()) { 3186 if (active_tree_->root_layer()) {
3166 scoped_ptr<base::Value> json(active_tree_->root_layer()->LayerTreeAsJson()); 3187 scoped_ptr<base::Value> json(active_tree_->root_layer()->LayerTreeAsJson());
3167 base::JSONWriter::WriteWithOptions( 3188 base::JSONWriter::WriteWithOptions(
3168 json.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); 3189 json.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &str);
3169 } 3190 }
3170 return str; 3191 return str;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
3227 // we're not in a frame (because this is during an input event or a delayed 3248 // we're not in a frame (because this is during an input event or a delayed
3228 // task), fall back to physical time. This should still be monotonic. 3249 // task), fall back to physical time. This should still be monotonic.
3229 if (current_begin_frame_args_.IsValid()) 3250 if (current_begin_frame_args_.IsValid())
3230 return current_begin_frame_args_; 3251 return current_begin_frame_args_;
3231 return BeginFrameArgs::Create( 3252 return BeginFrameArgs::Create(
3232 BEGINFRAME_FROM_HERE, gfx::FrameTime::Now(), base::TimeTicks(), 3253 BEGINFRAME_FROM_HERE, gfx::FrameTime::Now(), base::TimeTicks(),
3233 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL); 3254 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL);
3234 } 3255 }
3235 3256
3236 scoped_refptr<base::trace_event::ConvertableToTraceFormat> 3257 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
3237 LayerTreeHostImpl::AsValue() const {
3238 return AsValueWithFrame(NULL);
3239 }
3240
3241 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
3242 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { 3258 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const {
3243 scoped_refptr<base::trace_event::TracedValue> state = 3259 scoped_refptr<base::trace_event::TracedValue> state =
3244 new base::trace_event::TracedValue(); 3260 new base::trace_event::TracedValue();
3245 AsValueWithFrameInto(frame, state.get()); 3261 AsValueWithFrameInto(frame, state.get());
3246 return state; 3262 return state;
3247 } 3263 }
3248 3264
3249 void LayerTreeHostImpl::AsValueInto(
3250 base::trace_event::TracedValue* value) const {
3251 return AsValueWithFrameInto(NULL, value);
3252 }
3253
3254 void LayerTreeHostImpl::AsValueWithFrameInto( 3265 void LayerTreeHostImpl::AsValueWithFrameInto(
3255 FrameData* frame, 3266 FrameData* frame,
3256 base::trace_event::TracedValue* state) const { 3267 base::trace_event::TracedValue* state) const {
3257 if (this->pending_tree_) { 3268 if (this->pending_tree_) {
3258 state->BeginDictionary("activation_state"); 3269 state->BeginDictionary("activation_state");
3259 ActivationStateAsValueInto(state); 3270 ActivationStateAsValueInto(state);
3260 state->EndDictionary(); 3271 state->EndDictionary();
3261 } 3272 }
3262 MathUtil::AddToTracedValue("device_viewport_size", device_viewport_size_, 3273 MathUtil::AddToTracedValue("device_viewport_size", device_viewport_size_,
3263 state); 3274 state);
(...skipping 28 matching lines...) Expand all
3292 pending_tree_->AsValueInto(state); 3303 pending_tree_->AsValueInto(state);
3293 state->EndDictionary(); 3304 state->EndDictionary();
3294 } 3305 }
3295 if (frame) { 3306 if (frame) {
3296 state->BeginDictionary("frame"); 3307 state->BeginDictionary("frame");
3297 frame->AsValueInto(state); 3308 frame->AsValueInto(state);
3298 state->EndDictionary(); 3309 state->EndDictionary();
3299 } 3310 }
3300 } 3311 }
3301 3312
3302 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
3303 LayerTreeHostImpl::ActivationStateAsValue() const {
3304 scoped_refptr<base::trace_event::TracedValue> state =
3305 new base::trace_event::TracedValue();
3306 ActivationStateAsValueInto(state.get());
3307 return state;
3308 }
3309
3310 void LayerTreeHostImpl::ActivationStateAsValueInto( 3313 void LayerTreeHostImpl::ActivationStateAsValueInto(
3311 base::trace_event::TracedValue* state) const { 3314 base::trace_event::TracedValue* state) const {
3312 TracedValue::SetIDRef(this, state, "lthi"); 3315 TracedValue::SetIDRef(this, state, "lthi");
3313 if (tile_manager_) { 3316 if (tile_manager_) {
3314 state->BeginDictionary("tile_manager"); 3317 state->BeginDictionary("tile_manager");
3315 tile_manager_->BasicStateAsValueInto(state); 3318 tile_manager_->BasicStateAsValueInto(state);
3316 state->EndDictionary(); 3319 state->EndDictionary();
3317 } 3320 }
3318 } 3321 }
3319 3322
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
3450 (*it)->OnSetNeedsRedrawOnImpl(); 3453 (*it)->OnSetNeedsRedrawOnImpl();
3451 } 3454 }
3452 3455
3453 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { 3456 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() {
3454 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); 3457 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
3455 for (; it != swap_promise_monitor_.end(); it++) 3458 for (; it != swap_promise_monitor_.end(); it++)
3456 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); 3459 (*it)->OnForwardScrollUpdateToMainThreadOnImpl();
3457 } 3460 }
3458 3461
3459 } // namespace cc 3462 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698