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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 device_scale_factor_(1.f), | 222 device_scale_factor_(1.f), |
223 resourceless_software_draw_(false), | 223 resourceless_software_draw_(false), |
224 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), | 224 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), |
225 animation_registrar_(AnimationRegistrar::Create()), | 225 animation_registrar_(AnimationRegistrar::Create()), |
226 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 226 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
227 micro_benchmark_controller_(this), | 227 micro_benchmark_controller_(this), |
228 shared_bitmap_manager_(shared_bitmap_manager), | 228 shared_bitmap_manager_(shared_bitmap_manager), |
229 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 229 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
230 id_(id), | 230 id_(id), |
231 requires_high_res_to_draw_(false), | 231 requires_high_res_to_draw_(false), |
232 required_for_draw_tile_is_top_of_raster_queue_(false) { | 232 is_likely_to_require_a_draw_(false) { |
233 DCHECK(proxy_->IsImplThread()); | 233 DCHECK(proxy_->IsImplThread()); |
234 DidVisibilityChange(this, visible_); | 234 DidVisibilityChange(this, visible_); |
235 animation_registrar_->set_supports_scroll_animations( | 235 animation_registrar_->set_supports_scroll_animations( |
236 proxy_->SupportsImplScrolling()); | 236 proxy_->SupportsImplScrolling()); |
237 | 237 |
238 SetDebugState(settings.initial_debug_state); | 238 SetDebugState(settings.initial_debug_state); |
239 | 239 |
240 // LTHI always has an active tree. | 240 // LTHI always has an active tree. |
241 active_tree_ = LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(), | 241 active_tree_ = LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(), |
242 new SyncedElasticOverscroll); | 242 new SyncedElasticOverscroll); |
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 } | 1192 } |
1193 } | 1193 } |
1194 } | 1194 } |
1195 | 1195 |
1196 scoped_ptr<RasterTilePriorityQueue> LayerTreeHostImpl::BuildRasterQueue( | 1196 scoped_ptr<RasterTilePriorityQueue> LayerTreeHostImpl::BuildRasterQueue( |
1197 TreePriority tree_priority, | 1197 TreePriority tree_priority, |
1198 RasterTilePriorityQueue::Type type) { | 1198 RasterTilePriorityQueue::Type type) { |
1199 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); | 1199 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); |
1200 picture_layer_pairs_.clear(); | 1200 picture_layer_pairs_.clear(); |
1201 GetPictureLayerImplPairs(&picture_layer_pairs_, true); | 1201 GetPictureLayerImplPairs(&picture_layer_pairs_, true); |
1202 scoped_ptr<RasterTilePriorityQueue> queue(RasterTilePriorityQueue::Create( | 1202 return RasterTilePriorityQueue::Create(picture_layer_pairs_, tree_priority, |
1203 picture_layer_pairs_, tree_priority, type)); | 1203 type); |
1204 | |
1205 // Only check whether the top tile is required for draw if we're not building | |
1206 // a required for activation queue. | |
1207 // TODO(vmpstr): Remove side-effects from this function. crbug.com/451147 | |
1208 if (type != RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION) { | |
1209 if (!queue->IsEmpty()) { | |
1210 // Only checking the Top() tile here isn't a definite answer that there is | |
1211 // or isn't something required for draw in this raster queue. It's just a | |
1212 // heuristic to let us hit the common case and proactively tell the | |
1213 // scheduler that we expect to draw within each vsync until we get all the | |
1214 // tiles ready to draw. If we happen to miss a required for draw tile | |
1215 // here, then we will miss telling the scheduler each frame that we intend | |
1216 // to draw so it may make worse scheduling decisions. | |
1217 required_for_draw_tile_is_top_of_raster_queue_ = | |
1218 queue->Top()->required_for_draw(); | |
1219 } else { | |
1220 required_for_draw_tile_is_top_of_raster_queue_ = false; | |
1221 } | |
1222 } | |
1223 return queue; | |
1224 } | 1204 } |
1225 | 1205 |
1226 scoped_ptr<EvictionTilePriorityQueue> LayerTreeHostImpl::BuildEvictionQueue( | 1206 scoped_ptr<EvictionTilePriorityQueue> LayerTreeHostImpl::BuildEvictionQueue( |
1227 TreePriority tree_priority) { | 1207 TreePriority tree_priority) { |
1228 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); | 1208 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); |
1229 scoped_ptr<EvictionTilePriorityQueue> queue(new EvictionTilePriorityQueue); | 1209 scoped_ptr<EvictionTilePriorityQueue> queue(new EvictionTilePriorityQueue); |
1230 picture_layer_pairs_.clear(); | 1210 picture_layer_pairs_.clear(); |
1231 GetPictureLayerImplPairs(&picture_layer_pairs_, false); | 1211 GetPictureLayerImplPairs(&picture_layer_pairs_, false); |
1232 queue->Build(picture_layer_pairs_, tree_priority); | 1212 queue->Build(picture_layer_pairs_, tree_priority); |
1233 return queue; | 1213 return queue; |
1234 } | 1214 } |
1235 | 1215 |
| 1216 void LayerTreeHostImpl::SetIsLikelyToRequireADraw( |
| 1217 bool is_likely_to_require_a_draw) { |
| 1218 // Proactively tell the scheduler that we expect to draw within each vsync |
| 1219 // until we get all the tiles ready to draw. If we happen to miss a required |
| 1220 // for draw tile here, then we will miss telling the scheduler each frame that |
| 1221 // we intend to draw so it may make worse scheduling decisions. |
| 1222 is_likely_to_require_a_draw_ = is_likely_to_require_a_draw; |
| 1223 } |
| 1224 |
1236 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() | 1225 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() |
1237 const { | 1226 const { |
1238 return picture_layers_; | 1227 return picture_layers_; |
1239 } | 1228 } |
1240 | 1229 |
1241 void LayerTreeHostImpl::NotifyReadyToActivate() { | 1230 void LayerTreeHostImpl::NotifyReadyToActivate() { |
1242 client_->NotifyReadyToActivate(); | 1231 client_->NotifyReadyToActivate(); |
1243 } | 1232 } |
1244 | 1233 |
1245 void LayerTreeHostImpl::NotifyReadyToDraw() { | 1234 void LayerTreeHostImpl::NotifyReadyToDraw() { |
1246 // Tiles that are ready will cause NotifyTileStateChanged() to be called so we | 1235 // Tiles that are ready will cause NotifyTileStateChanged() to be called so we |
1247 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from | 1236 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from |
1248 // causing optimistic requests to draw a frame. | 1237 // causing optimistic requests to draw a frame. |
1249 required_for_draw_tile_is_top_of_raster_queue_ = false; | 1238 is_likely_to_require_a_draw_ = false; |
1250 | 1239 |
1251 client_->NotifyReadyToDraw(); | 1240 client_->NotifyReadyToDraw(); |
1252 } | 1241 } |
1253 | 1242 |
1254 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { | 1243 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { |
1255 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); | 1244 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); |
1256 | 1245 |
1257 if (active_tree_) { | 1246 if (active_tree_) { |
1258 LayerImpl* layer_impl = | 1247 LayerImpl* layer_impl = |
1259 active_tree_->FindActiveTreeLayerById(tile->layer_id()); | 1248 active_tree_->FindActiveTreeLayerById(tile->layer_id()); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1609 return true; | 1598 return true; |
1610 } | 1599 } |
1611 | 1600 |
1612 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1601 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
1613 // Sample the frame time now. This time will be used for updating animations | 1602 // Sample the frame time now. This time will be used for updating animations |
1614 // when we draw. | 1603 // when we draw. |
1615 UpdateCurrentBeginFrameArgs(args); | 1604 UpdateCurrentBeginFrameArgs(args); |
1616 // Cache the begin impl frame interval | 1605 // Cache the begin impl frame interval |
1617 begin_impl_frame_interval_ = args.interval; | 1606 begin_impl_frame_interval_ = args.interval; |
1618 | 1607 |
1619 if (required_for_draw_tile_is_top_of_raster_queue_) { | 1608 if (is_likely_to_require_a_draw_) { |
1620 // Optimistically schedule a draw, as a tile required for draw is at the top | 1609 // Optimistically schedule a draw. This will let us expect the tile manager |
1621 // of the current raster queue. This will let us expect the tile to complete | 1610 // to complete its work so that we can draw new tiles within the impl frame |
1622 // and draw it within the impl frame we are beginning now. | 1611 // we are beginning now. |
1623 SetNeedsRedraw(); | 1612 SetNeedsRedraw(); |
1624 } | 1613 } |
1625 } | 1614 } |
1626 | 1615 |
1627 void LayerTreeHostImpl::UpdateViewportContainerSizes() { | 1616 void LayerTreeHostImpl::UpdateViewportContainerSizes() { |
1628 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); | 1617 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); |
1629 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); | 1618 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); |
1630 | 1619 |
1631 if (!inner_container || !top_controls_manager_) | 1620 if (!inner_container || !top_controls_manager_) |
1632 return; | 1621 return; |
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3458 } | 3447 } |
3459 | 3448 |
3460 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3449 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3461 std::vector<PictureLayerImpl*>::iterator it = | 3450 std::vector<PictureLayerImpl*>::iterator it = |
3462 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3451 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3463 DCHECK(it != picture_layers_.end()); | 3452 DCHECK(it != picture_layers_.end()); |
3464 picture_layers_.erase(it); | 3453 picture_layers_.erase(it); |
3465 } | 3454 } |
3466 | 3455 |
3467 } // namespace cc | 3456 } // namespace cc |
OLD | NEW |