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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 zero_budget_(false), | 256 zero_budget_(false), |
257 device_scale_factor_(1.f), | 257 device_scale_factor_(1.f), |
258 overhang_ui_resource_id_(0), | 258 overhang_ui_resource_id_(0), |
259 resourceless_software_draw_(false), | 259 resourceless_software_draw_(false), |
260 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), | 260 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), |
261 animation_registrar_(AnimationRegistrar::Create()), | 261 animation_registrar_(AnimationRegistrar::Create()), |
262 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 262 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
263 micro_benchmark_controller_(this), | 263 micro_benchmark_controller_(this), |
264 need_to_update_visible_tiles_before_draw_(false), | 264 need_to_update_visible_tiles_before_draw_(false), |
265 shared_bitmap_manager_(manager), | 265 shared_bitmap_manager_(manager), |
266 id_(id) { | 266 id_(id), |
| 267 requires_high_res_to_draw_(false) { |
267 DCHECK(proxy_->IsImplThread()); | 268 DCHECK(proxy_->IsImplThread()); |
268 DidVisibilityChange(this, visible_); | 269 DidVisibilityChange(this, visible_); |
269 animation_registrar_->set_supports_scroll_animations( | 270 animation_registrar_->set_supports_scroll_animations( |
270 proxy_->SupportsImplScrolling()); | 271 proxy_->SupportsImplScrolling()); |
271 | 272 |
272 SetDebugState(settings.initial_debug_state); | 273 SetDebugState(settings.initial_debug_state); |
273 | 274 |
274 // LTHI always has an active tree. | 275 // LTHI always has an active tree. |
275 active_tree_ = LayerTreeImpl::create(this); | 276 active_tree_ = LayerTreeImpl::create(this); |
276 TRACE_EVENT_OBJECT_CREATED_WITH_ID( | 277 TRACE_EVENT_OBJECT_CREATED_WITH_ID( |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 bool layer_has_animating_transform = | 850 bool layer_has_animating_transform = |
850 it->screen_space_transform_is_animating() || | 851 it->screen_space_transform_is_animating() || |
851 it->draw_transform_is_animating(); | 852 it->draw_transform_is_animating(); |
852 if (layer_has_animating_transform) | 853 if (layer_has_animating_transform) |
853 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; | 854 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; |
854 } | 855 } |
855 | 856 |
856 if (append_quads_data.num_incomplete_tiles || | 857 if (append_quads_data.num_incomplete_tiles || |
857 append_quads_data.num_missing_tiles) { | 858 append_quads_data.num_missing_tiles) { |
858 frame->contains_incomplete_tile = true; | 859 frame->contains_incomplete_tile = true; |
859 if (active_tree()->RequiresHighResToDraw()) | 860 if (RequiresHighResToDraw()) |
860 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT; | 861 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT; |
861 } | 862 } |
862 | 863 |
863 occlusion_tracker.LeaveLayer(it); | 864 occlusion_tracker.LeaveLayer(it); |
864 } | 865 } |
865 | 866 |
866 if (have_copy_request || | 867 if (have_copy_request || |
867 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) | 868 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) |
868 draw_result = DRAW_SUCCESS; | 869 draw_result = DRAW_SUCCESS; |
869 | 870 |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 // Replace existing tile manager with another one that uses appropriate | 1605 // Replace existing tile manager with another one that uses appropriate |
1605 // rasterizer. | 1606 // rasterizer. |
1606 if (tile_manager_) { | 1607 if (tile_manager_) { |
1607 DestroyTileManager(); | 1608 DestroyTileManager(); |
1608 CreateAndSetTileManager(); | 1609 CreateAndSetTileManager(); |
1609 } | 1610 } |
1610 | 1611 |
1611 // We have released tilings for both active and pending tree. | 1612 // We have released tilings for both active and pending tree. |
1612 // We would not have any content to draw until the pending tree is activated. | 1613 // We would not have any content to draw until the pending tree is activated. |
1613 // Prevent the active tree from drawing until activation. | 1614 // Prevent the active tree from drawing until activation. |
1614 active_tree_->SetRequiresHighResToDraw(); | 1615 SetRequiresHighResToDraw(); |
1615 } | 1616 } |
1616 | 1617 |
1617 const RendererCapabilitiesImpl& | 1618 const RendererCapabilitiesImpl& |
1618 LayerTreeHostImpl::GetRendererCapabilities() const { | 1619 LayerTreeHostImpl::GetRendererCapabilities() const { |
1619 return renderer_->Capabilities(); | 1620 return renderer_->Capabilities(); |
1620 } | 1621 } |
1621 | 1622 |
1622 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { | 1623 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { |
1623 active_tree()->ResetRequiresHighResToDraw(); | 1624 ResetRequiresHighResToDraw(); |
1624 if (frame.has_no_damage) { | 1625 if (frame.has_no_damage) { |
1625 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); | 1626 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); |
1626 return false; | 1627 return false; |
1627 } | 1628 } |
1628 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); | 1629 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); |
1629 active_tree()->FinishSwapPromises(&metadata); | 1630 active_tree()->FinishSwapPromises(&metadata); |
1630 for (size_t i = 0; i < metadata.latency_info.size(); i++) { | 1631 for (size_t i = 0; i < metadata.latency_info.size(); i++) { |
1631 TRACE_EVENT_FLOW_STEP0( | 1632 TRACE_EVENT_FLOW_STEP0( |
1632 "input", | 1633 "input", |
1633 "LatencyInfo.Flow", | 1634 "LatencyInfo.Flow", |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1830 | 1831 |
1831 if (visible_ == visible) | 1832 if (visible_ == visible) |
1832 return; | 1833 return; |
1833 visible_ = visible; | 1834 visible_ = visible; |
1834 DidVisibilityChange(this, visible_); | 1835 DidVisibilityChange(this, visible_); |
1835 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); | 1836 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); |
1836 | 1837 |
1837 // If we just became visible, we have to ensure that we draw high res tiles, | 1838 // If we just became visible, we have to ensure that we draw high res tiles, |
1838 // to prevent checkerboard/low res flashes. | 1839 // to prevent checkerboard/low res flashes. |
1839 if (visible_) | 1840 if (visible_) |
1840 active_tree()->SetRequiresHighResToDraw(); | 1841 SetRequiresHighResToDraw(); |
1841 else | 1842 else |
1842 EvictAllUIResources(); | 1843 EvictAllUIResources(); |
1843 | 1844 |
1844 // Evict tiles immediately if invisible since this tab may never get another | 1845 // Evict tiles immediately if invisible since this tab may never get another |
1845 // draw or timer tick. | 1846 // draw or timer tick. |
1846 if (!visible_) | 1847 if (!visible_) |
1847 ManageTiles(); | 1848 ManageTiles(); |
1848 | 1849 |
1849 if (!renderer_) | 1850 if (!renderer_) |
1850 return; | 1851 return; |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2091 | 2092 |
2092 int max_frames_pending = output_surface_->capabilities().max_frames_pending; | 2093 int max_frames_pending = output_surface_->capabilities().max_frames_pending; |
2093 if (max_frames_pending <= 0) | 2094 if (max_frames_pending <= 0) |
2094 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; | 2095 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; |
2095 client_->SetMaxSwapsPendingOnImplThread(max_frames_pending); | 2096 client_->SetMaxSwapsPendingOnImplThread(max_frames_pending); |
2096 client_->OnCanDrawStateChanged(CanDraw()); | 2097 client_->OnCanDrawStateChanged(CanDraw()); |
2097 | 2098 |
2098 // There will not be anything to draw here, so set high res | 2099 // There will not be anything to draw here, so set high res |
2099 // to avoid checkerboards, typically when we are recovering | 2100 // to avoid checkerboards, typically when we are recovering |
2100 // from lost context. | 2101 // from lost context. |
2101 active_tree_->SetRequiresHighResToDraw(); | 2102 SetRequiresHighResToDraw(); |
2102 | 2103 |
2103 return true; | 2104 return true; |
2104 } | 2105 } |
2105 | 2106 |
2106 void LayerTreeHostImpl::CommitVSyncParameters(base::TimeTicks timebase, | 2107 void LayerTreeHostImpl::CommitVSyncParameters(base::TimeTicks timebase, |
2107 base::TimeDelta interval) { | 2108 base::TimeDelta interval) { |
2108 client_->CommitVSyncParameters(timebase, interval); | 2109 client_->CommitVSyncParameters(timebase, interval); |
2109 } | 2110 } |
2110 | 2111 |
2111 void LayerTreeHostImpl::DeferredInitialize() { | 2112 void LayerTreeHostImpl::DeferredInitialize() { |
(...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3378 } | 3379 } |
3379 | 3380 |
3380 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3381 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3381 std::vector<PictureLayerImpl*>::iterator it = | 3382 std::vector<PictureLayerImpl*>::iterator it = |
3382 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3383 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3383 DCHECK(it != picture_layers_.end()); | 3384 DCHECK(it != picture_layers_.end()); |
3384 picture_layers_.erase(it); | 3385 picture_layers_.erase(it); |
3385 } | 3386 } |
3386 | 3387 |
3387 } // namespace cc | 3388 } // namespace cc |
OLD | NEW |