Chromium Code Reviews| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 time_source_(time_source) { | 237 time_source_(time_source) { |
| 238 time_source_->SetClient(this); | 238 time_source_->SetClient(this); |
| 239 } | 239 } |
| 240 | 240 |
| 241 LayerTreeHostImpl* layer_tree_host_impl_; | 241 LayerTreeHostImpl* layer_tree_host_impl_; |
| 242 scoped_refptr<DelayBasedTimeSource> time_source_; | 242 scoped_refptr<DelayBasedTimeSource> time_source_; |
| 243 | 243 |
| 244 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImplTimeSourceAdapter); | 244 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImplTimeSourceAdapter); |
| 245 }; | 245 }; |
| 246 | 246 |
| 247 LayerTreeHostImpl::FrameData::FrameData() | 247 LayerTreeHostImpl::FrameData::FrameData() : has_no_damage(false) { |
| 248 : contains_incomplete_tile(false), has_no_damage(false) {} | 248 } |
| 249 | 249 |
| 250 LayerTreeHostImpl::FrameData::~FrameData() {} | 250 LayerTreeHostImpl::FrameData::~FrameData() {} |
| 251 | 251 |
| 252 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::Create( | 252 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::Create( |
| 253 const LayerTreeSettings& settings, | 253 const LayerTreeSettings& settings, |
| 254 LayerTreeHostImplClient* client, | 254 LayerTreeHostImplClient* client, |
| 255 Proxy* proxy, | 255 Proxy* proxy, |
| 256 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 256 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 257 SharedBitmapManager* shared_bitmap_manager, | 257 SharedBitmapManager* shared_bitmap_manager, |
| 258 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 258 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 : proxy_->MainThreadTaskRunner())), | 303 : proxy_->MainThreadTaskRunner())), |
| 304 max_memory_needed_bytes_(0), | 304 max_memory_needed_bytes_(0), |
| 305 zero_budget_(false), | 305 zero_budget_(false), |
| 306 device_scale_factor_(1.f), | 306 device_scale_factor_(1.f), |
| 307 overhang_ui_resource_id_(0), | 307 overhang_ui_resource_id_(0), |
| 308 resourceless_software_draw_(false), | 308 resourceless_software_draw_(false), |
| 309 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), | 309 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), |
| 310 animation_registrar_(AnimationRegistrar::Create()), | 310 animation_registrar_(AnimationRegistrar::Create()), |
| 311 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 311 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
| 312 micro_benchmark_controller_(this), | 312 micro_benchmark_controller_(this), |
| 313 need_to_update_visible_tiles_before_draw_(false), | |
| 314 shared_bitmap_manager_(shared_bitmap_manager), | 313 shared_bitmap_manager_(shared_bitmap_manager), |
| 315 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 314 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
| 316 id_(id), | 315 id_(id), |
| 317 requires_high_res_to_draw_(false) { | 316 requires_high_res_to_draw_(false), |
| 317 required_for_draw_tile_is_top_of_raster_queue_(false) { | |
| 318 DCHECK(proxy_->IsImplThread()); | 318 DCHECK(proxy_->IsImplThread()); |
| 319 DidVisibilityChange(this, visible_); | 319 DidVisibilityChange(this, visible_); |
| 320 animation_registrar_->set_supports_scroll_animations( | 320 animation_registrar_->set_supports_scroll_animations( |
| 321 proxy_->SupportsImplScrolling()); | 321 proxy_->SupportsImplScrolling()); |
| 322 | 322 |
| 323 SetDebugState(settings.initial_debug_state); | 323 SetDebugState(settings.initial_debug_state); |
| 324 | 324 |
| 325 // LTHI always has an active tree. | 325 // LTHI always has an active tree. |
| 326 active_tree_ = LayerTreeImpl::create(this); | 326 active_tree_ = LayerTreeImpl::create(this); |
| 327 TRACE_EVENT_OBJECT_CREATED_WITH_ID( | 327 TRACE_EVENT_OBJECT_CREATED_WITH_ID( |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 render_surface_layer->id(), | 545 render_surface_layer->id(), |
| 546 render_surface->SurfacePropertyChangedOnlyFromDescendant(), | 546 render_surface->SurfacePropertyChangedOnlyFromDescendant(), |
| 547 render_surface->content_rect(), | 547 render_surface->content_rect(), |
| 548 render_surface_layer->mask_layer(), | 548 render_surface_layer->mask_layer(), |
| 549 render_surface_layer->filters()); | 549 render_surface_layer->filters()); |
| 550 } | 550 } |
| 551 } | 551 } |
| 552 | 552 |
| 553 void LayerTreeHostImpl::FrameData::AsValueInto( | 553 void LayerTreeHostImpl::FrameData::AsValueInto( |
| 554 base::debug::TracedValue* value) const { | 554 base::debug::TracedValue* value) const { |
| 555 value->SetBoolean("contains_incomplete_tile", contains_incomplete_tile); | |
| 556 value->SetBoolean("has_no_damage", has_no_damage); | 555 value->SetBoolean("has_no_damage", has_no_damage); |
| 557 | 556 |
| 558 // Quad data can be quite large, so only dump render passes if we select | 557 // Quad data can be quite large, so only dump render passes if we select |
| 559 // cc.debug.quads. | 558 // cc.debug.quads. |
| 560 bool quads_enabled; | 559 bool quads_enabled; |
| 561 TRACE_EVENT_CATEGORY_GROUP_ENABLED( | 560 TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
| 562 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); | 561 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); |
| 563 if (quads_enabled) { | 562 if (quads_enabled) { |
| 564 value->BeginArray("render_passes"); | 563 value->BeginArray("render_passes"); |
| 565 for (size_t i = 0; i < render_passes.size(); ++i) { | 564 for (size_t i = 0; i < render_passes.size(); ++i) { |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 895 if (append_quads_data.num_missing_tiles) { | 894 if (append_quads_data.num_missing_tiles) { |
| 896 bool layer_has_animating_transform = | 895 bool layer_has_animating_transform = |
| 897 it->screen_space_transform_is_animating() || | 896 it->screen_space_transform_is_animating() || |
| 898 it->draw_transform_is_animating(); | 897 it->draw_transform_is_animating(); |
| 899 if (layer_has_animating_transform) | 898 if (layer_has_animating_transform) |
| 900 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; | 899 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; |
| 901 } | 900 } |
| 902 | 901 |
| 903 if (append_quads_data.num_incomplete_tiles || | 902 if (append_quads_data.num_incomplete_tiles || |
| 904 append_quads_data.num_missing_tiles) { | 903 append_quads_data.num_missing_tiles) { |
| 905 frame->contains_incomplete_tile = true; | |
| 906 if (RequiresHighResToDraw()) | 904 if (RequiresHighResToDraw()) |
| 907 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT; | 905 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT; |
| 908 } | 906 } |
| 909 | 907 |
| 910 occlusion_tracker.LeaveLayer(it); | 908 occlusion_tracker.LeaveLayer(it); |
| 911 } | 909 } |
| 912 | 910 |
| 913 if (have_copy_request || | 911 if (have_copy_request || |
| 914 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) | 912 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) |
| 915 draw_result = DRAW_SUCCESS; | 913 draw_result = DRAW_SUCCESS; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1112 DCHECK_GE(frame->render_passes.size(), position_from_end); | 1110 DCHECK_GE(frame->render_passes.size(), position_from_end); |
| 1113 } | 1111 } |
| 1114 } | 1112 } |
| 1115 } | 1113 } |
| 1116 | 1114 |
| 1117 DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { | 1115 DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { |
| 1118 TRACE_EVENT1("cc", | 1116 TRACE_EVENT1("cc", |
| 1119 "LayerTreeHostImpl::PrepareToDraw", | 1117 "LayerTreeHostImpl::PrepareToDraw", |
| 1120 "SourceFrameNumber", | 1118 "SourceFrameNumber", |
| 1121 active_tree_->source_frame_number()); | 1119 active_tree_->source_frame_number()); |
| 1122 | 1120 // This will cause NotifyTileStateChanged() to be called for any visible tiles |
| 1123 if (need_to_update_visible_tiles_before_draw_ && | 1121 // that completed, which will add damage to the frame for them so they appear |
| 1124 tile_manager_ && tile_manager_->UpdateVisibleTiles()) { | 1122 // as part of the current frame being drawn. |
| 1125 DidInitializeVisibleTile(); | 1123 if (settings().impl_side_painting) |
| 1126 } | 1124 tile_manager_->UpdateVisibleTiles(); |
| 1127 need_to_update_visible_tiles_before_draw_ = true; | |
| 1128 | 1125 |
| 1129 UMA_HISTOGRAM_CUSTOM_COUNTS( | 1126 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 1130 "Compositing.NumActiveLayers", active_tree_->NumLayers(), 1, 400, 20); | 1127 "Compositing.NumActiveLayers", active_tree_->NumLayers(), 1, 400, 20); |
| 1131 | 1128 |
| 1132 bool ok = active_tree_->UpdateDrawProperties(); | 1129 bool ok = active_tree_->UpdateDrawProperties(); |
| 1133 DCHECK(ok) << "UpdateDrawProperties failed during draw"; | 1130 DCHECK(ok) << "UpdateDrawProperties failed during draw"; |
| 1134 | 1131 |
| 1135 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); | 1132 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); |
| 1136 frame->render_passes.clear(); | 1133 frame->render_passes.clear(); |
| 1137 frame->render_passes_by_id.clear(); | 1134 frame->render_passes_by_id.clear(); |
| 1138 frame->will_draw_layers.clear(); | 1135 frame->will_draw_layers.clear(); |
| 1139 frame->contains_incomplete_tile = false; | |
| 1140 frame->has_no_damage = false; | 1136 frame->has_no_damage = false; |
| 1141 | 1137 |
| 1142 if (active_tree_->root_layer()) { | 1138 if (active_tree_->root_layer()) { |
| 1143 gfx::Rect device_viewport_damage_rect = viewport_damage_rect_; | 1139 gfx::Rect device_viewport_damage_rect = viewport_damage_rect_; |
| 1144 viewport_damage_rect_ = gfx::Rect(); | 1140 viewport_damage_rect_ = gfx::Rect(); |
| 1145 | 1141 |
| 1146 active_tree_->root_layer()->render_surface()->damage_tracker()-> | 1142 active_tree_->root_layer()->render_surface()->damage_tracker()-> |
| 1147 AddDamageNextUpdate(device_viewport_damage_rect); | 1143 AddDamageNextUpdate(device_viewport_damage_rect); |
| 1148 } | 1144 } |
| 1149 | 1145 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1160 } | 1156 } |
| 1161 | 1157 |
| 1162 void LayerTreeHostImpl::EvictTexturesForTesting() { | 1158 void LayerTreeHostImpl::EvictTexturesForTesting() { |
| 1163 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0)); | 1159 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0)); |
| 1164 } | 1160 } |
| 1165 | 1161 |
| 1166 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { | 1162 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { |
| 1167 NOTREACHED(); | 1163 NOTREACHED(); |
| 1168 } | 1164 } |
| 1169 | 1165 |
| 1170 void LayerTreeHostImpl::DidInitializeVisibleTileForTesting() { | |
| 1171 // Add arbitrary damage, to trigger prepare-to-draws. | |
| 1172 // Here, setting damage as viewport size, used only for testing. | |
| 1173 SetFullRootLayerDamage(); | |
| 1174 DidInitializeVisibleTile(); | |
| 1175 } | |
| 1176 | |
| 1177 void LayerTreeHostImpl::ResetTreesForTesting() { | 1166 void LayerTreeHostImpl::ResetTreesForTesting() { |
| 1178 if (active_tree_) | 1167 if (active_tree_) |
| 1179 active_tree_->DetachLayerTree(); | 1168 active_tree_->DetachLayerTree(); |
| 1180 active_tree_ = LayerTreeImpl::create(this); | 1169 active_tree_ = LayerTreeImpl::create(this); |
| 1181 if (pending_tree_) | 1170 if (pending_tree_) |
| 1182 pending_tree_->DetachLayerTree(); | 1171 pending_tree_->DetachLayerTree(); |
| 1183 pending_tree_ = nullptr; | 1172 pending_tree_ = nullptr; |
| 1184 if (recycle_tree_) | 1173 if (recycle_tree_) |
| 1185 recycle_tree_->DetachLayerTree(); | 1174 recycle_tree_->DetachLayerTree(); |
| 1186 recycle_tree_ = nullptr; | 1175 recycle_tree_ = nullptr; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1258 DidModifyTilePriorities(); | 1247 DidModifyTilePriorities(); |
| 1259 } | 1248 } |
| 1260 | 1249 |
| 1261 void LayerTreeHostImpl::DidModifyTilePriorities() { | 1250 void LayerTreeHostImpl::DidModifyTilePriorities() { |
| 1262 DCHECK(settings_.impl_side_painting); | 1251 DCHECK(settings_.impl_side_painting); |
| 1263 // Mark priorities as dirty and schedule a ManageTiles(). | 1252 // Mark priorities as dirty and schedule a ManageTiles(). |
| 1264 tile_priorities_dirty_ = true; | 1253 tile_priorities_dirty_ = true; |
| 1265 client_->SetNeedsManageTilesOnImplThread(); | 1254 client_->SetNeedsManageTilesOnImplThread(); |
| 1266 } | 1255 } |
| 1267 | 1256 |
| 1268 void LayerTreeHostImpl::DidInitializeVisibleTile() { | |
| 1269 if (client_ && !client_->IsInsideDraw()) | |
| 1270 client_->DidInitializeVisibleTileOnImplThread(); | |
| 1271 } | |
| 1272 | |
| 1273 void LayerTreeHostImpl::GetPictureLayerImplPairs( | 1257 void LayerTreeHostImpl::GetPictureLayerImplPairs( |
| 1274 std::vector<PictureLayerImpl::Pair>* layer_pairs) const { | 1258 std::vector<PictureLayerImpl::Pair>* layer_pairs) const { |
| 1275 DCHECK(layer_pairs->empty()); | 1259 DCHECK(layer_pairs->empty()); |
| 1276 for (std::vector<PictureLayerImpl*>::const_iterator it = | 1260 for (std::vector<PictureLayerImpl*>::const_iterator it = |
| 1277 picture_layers_.begin(); | 1261 picture_layers_.begin(); |
| 1278 it != picture_layers_.end(); | 1262 it != picture_layers_.end(); |
| 1279 ++it) { | 1263 ++it) { |
| 1280 PictureLayerImpl* layer = *it; | 1264 PictureLayerImpl* layer = *it; |
| 1281 | 1265 |
| 1282 // TODO(vmpstr): Iterators and should handle this instead. crbug.com/381704 | 1266 // TODO(vmpstr): Iterators and should handle this instead. crbug.com/381704 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1301 } | 1285 } |
| 1302 } | 1286 } |
| 1303 } | 1287 } |
| 1304 | 1288 |
| 1305 void LayerTreeHostImpl::BuildRasterQueue(RasterTilePriorityQueue* queue, | 1289 void LayerTreeHostImpl::BuildRasterQueue(RasterTilePriorityQueue* queue, |
| 1306 TreePriority tree_priority) { | 1290 TreePriority tree_priority) { |
| 1307 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); | 1291 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); |
| 1308 picture_layer_pairs_.clear(); | 1292 picture_layer_pairs_.clear(); |
| 1309 GetPictureLayerImplPairs(&picture_layer_pairs_); | 1293 GetPictureLayerImplPairs(&picture_layer_pairs_); |
| 1310 queue->Build(picture_layer_pairs_, tree_priority); | 1294 queue->Build(picture_layer_pairs_, tree_priority); |
| 1295 | |
| 1296 if (!queue->IsEmpty()) { | |
| 1297 required_for_draw_tile_is_top_of_raster_queue_ = | |
| 1298 queue->Top()->required_for_draw(); | |
| 1299 } else { | |
| 1300 required_for_draw_tile_is_top_of_raster_queue_ = false; | |
| 1301 } | |
| 1311 } | 1302 } |
| 1312 | 1303 |
| 1313 void LayerTreeHostImpl::BuildEvictionQueue(EvictionTilePriorityQueue* queue, | 1304 void LayerTreeHostImpl::BuildEvictionQueue(EvictionTilePriorityQueue* queue, |
| 1314 TreePriority tree_priority) { | 1305 TreePriority tree_priority) { |
| 1315 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); | 1306 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); |
| 1316 picture_layer_pairs_.clear(); | 1307 picture_layer_pairs_.clear(); |
| 1317 GetPictureLayerImplPairs(&picture_layer_pairs_); | 1308 GetPictureLayerImplPairs(&picture_layer_pairs_); |
| 1318 queue->Build(picture_layer_pairs_, tree_priority); | 1309 queue->Build(picture_layer_pairs_, tree_priority); |
| 1319 } | 1310 } |
| 1320 | 1311 |
| 1321 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() | 1312 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() |
| 1322 const { | 1313 const { |
| 1323 return picture_layers_; | 1314 return picture_layers_; |
| 1324 } | 1315 } |
| 1325 | 1316 |
| 1326 void LayerTreeHostImpl::NotifyReadyToActivate() { | 1317 void LayerTreeHostImpl::NotifyReadyToActivate() { |
| 1327 client_->NotifyReadyToActivate(); | 1318 client_->NotifyReadyToActivate(); |
| 1328 } | 1319 } |
| 1329 | 1320 |
| 1330 void LayerTreeHostImpl::NotifyReadyToDraw() { | 1321 void LayerTreeHostImpl::NotifyReadyToDraw() { |
| 1322 // Tiles that are ready will cause NotifyTileStateChanged() to be called so we | |
| 1323 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from | |
| 1324 // causing optimistic requests to draw a frame. | |
| 1325 required_for_draw_tile_is_top_of_raster_queue_ = false; | |
| 1326 | |
| 1331 client_->NotifyReadyToDraw(); | 1327 client_->NotifyReadyToDraw(); |
| 1332 } | 1328 } |
| 1333 | 1329 |
| 1334 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { | 1330 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { |
| 1335 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); | 1331 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); |
| 1336 | 1332 |
| 1337 if (active_tree_) { | 1333 if (active_tree_) { |
| 1338 LayerImpl* layer_impl = | 1334 LayerImpl* layer_impl = |
| 1339 active_tree_->FindActiveTreeLayerById(tile->layer_id()); | 1335 active_tree_->FindActiveTreeLayerById(tile->layer_id()); |
| 1340 if (layer_impl) | 1336 if (layer_impl) |
| 1341 layer_impl->NotifyTileStateChanged(tile); | 1337 layer_impl->NotifyTileStateChanged(tile); |
| 1342 } | 1338 } |
| 1343 | 1339 |
| 1344 if (pending_tree_) { | 1340 if (pending_tree_) { |
| 1345 LayerImpl* layer_impl = | 1341 LayerImpl* layer_impl = |
| 1346 pending_tree_->FindPendingTreeLayerById(tile->layer_id()); | 1342 pending_tree_->FindPendingTreeLayerById(tile->layer_id()); |
| 1347 if (layer_impl) | 1343 if (layer_impl) |
| 1348 layer_impl->NotifyTileStateChanged(tile); | 1344 layer_impl->NotifyTileStateChanged(tile); |
| 1349 } | 1345 } |
| 1346 | |
| 1347 // Check for a non-null active tree to avoid doing this during shutdown. | |
| 1348 if (active_tree_ && !client_->IsInsideDraw() && tile->required_for_draw()) { | |
|
vmpstr
2014/11/10 22:47:04
Is there any way to push this check into picture l
| |
| 1349 // The LayerImpl::NotifyTileStateChanged() should damage the layer, so this | |
| 1350 // redraw will make those tiles be displayed. | |
| 1351 SetNeedsRedraw(); | |
| 1352 } | |
| 1350 } | 1353 } |
| 1351 | 1354 |
| 1352 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { | 1355 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { |
| 1353 SetManagedMemoryPolicy(policy, zero_budget_); | 1356 SetManagedMemoryPolicy(policy, zero_budget_); |
| 1354 } | 1357 } |
| 1355 | 1358 |
| 1356 void LayerTreeHostImpl::SetTreeActivationCallback( | 1359 void LayerTreeHostImpl::SetTreeActivationCallback( |
| 1357 const base::Closure& callback) { | 1360 const base::Closure& callback) { |
| 1358 DCHECK(proxy_->IsImplThread()); | 1361 DCHECK(proxy_->IsImplThread()); |
| 1359 DCHECK(settings_.impl_side_painting || callback.is_null()); | 1362 DCHECK(settings_.impl_side_painting || callback.is_null()); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1688 else | 1691 else |
| 1689 DCHECK(!enable); | 1692 DCHECK(!enable); |
| 1690 } | 1693 } |
| 1691 | 1694 |
| 1692 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1695 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
| 1693 // Sample the frame time now. This time will be used for updating animations | 1696 // Sample the frame time now. This time will be used for updating animations |
| 1694 // when we draw. | 1697 // when we draw. |
| 1695 UpdateCurrentBeginFrameArgs(args); | 1698 UpdateCurrentBeginFrameArgs(args); |
| 1696 // Cache the begin impl frame interval | 1699 // Cache the begin impl frame interval |
| 1697 begin_impl_frame_interval_ = args.interval; | 1700 begin_impl_frame_interval_ = args.interval; |
| 1701 | |
| 1702 if (required_for_draw_tile_is_top_of_raster_queue_) { | |
| 1703 // Optimistically schedule a draw, as a tile required for draw is at the top | |
| 1704 // of the current raster queue. This will let us expect the tile to complete | |
| 1705 // and draw it within the impl frame we are beginning now. | |
| 1706 SetNeedsRedraw(); | |
| 1707 } | |
| 1698 } | 1708 } |
| 1699 | 1709 |
| 1700 void LayerTreeHostImpl::UpdateViewportContainerSizes() { | 1710 void LayerTreeHostImpl::UpdateViewportContainerSizes() { |
| 1701 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); | 1711 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); |
| 1702 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); | 1712 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); |
| 1703 | 1713 |
| 1704 if (!inner_container || !top_controls_manager_) | 1714 if (!inner_container || !top_controls_manager_) |
| 1705 return; | 1715 return; |
| 1706 | 1716 |
| 1707 ViewportAnchor anchor(InnerViewportScrollLayer(), | 1717 ViewportAnchor anchor(InnerViewportScrollLayer(), |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1815 pending_tree_->SetPageScaleDelta(active_tree_->page_scale_delta() / | 1825 pending_tree_->SetPageScaleDelta(active_tree_->page_scale_delta() / |
| 1816 active_tree_->sent_page_scale_delta()); | 1826 active_tree_->sent_page_scale_delta()); |
| 1817 pending_tree_->set_top_controls_delta( | 1827 pending_tree_->set_top_controls_delta( |
| 1818 active_tree_->top_controls_delta() - | 1828 active_tree_->top_controls_delta() - |
| 1819 active_tree_->sent_top_controls_delta()); | 1829 active_tree_->sent_top_controls_delta()); |
| 1820 | 1830 |
| 1821 client_->OnCanDrawStateChanged(CanDraw()); | 1831 client_->OnCanDrawStateChanged(CanDraw()); |
| 1822 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); | 1832 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); |
| 1823 } | 1833 } |
| 1824 | 1834 |
| 1825 void LayerTreeHostImpl::UpdateVisibleTiles() { | |
| 1826 if (tile_manager_ && tile_manager_->UpdateVisibleTiles()) | |
| 1827 DidInitializeVisibleTile(); | |
| 1828 need_to_update_visible_tiles_before_draw_ = false; | |
| 1829 } | |
| 1830 | |
| 1831 void LayerTreeHostImpl::ActivateSyncTree() { | 1835 void LayerTreeHostImpl::ActivateSyncTree() { |
| 1832 need_to_update_visible_tiles_before_draw_ = true; | |
| 1833 | |
| 1834 if (pending_tree_) { | 1836 if (pending_tree_) { |
| 1835 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); | 1837 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); |
| 1836 | 1838 |
| 1837 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); | 1839 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); |
| 1838 active_tree_->PushPersistedState(pending_tree_.get()); | 1840 active_tree_->PushPersistedState(pending_tree_.get()); |
| 1839 // Process any requests in the UI resource queue. The request queue is | 1841 // Process any requests in the UI resource queue. The request queue is |
| 1840 // given in LayerTreeHost::FinishCommitOnImplThread. This must take place | 1842 // given in LayerTreeHost::FinishCommitOnImplThread. This must take place |
| 1841 // before the swap. | 1843 // before the swap. |
| 1842 pending_tree_->ProcessUIResourceRequestQueue(); | 1844 pending_tree_->ProcessUIResourceRequestQueue(); |
| 1843 | 1845 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2029 IsSynchronousSingleThreaded() ? std::numeric_limits<size_t>::max() | 2031 IsSynchronousSingleThreaded() ? std::numeric_limits<size_t>::max() |
| 2030 : settings_.scheduled_raster_task_limit; | 2032 : settings_.scheduled_raster_task_limit; |
| 2031 tile_manager_ = TileManager::Create(this, | 2033 tile_manager_ = TileManager::Create(this, |
| 2032 task_runner, | 2034 task_runner, |
| 2033 resource_pool_.get(), | 2035 resource_pool_.get(), |
| 2034 raster_worker_pool_->AsRasterizer(), | 2036 raster_worker_pool_->AsRasterizer(), |
| 2035 rendering_stats_instrumentation_, | 2037 rendering_stats_instrumentation_, |
| 2036 scheduled_raster_task_limit); | 2038 scheduled_raster_task_limit); |
| 2037 | 2039 |
| 2038 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); | 2040 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); |
| 2039 need_to_update_visible_tiles_before_draw_ = false; | |
| 2040 } | 2041 } |
| 2041 | 2042 |
| 2042 void LayerTreeHostImpl::CreateResourceAndRasterWorkerPool( | 2043 void LayerTreeHostImpl::CreateResourceAndRasterWorkerPool( |
| 2043 scoped_ptr<RasterWorkerPool>* raster_worker_pool, | 2044 scoped_ptr<RasterWorkerPool>* raster_worker_pool, |
| 2044 scoped_ptr<ResourcePool>* resource_pool, | 2045 scoped_ptr<ResourcePool>* resource_pool, |
| 2045 scoped_ptr<ResourcePool>* staging_resource_pool) { | 2046 scoped_ptr<ResourcePool>* staging_resource_pool) { |
| 2046 base::SingleThreadTaskRunner* task_runner = | 2047 base::SingleThreadTaskRunner* task_runner = |
| 2047 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() | 2048 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() |
| 2048 : proxy_->MainThreadTaskRunner(); | 2049 : proxy_->MainThreadTaskRunner(); |
| 2049 DCHECK(task_runner); | 2050 DCHECK(task_runner); |
| (...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3031 ClearCurrentlyScrollingLayer(); | 3032 ClearCurrentlyScrollingLayer(); |
| 3032 } | 3033 } |
| 3033 if (top_controls_manager_) | 3034 if (top_controls_manager_) |
| 3034 top_controls_manager_->PinchEnd(); | 3035 top_controls_manager_->PinchEnd(); |
| 3035 client_->SetNeedsCommitOnImplThread(); | 3036 client_->SetNeedsCommitOnImplThread(); |
| 3036 // When a pinch ends, we may be displaying content cached at incorrect scales, | 3037 // When a pinch ends, we may be displaying content cached at incorrect scales, |
| 3037 // so updating draw properties and drawing will ensure we are using the right | 3038 // so updating draw properties and drawing will ensure we are using the right |
| 3038 // scales that we want when we're not inside a pinch. | 3039 // scales that we want when we're not inside a pinch. |
| 3039 active_tree_->set_needs_update_draw_properties(); | 3040 active_tree_->set_needs_update_draw_properties(); |
| 3040 SetNeedsRedraw(); | 3041 SetNeedsRedraw(); |
| 3041 // TODO(danakj): Don't set root damage. Just updating draw properties and | |
| 3042 // getting new tiles rastered should be enough! crbug.com/427423 | |
| 3043 SetFullRootLayerDamage(); | |
| 3044 } | 3042 } |
| 3045 | 3043 |
| 3046 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, | 3044 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, |
| 3047 LayerImpl* layer_impl) { | 3045 LayerImpl* layer_impl) { |
| 3048 if (!layer_impl) | 3046 if (!layer_impl) |
| 3049 return; | 3047 return; |
| 3050 | 3048 |
| 3051 gfx::Vector2d scroll_delta = | 3049 gfx::Vector2d scroll_delta = |
| 3052 gfx::ToFlooredVector2d(layer_impl->ScrollDelta()); | 3050 gfx::ToFlooredVector2d(layer_impl->ScrollDelta()); |
| 3053 if (!scroll_delta.IsZero()) { | 3051 if (!scroll_delta.IsZero()) { |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3526 } | 3524 } |
| 3527 | 3525 |
| 3528 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3526 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3529 std::vector<PictureLayerImpl*>::iterator it = | 3527 std::vector<PictureLayerImpl*>::iterator it = |
| 3530 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3528 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3531 DCHECK(it != picture_layers_.end()); | 3529 DCHECK(it != picture_layers_.end()); |
| 3532 picture_layers_.erase(it); | 3530 picture_layers_.erase(it); |
| 3533 } | 3531 } |
| 3534 | 3532 |
| 3535 } // namespace cc | 3533 } // namespace cc |
| OLD | NEW |