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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 time_source_(time_source) { | 231 time_source_(time_source) { |
232 time_source_->SetClient(this); | 232 time_source_->SetClient(this); |
233 } | 233 } |
234 | 234 |
235 LayerTreeHostImpl* layer_tree_host_impl_; | 235 LayerTreeHostImpl* layer_tree_host_impl_; |
236 scoped_refptr<DelayBasedTimeSource> time_source_; | 236 scoped_refptr<DelayBasedTimeSource> time_source_; |
237 | 237 |
238 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImplTimeSourceAdapter); | 238 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImplTimeSourceAdapter); |
239 }; | 239 }; |
240 | 240 |
241 LayerTreeHostImpl::FrameData::FrameData() | 241 LayerTreeHostImpl::FrameData::FrameData() : has_no_damage(false) { |
242 : contains_incomplete_tile(false), has_no_damage(false) {} | 242 } |
243 | 243 |
244 LayerTreeHostImpl::FrameData::~FrameData() {} | 244 LayerTreeHostImpl::FrameData::~FrameData() {} |
245 | 245 |
246 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::Create( | 246 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::Create( |
247 const LayerTreeSettings& settings, | 247 const LayerTreeSettings& settings, |
248 LayerTreeHostImplClient* client, | 248 LayerTreeHostImplClient* client, |
249 Proxy* proxy, | 249 Proxy* proxy, |
250 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 250 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
251 SharedBitmapManager* shared_bitmap_manager, | 251 SharedBitmapManager* shared_bitmap_manager, |
252 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 252 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 : proxy_->MainThreadTaskRunner())), | 297 : proxy_->MainThreadTaskRunner())), |
298 max_memory_needed_bytes_(0), | 298 max_memory_needed_bytes_(0), |
299 zero_budget_(false), | 299 zero_budget_(false), |
300 device_scale_factor_(1.f), | 300 device_scale_factor_(1.f), |
301 overhang_ui_resource_id_(0), | 301 overhang_ui_resource_id_(0), |
302 resourceless_software_draw_(false), | 302 resourceless_software_draw_(false), |
303 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), | 303 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), |
304 animation_registrar_(AnimationRegistrar::Create()), | 304 animation_registrar_(AnimationRegistrar::Create()), |
305 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 305 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
306 micro_benchmark_controller_(this), | 306 micro_benchmark_controller_(this), |
307 need_to_update_visible_tiles_before_draw_(false), | |
308 shared_bitmap_manager_(shared_bitmap_manager), | 307 shared_bitmap_manager_(shared_bitmap_manager), |
309 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 308 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
310 id_(id), | 309 id_(id), |
311 requires_high_res_to_draw_(false) { | 310 requires_high_res_to_draw_(false), |
311 required_for_draw_tile_is_top_of_raster_queue_(false) { | |
312 DCHECK(proxy_->IsImplThread()); | 312 DCHECK(proxy_->IsImplThread()); |
313 DidVisibilityChange(this, visible_); | 313 DidVisibilityChange(this, visible_); |
314 animation_registrar_->set_supports_scroll_animations( | 314 animation_registrar_->set_supports_scroll_animations( |
315 proxy_->SupportsImplScrolling()); | 315 proxy_->SupportsImplScrolling()); |
316 | 316 |
317 SetDebugState(settings.initial_debug_state); | 317 SetDebugState(settings.initial_debug_state); |
318 | 318 |
319 // LTHI always has an active tree. | 319 // LTHI always has an active tree. |
320 active_tree_ = LayerTreeImpl::create(this); | 320 active_tree_ = LayerTreeImpl::create(this); |
321 TRACE_EVENT_OBJECT_CREATED_WITH_ID( | 321 TRACE_EVENT_OBJECT_CREATED_WITH_ID( |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
539 render_surface_layer->id(), | 539 render_surface_layer->id(), |
540 render_surface->SurfacePropertyChangedOnlyFromDescendant(), | 540 render_surface->SurfacePropertyChangedOnlyFromDescendant(), |
541 render_surface->content_rect(), | 541 render_surface->content_rect(), |
542 render_surface_layer->mask_layer(), | 542 render_surface_layer->mask_layer(), |
543 render_surface_layer->filters()); | 543 render_surface_layer->filters()); |
544 } | 544 } |
545 } | 545 } |
546 | 546 |
547 void LayerTreeHostImpl::FrameData::AsValueInto( | 547 void LayerTreeHostImpl::FrameData::AsValueInto( |
548 base::debug::TracedValue* value) const { | 548 base::debug::TracedValue* value) const { |
549 value->SetBoolean("contains_incomplete_tile", contains_incomplete_tile); | |
550 value->SetBoolean("has_no_damage", has_no_damage); | 549 value->SetBoolean("has_no_damage", has_no_damage); |
551 | 550 |
552 // Quad data can be quite large, so only dump render passes if we select | 551 // Quad data can be quite large, so only dump render passes if we select |
553 // cc.debug.quads. | 552 // cc.debug.quads. |
554 bool quads_enabled; | 553 bool quads_enabled; |
555 TRACE_EVENT_CATEGORY_GROUP_ENABLED( | 554 TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
556 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); | 555 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); |
557 if (quads_enabled) { | 556 if (quads_enabled) { |
558 value->BeginArray("render_passes"); | 557 value->BeginArray("render_passes"); |
559 for (size_t i = 0; i < render_passes.size(); ++i) { | 558 for (size_t i = 0; i < render_passes.size(); ++i) { |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
889 if (append_quads_data.num_missing_tiles) { | 888 if (append_quads_data.num_missing_tiles) { |
890 bool layer_has_animating_transform = | 889 bool layer_has_animating_transform = |
891 it->screen_space_transform_is_animating() || | 890 it->screen_space_transform_is_animating() || |
892 it->draw_transform_is_animating(); | 891 it->draw_transform_is_animating(); |
893 if (layer_has_animating_transform) | 892 if (layer_has_animating_transform) |
894 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; | 893 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; |
895 } | 894 } |
896 | 895 |
897 if (append_quads_data.num_incomplete_tiles || | 896 if (append_quads_data.num_incomplete_tiles || |
898 append_quads_data.num_missing_tiles) { | 897 append_quads_data.num_missing_tiles) { |
899 frame->contains_incomplete_tile = true; | |
900 if (RequiresHighResToDraw()) | 898 if (RequiresHighResToDraw()) |
901 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT; | 899 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT; |
902 } | 900 } |
903 | 901 |
904 occlusion_tracker.LeaveLayer(it); | 902 occlusion_tracker.LeaveLayer(it); |
905 } | 903 } |
906 | 904 |
907 if (have_copy_request || | 905 if (have_copy_request || |
908 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) | 906 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) |
909 draw_result = DRAW_SUCCESS; | 907 draw_result = DRAW_SUCCESS; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1106 DCHECK_GE(frame->render_passes.size(), position_from_end); | 1104 DCHECK_GE(frame->render_passes.size(), position_from_end); |
1107 } | 1105 } |
1108 } | 1106 } |
1109 } | 1107 } |
1110 | 1108 |
1111 DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { | 1109 DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { |
1112 TRACE_EVENT1("cc", | 1110 TRACE_EVENT1("cc", |
1113 "LayerTreeHostImpl::PrepareToDraw", | 1111 "LayerTreeHostImpl::PrepareToDraw", |
1114 "SourceFrameNumber", | 1112 "SourceFrameNumber", |
1115 active_tree_->source_frame_number()); | 1113 active_tree_->source_frame_number()); |
1116 | 1114 // This will cause NotifyTileStateChanged() to be called for any visible tiles |
1117 if (need_to_update_visible_tiles_before_draw_ && | 1115 // that completed, which will add damage to the frame for them so they appear |
1118 tile_manager_ && tile_manager_->UpdateVisibleTiles()) { | 1116 // as part of the current frame being drawn.g |
brianderson
2014/10/31 22:42:53
typo: ".g"
danakj
2014/11/03 16:26:04
I blame emacs. Thanks :)
| |
1119 DidInitializeVisibleTile(); | 1117 if (settings().impl_side_painting) |
1120 } | 1118 tile_manager_->UpdateVisibleTiles(); |
1121 need_to_update_visible_tiles_before_draw_ = true; | |
1122 | 1119 |
1123 UMA_HISTOGRAM_CUSTOM_COUNTS( | 1120 UMA_HISTOGRAM_CUSTOM_COUNTS( |
1124 "Compositing.NumActiveLayers", active_tree_->NumLayers(), 1, 400, 20); | 1121 "Compositing.NumActiveLayers", active_tree_->NumLayers(), 1, 400, 20); |
1125 | 1122 |
1126 bool ok = active_tree_->UpdateDrawProperties(); | 1123 bool ok = active_tree_->UpdateDrawProperties(); |
1127 DCHECK(ok) << "UpdateDrawProperties failed during draw"; | 1124 DCHECK(ok) << "UpdateDrawProperties failed during draw"; |
1128 | 1125 |
1129 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); | 1126 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); |
1130 frame->render_passes.clear(); | 1127 frame->render_passes.clear(); |
1131 frame->render_passes_by_id.clear(); | 1128 frame->render_passes_by_id.clear(); |
1132 frame->will_draw_layers.clear(); | 1129 frame->will_draw_layers.clear(); |
1133 frame->contains_incomplete_tile = false; | |
1134 frame->has_no_damage = false; | 1130 frame->has_no_damage = false; |
1135 | 1131 |
1136 if (active_tree_->root_layer()) { | 1132 if (active_tree_->root_layer()) { |
1137 gfx::Rect device_viewport_damage_rect = viewport_damage_rect_; | 1133 gfx::Rect device_viewport_damage_rect = viewport_damage_rect_; |
1138 viewport_damage_rect_ = gfx::Rect(); | 1134 viewport_damage_rect_ = gfx::Rect(); |
1139 | 1135 |
1140 active_tree_->root_layer()->render_surface()->damage_tracker()-> | 1136 active_tree_->root_layer()->render_surface()->damage_tracker()-> |
1141 AddDamageNextUpdate(device_viewport_damage_rect); | 1137 AddDamageNextUpdate(device_viewport_damage_rect); |
1142 } | 1138 } |
1143 | 1139 |
(...skipping 10 matching lines...) Expand all Loading... | |
1154 } | 1150 } |
1155 | 1151 |
1156 void LayerTreeHostImpl::EvictTexturesForTesting() { | 1152 void LayerTreeHostImpl::EvictTexturesForTesting() { |
1157 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0)); | 1153 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0)); |
1158 } | 1154 } |
1159 | 1155 |
1160 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { | 1156 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { |
1161 NOTREACHED(); | 1157 NOTREACHED(); |
1162 } | 1158 } |
1163 | 1159 |
1164 void LayerTreeHostImpl::DidInitializeVisibleTileForTesting() { | |
1165 // Add arbitrary damage, to trigger prepare-to-draws. | |
1166 // Here, setting damage as viewport size, used only for testing. | |
1167 SetFullRootLayerDamage(); | |
1168 DidInitializeVisibleTile(); | |
1169 } | |
1170 | |
1171 void LayerTreeHostImpl::ResetTreesForTesting() { | 1160 void LayerTreeHostImpl::ResetTreesForTesting() { |
1172 if (active_tree_) | 1161 if (active_tree_) |
1173 active_tree_->DetachLayerTree(); | 1162 active_tree_->DetachLayerTree(); |
1174 active_tree_ = LayerTreeImpl::create(this); | 1163 active_tree_ = LayerTreeImpl::create(this); |
1175 if (pending_tree_) | 1164 if (pending_tree_) |
1176 pending_tree_->DetachLayerTree(); | 1165 pending_tree_->DetachLayerTree(); |
1177 pending_tree_ = nullptr; | 1166 pending_tree_ = nullptr; |
1178 if (recycle_tree_) | 1167 if (recycle_tree_) |
1179 recycle_tree_->DetachLayerTree(); | 1168 recycle_tree_->DetachLayerTree(); |
1180 recycle_tree_ = nullptr; | 1169 recycle_tree_ = nullptr; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1252 DidModifyTilePriorities(); | 1241 DidModifyTilePriorities(); |
1253 } | 1242 } |
1254 | 1243 |
1255 void LayerTreeHostImpl::DidModifyTilePriorities() { | 1244 void LayerTreeHostImpl::DidModifyTilePriorities() { |
1256 DCHECK(settings_.impl_side_painting); | 1245 DCHECK(settings_.impl_side_painting); |
1257 // Mark priorities as dirty and schedule a ManageTiles(). | 1246 // Mark priorities as dirty and schedule a ManageTiles(). |
1258 tile_priorities_dirty_ = true; | 1247 tile_priorities_dirty_ = true; |
1259 client_->SetNeedsManageTilesOnImplThread(); | 1248 client_->SetNeedsManageTilesOnImplThread(); |
1260 } | 1249 } |
1261 | 1250 |
1262 void LayerTreeHostImpl::DidInitializeVisibleTile() { | |
1263 if (client_ && !client_->IsInsideDraw()) | |
1264 client_->DidInitializeVisibleTileOnImplThread(); | |
1265 } | |
1266 | |
1267 void LayerTreeHostImpl::GetPictureLayerImplPairs( | 1251 void LayerTreeHostImpl::GetPictureLayerImplPairs( |
1268 std::vector<PictureLayerImpl::Pair>* layer_pairs) const { | 1252 std::vector<PictureLayerImpl::Pair>* layer_pairs) const { |
1269 DCHECK(layer_pairs->empty()); | 1253 DCHECK(layer_pairs->empty()); |
1270 for (std::vector<PictureLayerImpl*>::const_iterator it = | 1254 for (std::vector<PictureLayerImpl*>::const_iterator it = |
1271 picture_layers_.begin(); | 1255 picture_layers_.begin(); |
1272 it != picture_layers_.end(); | 1256 it != picture_layers_.end(); |
1273 ++it) { | 1257 ++it) { |
1274 PictureLayerImpl* layer = *it; | 1258 PictureLayerImpl* layer = *it; |
1275 | 1259 |
1276 // TODO(vmpstr): Iterators and should handle this instead. crbug.com/381704 | 1260 // TODO(vmpstr): Iterators and should handle this instead. crbug.com/381704 |
(...skipping 18 matching lines...) Expand all Loading... | |
1295 } | 1279 } |
1296 } | 1280 } |
1297 } | 1281 } |
1298 | 1282 |
1299 void LayerTreeHostImpl::BuildRasterQueue(RasterTilePriorityQueue* queue, | 1283 void LayerTreeHostImpl::BuildRasterQueue(RasterTilePriorityQueue* queue, |
1300 TreePriority tree_priority) { | 1284 TreePriority tree_priority) { |
1301 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); | 1285 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); |
1302 picture_layer_pairs_.clear(); | 1286 picture_layer_pairs_.clear(); |
1303 GetPictureLayerImplPairs(&picture_layer_pairs_); | 1287 GetPictureLayerImplPairs(&picture_layer_pairs_); |
1304 queue->Build(picture_layer_pairs_, tree_priority); | 1288 queue->Build(picture_layer_pairs_, tree_priority); |
1289 | |
1290 if (!queue->IsEmpty()) { | |
1291 required_for_draw_tile_is_top_of_raster_queue_ = | |
1292 queue->Top()->required_for_draw(); | |
1293 } else { | |
1294 required_for_draw_tile_is_top_of_raster_queue_ = false; | |
1295 } | |
reveman
2014/10/31 20:28:39
How about using conditional assignment here instea
danakj
2014/10/31 20:43:01
It's a similar number of lines of code with the li
reveman
2014/10/31 21:38:13
Acknowledged.
| |
1305 } | 1296 } |
1306 | 1297 |
1307 void LayerTreeHostImpl::BuildEvictionQueue(EvictionTilePriorityQueue* queue, | 1298 void LayerTreeHostImpl::BuildEvictionQueue(EvictionTilePriorityQueue* queue, |
1308 TreePriority tree_priority) { | 1299 TreePriority tree_priority) { |
1309 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); | 1300 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); |
1310 picture_layer_pairs_.clear(); | 1301 picture_layer_pairs_.clear(); |
1311 GetPictureLayerImplPairs(&picture_layer_pairs_); | 1302 GetPictureLayerImplPairs(&picture_layer_pairs_); |
1312 queue->Build(picture_layer_pairs_, tree_priority); | 1303 queue->Build(picture_layer_pairs_, tree_priority); |
1313 } | 1304 } |
1314 | 1305 |
1315 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() | 1306 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() |
1316 const { | 1307 const { |
1317 return picture_layers_; | 1308 return picture_layers_; |
1318 } | 1309 } |
1319 | 1310 |
1320 void LayerTreeHostImpl::NotifyReadyToActivate() { | 1311 void LayerTreeHostImpl::NotifyReadyToActivate() { |
1321 client_->NotifyReadyToActivate(); | 1312 client_->NotifyReadyToActivate(); |
1322 } | 1313 } |
1323 | 1314 |
1324 void LayerTreeHostImpl::NotifyReadyToDraw() { | 1315 void LayerTreeHostImpl::NotifyReadyToDraw() { |
1325 client_->NotifyReadyToDraw(); | 1316 // Tiles that are ready will cause NotifyTileStateChanged() to be called so we |
brianderson
2014/10/31 22:42:54
Was this accidentally removed? The scheduler doesn
danakj
2014/11/03 16:26:04
I assumed it could go away since we already SetNee
| |
1317 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from | |
1318 // causing optimistic requests to draw a frame. | |
1319 required_for_draw_tile_is_top_of_raster_queue_ = false; | |
1326 } | 1320 } |
1327 | 1321 |
1328 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { | 1322 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { |
1329 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); | 1323 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); |
1330 | 1324 |
1331 if (active_tree_) { | 1325 if (active_tree_) { |
1332 LayerImpl* layer_impl = | 1326 LayerImpl* layer_impl = |
1333 active_tree_->FindActiveTreeLayerById(tile->layer_id()); | 1327 active_tree_->FindActiveTreeLayerById(tile->layer_id()); |
1334 if (layer_impl) | 1328 if (layer_impl) |
1335 layer_impl->NotifyTileStateChanged(tile); | 1329 layer_impl->NotifyTileStateChanged(tile); |
1336 } | 1330 } |
1337 | 1331 |
1338 if (pending_tree_) { | 1332 if (pending_tree_) { |
1339 LayerImpl* layer_impl = | 1333 LayerImpl* layer_impl = |
1340 pending_tree_->FindPendingTreeLayerById(tile->layer_id()); | 1334 pending_tree_->FindPendingTreeLayerById(tile->layer_id()); |
1341 if (layer_impl) | 1335 if (layer_impl) |
1342 layer_impl->NotifyTileStateChanged(tile); | 1336 layer_impl->NotifyTileStateChanged(tile); |
1343 } | 1337 } |
1338 | |
1339 // Check for a non-null active tree to avoid doing this during shutdown. | |
1340 if (active_tree_ && !client_->IsInsideDraw() && tile->required_for_draw()) { | |
1341 // The LayerImpl::NotifyTileStateChanged() should damage the layer, so this | |
1342 // redraw will make those tiles be displayed. | |
1343 SetNeedsRedraw(); | |
1344 } | |
1344 } | 1345 } |
1345 | 1346 |
1346 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { | 1347 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { |
1347 SetManagedMemoryPolicy(policy, zero_budget_); | 1348 SetManagedMemoryPolicy(policy, zero_budget_); |
1348 } | 1349 } |
1349 | 1350 |
1350 void LayerTreeHostImpl::SetTreeActivationCallback( | 1351 void LayerTreeHostImpl::SetTreeActivationCallback( |
1351 const base::Closure& callback) { | 1352 const base::Closure& callback) { |
1352 DCHECK(proxy_->IsImplThread()); | 1353 DCHECK(proxy_->IsImplThread()); |
1353 DCHECK(settings_.impl_side_painting || callback.is_null()); | 1354 DCHECK(settings_.impl_side_painting || callback.is_null()); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1682 else | 1683 else |
1683 DCHECK(!enable); | 1684 DCHECK(!enable); |
1684 } | 1685 } |
1685 | 1686 |
1686 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1687 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
1687 // Sample the frame time now. This time will be used for updating animations | 1688 // Sample the frame time now. This time will be used for updating animations |
1688 // when we draw. | 1689 // when we draw. |
1689 UpdateCurrentBeginFrameArgs(args); | 1690 UpdateCurrentBeginFrameArgs(args); |
1690 // Cache the begin impl frame interval | 1691 // Cache the begin impl frame interval |
1691 begin_impl_frame_interval_ = args.interval; | 1692 begin_impl_frame_interval_ = args.interval; |
1693 | |
1694 if (required_for_draw_tile_is_top_of_raster_queue_) { | |
1695 // Optimistically schedule a draw, as a tile required for draw is at the top | |
1696 // of the current raster queue. This will let us expect the tile to complete | |
1697 // and draw it within the impl frame we are beginning now. | |
1698 SetNeedsRedraw(); | |
1699 } | |
1692 } | 1700 } |
1693 | 1701 |
1694 void LayerTreeHostImpl::UpdateViewportContainerSizes() { | 1702 void LayerTreeHostImpl::UpdateViewportContainerSizes() { |
1695 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); | 1703 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); |
1696 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); | 1704 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); |
1697 | 1705 |
1698 if (!inner_container || !top_controls_manager_) | 1706 if (!inner_container || !top_controls_manager_) |
1699 return; | 1707 return; |
1700 | 1708 |
1701 ViewportAnchor anchor(InnerViewportScrollLayer(), | 1709 ViewportAnchor anchor(InnerViewportScrollLayer(), |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1809 pending_tree_->SetPageScaleDelta(active_tree_->page_scale_delta() / | 1817 pending_tree_->SetPageScaleDelta(active_tree_->page_scale_delta() / |
1810 active_tree_->sent_page_scale_delta()); | 1818 active_tree_->sent_page_scale_delta()); |
1811 pending_tree_->set_top_controls_delta( | 1819 pending_tree_->set_top_controls_delta( |
1812 active_tree_->top_controls_delta() - | 1820 active_tree_->top_controls_delta() - |
1813 active_tree_->sent_top_controls_delta()); | 1821 active_tree_->sent_top_controls_delta()); |
1814 | 1822 |
1815 client_->OnCanDrawStateChanged(CanDraw()); | 1823 client_->OnCanDrawStateChanged(CanDraw()); |
1816 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); | 1824 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); |
1817 } | 1825 } |
1818 | 1826 |
1819 void LayerTreeHostImpl::UpdateVisibleTiles() { | |
1820 if (tile_manager_ && tile_manager_->UpdateVisibleTiles()) | |
1821 DidInitializeVisibleTile(); | |
1822 need_to_update_visible_tiles_before_draw_ = false; | |
1823 } | |
1824 | |
1825 void LayerTreeHostImpl::ActivateSyncTree() { | 1827 void LayerTreeHostImpl::ActivateSyncTree() { |
1826 need_to_update_visible_tiles_before_draw_ = true; | |
1827 | |
1828 if (pending_tree_) { | 1828 if (pending_tree_) { |
1829 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); | 1829 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); |
1830 | 1830 |
1831 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); | 1831 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); |
1832 active_tree_->PushPersistedState(pending_tree_.get()); | 1832 active_tree_->PushPersistedState(pending_tree_.get()); |
1833 // Process any requests in the UI resource queue. The request queue is | 1833 // Process any requests in the UI resource queue. The request queue is |
1834 // given in LayerTreeHost::FinishCommitOnImplThread. This must take place | 1834 // given in LayerTreeHost::FinishCommitOnImplThread. This must take place |
1835 // before the swap. | 1835 // before the swap. |
1836 pending_tree_->ProcessUIResourceRequestQueue(); | 1836 pending_tree_->ProcessUIResourceRequestQueue(); |
1837 | 1837 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2021 IsSynchronousSingleThreaded() ? std::numeric_limits<size_t>::max() | 2021 IsSynchronousSingleThreaded() ? std::numeric_limits<size_t>::max() |
2022 : settings_.scheduled_raster_task_limit; | 2022 : settings_.scheduled_raster_task_limit; |
2023 tile_manager_ = TileManager::Create(this, | 2023 tile_manager_ = TileManager::Create(this, |
2024 task_runner, | 2024 task_runner, |
2025 resource_pool_.get(), | 2025 resource_pool_.get(), |
2026 raster_worker_pool_->AsRasterizer(), | 2026 raster_worker_pool_->AsRasterizer(), |
2027 rendering_stats_instrumentation_, | 2027 rendering_stats_instrumentation_, |
2028 scheduled_raster_task_limit); | 2028 scheduled_raster_task_limit); |
2029 | 2029 |
2030 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); | 2030 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); |
2031 need_to_update_visible_tiles_before_draw_ = false; | |
2032 } | 2031 } |
2033 | 2032 |
2034 void LayerTreeHostImpl::CreateResourceAndRasterWorkerPool( | 2033 void LayerTreeHostImpl::CreateResourceAndRasterWorkerPool( |
2035 scoped_ptr<RasterWorkerPool>* raster_worker_pool, | 2034 scoped_ptr<RasterWorkerPool>* raster_worker_pool, |
2036 scoped_ptr<ResourcePool>* resource_pool, | 2035 scoped_ptr<ResourcePool>* resource_pool, |
2037 scoped_ptr<ResourcePool>* staging_resource_pool) { | 2036 scoped_ptr<ResourcePool>* staging_resource_pool) { |
2038 base::SingleThreadTaskRunner* task_runner = | 2037 base::SingleThreadTaskRunner* task_runner = |
2039 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() | 2038 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() |
2040 : proxy_->MainThreadTaskRunner(); | 2039 : proxy_->MainThreadTaskRunner(); |
2041 DCHECK(task_runner); | 2040 DCHECK(task_runner); |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3023 ClearCurrentlyScrollingLayer(); | 3022 ClearCurrentlyScrollingLayer(); |
3024 } | 3023 } |
3025 if (top_controls_manager_) | 3024 if (top_controls_manager_) |
3026 top_controls_manager_->PinchEnd(); | 3025 top_controls_manager_->PinchEnd(); |
3027 client_->SetNeedsCommitOnImplThread(); | 3026 client_->SetNeedsCommitOnImplThread(); |
3028 // When a pinch ends, we may be displaying content cached at incorrect scales, | 3027 // When a pinch ends, we may be displaying content cached at incorrect scales, |
3029 // so updating draw properties and drawing will ensure we are using the right | 3028 // so updating draw properties and drawing will ensure we are using the right |
3030 // scales that we want when we're not inside a pinch. | 3029 // scales that we want when we're not inside a pinch. |
3031 active_tree_->set_needs_update_draw_properties(); | 3030 active_tree_->set_needs_update_draw_properties(); |
3032 SetNeedsRedraw(); | 3031 SetNeedsRedraw(); |
3033 // TODO(danakj): Don't set root damage. Just updating draw properties and | |
3034 // getting new tiles rastered should be enough! crbug.com/427423 | |
3035 SetFullRootLayerDamage(); | |
3036 } | 3032 } |
3037 | 3033 |
3038 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, | 3034 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, |
3039 LayerImpl* layer_impl) { | 3035 LayerImpl* layer_impl) { |
3040 if (!layer_impl) | 3036 if (!layer_impl) |
3041 return; | 3037 return; |
3042 | 3038 |
3043 gfx::Vector2d scroll_delta = | 3039 gfx::Vector2d scroll_delta = |
3044 gfx::ToFlooredVector2d(layer_impl->ScrollDelta()); | 3040 gfx::ToFlooredVector2d(layer_impl->ScrollDelta()); |
3045 if (!scroll_delta.IsZero()) { | 3041 if (!scroll_delta.IsZero()) { |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3518 } | 3514 } |
3519 | 3515 |
3520 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3516 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3521 std::vector<PictureLayerImpl*>::iterator it = | 3517 std::vector<PictureLayerImpl*>::iterator it = |
3522 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3518 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3523 DCHECK(it != picture_layers_.end()); | 3519 DCHECK(it != picture_layers_.end()); |
3524 picture_layers_.erase(it); | 3520 picture_layers_.erase(it); |
3525 } | 3521 } |
3526 | 3522 |
3527 } // namespace cc | 3523 } // namespace cc |
OLD | NEW |