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 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1193 } | 1193 } |
1194 } | 1194 } |
1195 } | 1195 } |
1196 | 1196 |
1197 scoped_ptr<RasterTilePriorityQueue> LayerTreeHostImpl::BuildRasterQueue( | 1197 scoped_ptr<RasterTilePriorityQueue> LayerTreeHostImpl::BuildRasterQueue( |
1198 TreePriority tree_priority, | 1198 TreePriority tree_priority, |
1199 RasterTilePriorityQueue::Type type) { | 1199 RasterTilePriorityQueue::Type type) { |
1200 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); | 1200 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); |
1201 picture_layer_pairs_.clear(); | 1201 picture_layer_pairs_.clear(); |
1202 GetPictureLayerImplPairs(&picture_layer_pairs_, true); | 1202 GetPictureLayerImplPairs(&picture_layer_pairs_, true); |
1203 scoped_ptr<RasterTilePriorityQueue> queue(RasterTilePriorityQueue::Create( | 1203 return RasterTilePriorityQueue::Create(picture_layer_pairs_, tree_priority, |
1204 picture_layer_pairs_, tree_priority, type)); | 1204 type); |
1205 | |
1206 if (!queue->IsEmpty()) { | |
1207 // Only checking the Top() tile here isn't a definite answer that there is | |
1208 // or isn't something required for draw in this raster queue. It's just a | |
1209 // heuristic to let us hit the common case and proactively tell the | |
1210 // scheduler that we expect to draw within each vsync until we get all the | |
1211 // tiles ready to draw. If we happen to miss a required for draw tile here, | |
1212 // then we will miss telling the scheduler each frame that we intend to draw | |
1213 // so it may make worse scheduling decisions. | |
1214 required_for_draw_tile_is_top_of_raster_queue_ = | |
1215 queue->Top()->required_for_draw(); | |
1216 } else { | |
1217 required_for_draw_tile_is_top_of_raster_queue_ = false; | |
1218 } | |
1219 return queue; | |
1220 } | 1205 } |
1221 | 1206 |
1222 scoped_ptr<EvictionTilePriorityQueue> LayerTreeHostImpl::BuildEvictionQueue( | 1207 scoped_ptr<EvictionTilePriorityQueue> LayerTreeHostImpl::BuildEvictionQueue( |
1223 TreePriority tree_priority) { | 1208 TreePriority tree_priority) { |
1224 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); | 1209 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); |
1225 scoped_ptr<EvictionTilePriorityQueue> queue(new EvictionTilePriorityQueue); | 1210 scoped_ptr<EvictionTilePriorityQueue> queue(new EvictionTilePriorityQueue); |
1226 picture_layer_pairs_.clear(); | 1211 picture_layer_pairs_.clear(); |
1227 GetPictureLayerImplPairs(&picture_layer_pairs_, false); | 1212 GetPictureLayerImplPairs(&picture_layer_pairs_, false); |
1228 queue->Build(picture_layer_pairs_, tree_priority); | 1213 queue->Build(picture_layer_pairs_, tree_priority); |
1229 return queue; | 1214 return queue; |
1230 } | 1215 } |
1231 | 1216 |
1217 void LayerTreeHostImpl::SetIsLikelyToRequireADraw( | |
1218 bool is_likely_to_require_a_draw) { | |
vmpstr
2015/01/26 22:08:35
Since we're updating this only in certain cases, d
| |
1219 // Proactively tell the scheduler that we expect to draw within each vsync | |
1220 // until we get all the tiles ready to draw. If we happen to miss a required | |
1221 // for draw tile here, then we will miss telling the scheduler each frame that | |
1222 // we intend to draw so it may make worse scheduling decisions. | |
1223 is_likely_to_require_a_draw_ = is_likely_to_require_a_draw; | |
1224 } | |
1225 | |
1232 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() | 1226 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() |
1233 const { | 1227 const { |
1234 return picture_layers_; | 1228 return picture_layers_; |
1235 } | 1229 } |
1236 | 1230 |
1237 void LayerTreeHostImpl::NotifyReadyToActivate() { | 1231 void LayerTreeHostImpl::NotifyReadyToActivate() { |
1238 client_->NotifyReadyToActivate(); | 1232 client_->NotifyReadyToActivate(); |
1239 } | 1233 } |
1240 | 1234 |
1241 void LayerTreeHostImpl::NotifyReadyToDraw() { | 1235 void LayerTreeHostImpl::NotifyReadyToDraw() { |
1242 // Tiles that are ready will cause NotifyTileStateChanged() to be called so we | 1236 // Tiles that are ready will cause NotifyTileStateChanged() to be called so we |
1243 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from | 1237 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from |
1244 // causing optimistic requests to draw a frame. | 1238 // causing optimistic requests to draw a frame. |
1245 required_for_draw_tile_is_top_of_raster_queue_ = false; | 1239 is_likely_to_require_a_draw_ = false; |
1246 | 1240 |
1247 client_->NotifyReadyToDraw(); | 1241 client_->NotifyReadyToDraw(); |
1248 } | 1242 } |
1249 | 1243 |
1250 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { | 1244 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { |
1251 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); | 1245 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); |
1252 | 1246 |
1253 if (active_tree_) { | 1247 if (active_tree_) { |
1254 LayerImpl* layer_impl = | 1248 LayerImpl* layer_impl = |
1255 active_tree_->FindActiveTreeLayerById(tile->layer_id()); | 1249 active_tree_->FindActiveTreeLayerById(tile->layer_id()); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1605 return true; | 1599 return true; |
1606 } | 1600 } |
1607 | 1601 |
1608 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1602 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
1609 // Sample the frame time now. This time will be used for updating animations | 1603 // Sample the frame time now. This time will be used for updating animations |
1610 // when we draw. | 1604 // when we draw. |
1611 UpdateCurrentBeginFrameArgs(args); | 1605 UpdateCurrentBeginFrameArgs(args); |
1612 // Cache the begin impl frame interval | 1606 // Cache the begin impl frame interval |
1613 begin_impl_frame_interval_ = args.interval; | 1607 begin_impl_frame_interval_ = args.interval; |
1614 | 1608 |
1615 if (required_for_draw_tile_is_top_of_raster_queue_) { | 1609 if (is_likely_to_require_a_draw_) { |
1616 // Optimistically schedule a draw, as a tile required for draw is at the top | 1610 // Optimistically schedule a draw, as a tile required for draw is at the top |
1617 // of the current raster queue. This will let us expect the tile to complete | 1611 // of the current raster queue. This will let us expect the tile to complete |
1618 // and draw it within the impl frame we are beginning now. | 1612 // and draw it within the impl frame we are beginning now. |
1619 SetNeedsRedraw(); | 1613 SetNeedsRedraw(); |
1620 } | 1614 } |
1621 } | 1615 } |
1622 | 1616 |
1623 void LayerTreeHostImpl::UpdateViewportContainerSizes() { | 1617 void LayerTreeHostImpl::UpdateViewportContainerSizes() { |
1624 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); | 1618 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); |
1625 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); | 1619 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); |
(...skipping 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3460 } | 3454 } |
3461 | 3455 |
3462 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3456 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3463 std::vector<PictureLayerImpl*>::iterator it = | 3457 std::vector<PictureLayerImpl*>::iterator it = |
3464 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3458 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3465 DCHECK(it != picture_layers_.end()); | 3459 DCHECK(it != picture_layers_.end()); |
3466 picture_layers_.erase(it); | 3460 picture_layers_.erase(it); |
3467 } | 3461 } |
3468 | 3462 |
3469 } // namespace cc | 3463 } // namespace cc |
OLD | NEW |