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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 return GL_TEXTURE_2D; | 166 return GL_TEXTURE_2D; |
167 } | 167 } |
168 | 168 |
169 size_t GetMaxStagingResourceCount() { | 169 size_t GetMaxStagingResourceCount() { |
170 // Upper bound for number of staging resource to allow. | 170 // Upper bound for number of staging resource to allow. |
171 return 32; | 171 return 32; |
172 } | 172 } |
173 | 173 |
174 } // namespace | 174 } // namespace |
175 | 175 |
176 LayerTreeHostImpl::FrameData::FrameData() | 176 LayerTreeHostImpl::FrameData::FrameData() : has_no_damage(false) { |
177 : contains_incomplete_tile(false), has_no_damage(false) {} | 177 } |
178 | 178 |
179 LayerTreeHostImpl::FrameData::~FrameData() {} | 179 LayerTreeHostImpl::FrameData::~FrameData() {} |
180 | 180 |
181 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::Create( | 181 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::Create( |
182 const LayerTreeSettings& settings, | 182 const LayerTreeSettings& settings, |
183 LayerTreeHostImplClient* client, | 183 LayerTreeHostImplClient* client, |
184 Proxy* proxy, | 184 Proxy* proxy, |
185 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 185 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
186 SharedBitmapManager* shared_bitmap_manager, | 186 SharedBitmapManager* shared_bitmap_manager, |
187 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 187 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 : proxy_->MainThreadTaskRunner())), | 231 : proxy_->MainThreadTaskRunner())), |
232 max_memory_needed_bytes_(0), | 232 max_memory_needed_bytes_(0), |
233 zero_budget_(false), | 233 zero_budget_(false), |
234 device_scale_factor_(1.f), | 234 device_scale_factor_(1.f), |
235 overhang_ui_resource_id_(0), | 235 overhang_ui_resource_id_(0), |
236 resourceless_software_draw_(false), | 236 resourceless_software_draw_(false), |
237 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), | 237 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), |
238 animation_registrar_(AnimationRegistrar::Create()), | 238 animation_registrar_(AnimationRegistrar::Create()), |
239 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 239 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
240 micro_benchmark_controller_(this), | 240 micro_benchmark_controller_(this), |
241 need_to_update_visible_tiles_before_draw_(false), | |
242 shared_bitmap_manager_(shared_bitmap_manager), | 241 shared_bitmap_manager_(shared_bitmap_manager), |
243 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 242 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
244 id_(id), | 243 id_(id), |
245 requires_high_res_to_draw_(false) { | 244 requires_high_res_to_draw_(false), |
| 245 required_for_draw_tile_is_top_of_raster_queue_(false) { |
246 DCHECK(proxy_->IsImplThread()); | 246 DCHECK(proxy_->IsImplThread()); |
247 DidVisibilityChange(this, visible_); | 247 DidVisibilityChange(this, visible_); |
248 animation_registrar_->set_supports_scroll_animations( | 248 animation_registrar_->set_supports_scroll_animations( |
249 proxy_->SupportsImplScrolling()); | 249 proxy_->SupportsImplScrolling()); |
250 | 250 |
251 SetDebugState(settings.initial_debug_state); | 251 SetDebugState(settings.initial_debug_state); |
252 | 252 |
253 // LTHI always has an active tree. | 253 // LTHI always has an active tree. |
254 active_tree_ = LayerTreeImpl::create(this); | 254 active_tree_ = LayerTreeImpl::create(this); |
255 TRACE_EVENT_OBJECT_CREATED_WITH_ID( | 255 TRACE_EVENT_OBJECT_CREATED_WITH_ID( |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 render_surface_layer->id(), | 473 render_surface_layer->id(), |
474 render_surface->SurfacePropertyChangedOnlyFromDescendant(), | 474 render_surface->SurfacePropertyChangedOnlyFromDescendant(), |
475 render_surface->content_rect(), | 475 render_surface->content_rect(), |
476 render_surface_layer->mask_layer(), | 476 render_surface_layer->mask_layer(), |
477 render_surface_layer->filters()); | 477 render_surface_layer->filters()); |
478 } | 478 } |
479 } | 479 } |
480 | 480 |
481 void LayerTreeHostImpl::FrameData::AsValueInto( | 481 void LayerTreeHostImpl::FrameData::AsValueInto( |
482 base::debug::TracedValue* value) const { | 482 base::debug::TracedValue* value) const { |
483 value->SetBoolean("contains_incomplete_tile", contains_incomplete_tile); | |
484 value->SetBoolean("has_no_damage", has_no_damage); | 483 value->SetBoolean("has_no_damage", has_no_damage); |
485 | 484 |
486 // Quad data can be quite large, so only dump render passes if we select | 485 // Quad data can be quite large, so only dump render passes if we select |
487 // cc.debug.quads. | 486 // cc.debug.quads. |
488 bool quads_enabled; | 487 bool quads_enabled; |
489 TRACE_EVENT_CATEGORY_GROUP_ENABLED( | 488 TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
490 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); | 489 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); |
491 if (quads_enabled) { | 490 if (quads_enabled) { |
492 value->BeginArray("render_passes"); | 491 value->BeginArray("render_passes"); |
493 for (size_t i = 0; i < render_passes.size(); ++i) { | 492 for (size_t i = 0; i < render_passes.size(); ++i) { |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 if (append_quads_data.num_missing_tiles) { | 822 if (append_quads_data.num_missing_tiles) { |
824 bool layer_has_animating_transform = | 823 bool layer_has_animating_transform = |
825 it->screen_space_transform_is_animating() || | 824 it->screen_space_transform_is_animating() || |
826 it->draw_transform_is_animating(); | 825 it->draw_transform_is_animating(); |
827 if (layer_has_animating_transform) | 826 if (layer_has_animating_transform) |
828 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; | 827 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; |
829 } | 828 } |
830 | 829 |
831 if (append_quads_data.num_incomplete_tiles || | 830 if (append_quads_data.num_incomplete_tiles || |
832 append_quads_data.num_missing_tiles) { | 831 append_quads_data.num_missing_tiles) { |
833 frame->contains_incomplete_tile = true; | |
834 if (RequiresHighResToDraw()) | 832 if (RequiresHighResToDraw()) |
835 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT; | 833 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT; |
836 } | 834 } |
837 | 835 |
838 occlusion_tracker.LeaveLayer(it); | 836 occlusion_tracker.LeaveLayer(it); |
839 } | 837 } |
840 | 838 |
841 if (have_copy_request || | 839 if (have_copy_request || |
842 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) | 840 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) |
843 draw_result = DRAW_SUCCESS; | 841 draw_result = DRAW_SUCCESS; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 DCHECK_GE(frame->render_passes.size(), position_from_end); | 1016 DCHECK_GE(frame->render_passes.size(), position_from_end); |
1019 } | 1017 } |
1020 } | 1018 } |
1021 } | 1019 } |
1022 | 1020 |
1023 DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { | 1021 DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { |
1024 TRACE_EVENT1("cc", | 1022 TRACE_EVENT1("cc", |
1025 "LayerTreeHostImpl::PrepareToDraw", | 1023 "LayerTreeHostImpl::PrepareToDraw", |
1026 "SourceFrameNumber", | 1024 "SourceFrameNumber", |
1027 active_tree_->source_frame_number()); | 1025 active_tree_->source_frame_number()); |
1028 | 1026 // This will cause NotifyTileStateChanged() to be called for any visible tiles |
1029 if (need_to_update_visible_tiles_before_draw_ && | 1027 // that completed, which will add damage to the frame for them so they appear |
1030 tile_manager_ && tile_manager_->UpdateVisibleTiles()) { | 1028 // as part of the current frame being drawn. |
1031 DidInitializeVisibleTile(); | 1029 if (settings().impl_side_painting) |
1032 } | 1030 tile_manager_->UpdateVisibleTiles(); |
1033 need_to_update_visible_tiles_before_draw_ = true; | |
1034 | 1031 |
1035 UMA_HISTOGRAM_CUSTOM_COUNTS( | 1032 UMA_HISTOGRAM_CUSTOM_COUNTS( |
1036 "Compositing.NumActiveLayers", active_tree_->NumLayers(), 1, 400, 20); | 1033 "Compositing.NumActiveLayers", active_tree_->NumLayers(), 1, 400, 20); |
1037 | 1034 |
1038 bool ok = active_tree_->UpdateDrawProperties(); | 1035 bool ok = active_tree_->UpdateDrawProperties(); |
1039 DCHECK(ok) << "UpdateDrawProperties failed during draw"; | 1036 DCHECK(ok) << "UpdateDrawProperties failed during draw"; |
1040 | 1037 |
1041 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); | 1038 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); |
1042 frame->render_passes.clear(); | 1039 frame->render_passes.clear(); |
1043 frame->render_passes_by_id.clear(); | 1040 frame->render_passes_by_id.clear(); |
1044 frame->will_draw_layers.clear(); | 1041 frame->will_draw_layers.clear(); |
1045 frame->contains_incomplete_tile = false; | |
1046 frame->has_no_damage = false; | 1042 frame->has_no_damage = false; |
1047 | 1043 |
1048 if (active_tree_->root_layer()) { | 1044 if (active_tree_->root_layer()) { |
1049 gfx::Rect device_viewport_damage_rect = viewport_damage_rect_; | 1045 gfx::Rect device_viewport_damage_rect = viewport_damage_rect_; |
1050 viewport_damage_rect_ = gfx::Rect(); | 1046 viewport_damage_rect_ = gfx::Rect(); |
1051 | 1047 |
1052 active_tree_->root_layer()->render_surface()->damage_tracker()-> | 1048 active_tree_->root_layer()->render_surface()->damage_tracker()-> |
1053 AddDamageNextUpdate(device_viewport_damage_rect); | 1049 AddDamageNextUpdate(device_viewport_damage_rect); |
1054 } | 1050 } |
1055 | 1051 |
(...skipping 10 matching lines...) Expand all Loading... |
1066 } | 1062 } |
1067 | 1063 |
1068 void LayerTreeHostImpl::EvictTexturesForTesting() { | 1064 void LayerTreeHostImpl::EvictTexturesForTesting() { |
1069 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0)); | 1065 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0)); |
1070 } | 1066 } |
1071 | 1067 |
1072 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { | 1068 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { |
1073 NOTREACHED(); | 1069 NOTREACHED(); |
1074 } | 1070 } |
1075 | 1071 |
1076 void LayerTreeHostImpl::DidInitializeVisibleTileForTesting() { | |
1077 // Add arbitrary damage, to trigger prepare-to-draws. | |
1078 // Here, setting damage as viewport size, used only for testing. | |
1079 SetFullRootLayerDamage(); | |
1080 DidInitializeVisibleTile(); | |
1081 } | |
1082 | |
1083 void LayerTreeHostImpl::ResetTreesForTesting() { | 1072 void LayerTreeHostImpl::ResetTreesForTesting() { |
1084 if (active_tree_) | 1073 if (active_tree_) |
1085 active_tree_->DetachLayerTree(); | 1074 active_tree_->DetachLayerTree(); |
1086 active_tree_ = LayerTreeImpl::create(this); | 1075 active_tree_ = LayerTreeImpl::create(this); |
1087 if (pending_tree_) | 1076 if (pending_tree_) |
1088 pending_tree_->DetachLayerTree(); | 1077 pending_tree_->DetachLayerTree(); |
1089 pending_tree_ = nullptr; | 1078 pending_tree_ = nullptr; |
1090 if (recycle_tree_) | 1079 if (recycle_tree_) |
1091 recycle_tree_->DetachLayerTree(); | 1080 recycle_tree_->DetachLayerTree(); |
1092 recycle_tree_ = nullptr; | 1081 recycle_tree_ = nullptr; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 DidModifyTilePriorities(); | 1153 DidModifyTilePriorities(); |
1165 } | 1154 } |
1166 | 1155 |
1167 void LayerTreeHostImpl::DidModifyTilePriorities() { | 1156 void LayerTreeHostImpl::DidModifyTilePriorities() { |
1168 DCHECK(settings_.impl_side_painting); | 1157 DCHECK(settings_.impl_side_painting); |
1169 // Mark priorities as dirty and schedule a ManageTiles(). | 1158 // Mark priorities as dirty and schedule a ManageTiles(). |
1170 tile_priorities_dirty_ = true; | 1159 tile_priorities_dirty_ = true; |
1171 client_->SetNeedsManageTilesOnImplThread(); | 1160 client_->SetNeedsManageTilesOnImplThread(); |
1172 } | 1161 } |
1173 | 1162 |
1174 void LayerTreeHostImpl::DidInitializeVisibleTile() { | |
1175 if (client_ && !client_->IsInsideDraw()) | |
1176 client_->DidInitializeVisibleTileOnImplThread(); | |
1177 } | |
1178 | |
1179 void LayerTreeHostImpl::GetPictureLayerImplPairs( | 1163 void LayerTreeHostImpl::GetPictureLayerImplPairs( |
1180 std::vector<PictureLayerImpl::Pair>* layer_pairs) const { | 1164 std::vector<PictureLayerImpl::Pair>* layer_pairs) const { |
1181 DCHECK(layer_pairs->empty()); | 1165 DCHECK(layer_pairs->empty()); |
1182 for (std::vector<PictureLayerImpl*>::const_iterator it = | 1166 for (std::vector<PictureLayerImpl*>::const_iterator it = |
1183 picture_layers_.begin(); | 1167 picture_layers_.begin(); |
1184 it != picture_layers_.end(); | 1168 it != picture_layers_.end(); |
1185 ++it) { | 1169 ++it) { |
1186 PictureLayerImpl* layer = *it; | 1170 PictureLayerImpl* layer = *it; |
1187 | 1171 |
1188 // TODO(vmpstr): Iterators and should handle this instead. crbug.com/381704 | 1172 // TODO(vmpstr): Iterators and should handle this instead. crbug.com/381704 |
(...skipping 18 matching lines...) Expand all Loading... |
1207 } | 1191 } |
1208 } | 1192 } |
1209 } | 1193 } |
1210 | 1194 |
1211 void LayerTreeHostImpl::BuildRasterQueue(RasterTilePriorityQueue* queue, | 1195 void LayerTreeHostImpl::BuildRasterQueue(RasterTilePriorityQueue* queue, |
1212 TreePriority tree_priority) { | 1196 TreePriority tree_priority) { |
1213 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); | 1197 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); |
1214 picture_layer_pairs_.clear(); | 1198 picture_layer_pairs_.clear(); |
1215 GetPictureLayerImplPairs(&picture_layer_pairs_); | 1199 GetPictureLayerImplPairs(&picture_layer_pairs_); |
1216 queue->Build(picture_layer_pairs_, tree_priority); | 1200 queue->Build(picture_layer_pairs_, tree_priority); |
| 1201 |
| 1202 if (!queue->IsEmpty()) { |
| 1203 required_for_draw_tile_is_top_of_raster_queue_ = |
| 1204 queue->Top()->required_for_draw(); |
| 1205 } else { |
| 1206 required_for_draw_tile_is_top_of_raster_queue_ = false; |
| 1207 } |
1217 } | 1208 } |
1218 | 1209 |
1219 void LayerTreeHostImpl::BuildEvictionQueue(EvictionTilePriorityQueue* queue, | 1210 void LayerTreeHostImpl::BuildEvictionQueue(EvictionTilePriorityQueue* queue, |
1220 TreePriority tree_priority) { | 1211 TreePriority tree_priority) { |
1221 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); | 1212 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); |
1222 picture_layer_pairs_.clear(); | 1213 picture_layer_pairs_.clear(); |
1223 GetPictureLayerImplPairs(&picture_layer_pairs_); | 1214 GetPictureLayerImplPairs(&picture_layer_pairs_); |
1224 queue->Build(picture_layer_pairs_, tree_priority); | 1215 queue->Build(picture_layer_pairs_, tree_priority); |
1225 } | 1216 } |
1226 | 1217 |
1227 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() | 1218 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() |
1228 const { | 1219 const { |
1229 return picture_layers_; | 1220 return picture_layers_; |
1230 } | 1221 } |
1231 | 1222 |
1232 void LayerTreeHostImpl::NotifyReadyToActivate() { | 1223 void LayerTreeHostImpl::NotifyReadyToActivate() { |
1233 client_->NotifyReadyToActivate(); | 1224 client_->NotifyReadyToActivate(); |
1234 } | 1225 } |
1235 | 1226 |
1236 void LayerTreeHostImpl::NotifyReadyToDraw() { | 1227 void LayerTreeHostImpl::NotifyReadyToDraw() { |
| 1228 // Tiles that are ready will cause NotifyTileStateChanged() to be called so we |
| 1229 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from |
| 1230 // causing optimistic requests to draw a frame. |
| 1231 required_for_draw_tile_is_top_of_raster_queue_ = false; |
| 1232 |
1237 client_->NotifyReadyToDraw(); | 1233 client_->NotifyReadyToDraw(); |
1238 } | 1234 } |
1239 | 1235 |
1240 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { | 1236 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { |
1241 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); | 1237 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); |
1242 | 1238 |
1243 if (active_tree_) { | 1239 if (active_tree_) { |
1244 LayerImpl* layer_impl = | 1240 LayerImpl* layer_impl = |
1245 active_tree_->FindActiveTreeLayerById(tile->layer_id()); | 1241 active_tree_->FindActiveTreeLayerById(tile->layer_id()); |
1246 if (layer_impl) | 1242 if (layer_impl) |
1247 layer_impl->NotifyTileStateChanged(tile); | 1243 layer_impl->NotifyTileStateChanged(tile); |
1248 } | 1244 } |
1249 | 1245 |
1250 if (pending_tree_) { | 1246 if (pending_tree_) { |
1251 LayerImpl* layer_impl = | 1247 LayerImpl* layer_impl = |
1252 pending_tree_->FindPendingTreeLayerById(tile->layer_id()); | 1248 pending_tree_->FindPendingTreeLayerById(tile->layer_id()); |
1253 if (layer_impl) | 1249 if (layer_impl) |
1254 layer_impl->NotifyTileStateChanged(tile); | 1250 layer_impl->NotifyTileStateChanged(tile); |
1255 } | 1251 } |
| 1252 |
| 1253 // Check for a non-null active tree to avoid doing this during shutdown. |
| 1254 if (active_tree_ && !client_->IsInsideDraw() && tile->required_for_draw()) { |
| 1255 // The LayerImpl::NotifyTileStateChanged() should damage the layer, so this |
| 1256 // redraw will make those tiles be displayed. |
| 1257 SetNeedsRedraw(); |
| 1258 } |
1256 } | 1259 } |
1257 | 1260 |
1258 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { | 1261 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { |
1259 SetManagedMemoryPolicy(policy, zero_budget_); | 1262 SetManagedMemoryPolicy(policy, zero_budget_); |
1260 } | 1263 } |
1261 | 1264 |
1262 void LayerTreeHostImpl::SetTreeActivationCallback( | 1265 void LayerTreeHostImpl::SetTreeActivationCallback( |
1263 const base::Closure& callback) { | 1266 const base::Closure& callback) { |
1264 DCHECK(proxy_->IsImplThread()); | 1267 DCHECK(proxy_->IsImplThread()); |
1265 DCHECK(settings_.impl_side_painting || callback.is_null()); | 1268 DCHECK(settings_.impl_side_painting || callback.is_null()); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1584 renderer_->SwapBuffers(metadata); | 1587 renderer_->SwapBuffers(metadata); |
1585 return true; | 1588 return true; |
1586 } | 1589 } |
1587 | 1590 |
1588 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1591 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
1589 // Sample the frame time now. This time will be used for updating animations | 1592 // Sample the frame time now. This time will be used for updating animations |
1590 // when we draw. | 1593 // when we draw. |
1591 UpdateCurrentBeginFrameArgs(args); | 1594 UpdateCurrentBeginFrameArgs(args); |
1592 // Cache the begin impl frame interval | 1595 // Cache the begin impl frame interval |
1593 begin_impl_frame_interval_ = args.interval; | 1596 begin_impl_frame_interval_ = args.interval; |
| 1597 |
| 1598 if (required_for_draw_tile_is_top_of_raster_queue_) { |
| 1599 // Optimistically schedule a draw, as a tile required for draw is at the top |
| 1600 // of the current raster queue. This will let us expect the tile to complete |
| 1601 // and draw it within the impl frame we are beginning now. |
| 1602 SetNeedsRedraw(); |
| 1603 } |
1594 } | 1604 } |
1595 | 1605 |
1596 void LayerTreeHostImpl::UpdateViewportContainerSizes() { | 1606 void LayerTreeHostImpl::UpdateViewportContainerSizes() { |
1597 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); | 1607 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); |
1598 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); | 1608 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); |
1599 | 1609 |
1600 if (!inner_container || !top_controls_manager_) | 1610 if (!inner_container || !top_controls_manager_) |
1601 return; | 1611 return; |
1602 | 1612 |
1603 ViewportAnchor anchor(InnerViewportScrollLayer(), | 1613 ViewportAnchor anchor(InnerViewportScrollLayer(), |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1711 pending_tree_->SetPageScaleDelta(active_tree_->page_scale_delta() / | 1721 pending_tree_->SetPageScaleDelta(active_tree_->page_scale_delta() / |
1712 active_tree_->sent_page_scale_delta()); | 1722 active_tree_->sent_page_scale_delta()); |
1713 pending_tree_->set_top_controls_delta( | 1723 pending_tree_->set_top_controls_delta( |
1714 active_tree_->top_controls_delta() - | 1724 active_tree_->top_controls_delta() - |
1715 active_tree_->sent_top_controls_delta()); | 1725 active_tree_->sent_top_controls_delta()); |
1716 | 1726 |
1717 client_->OnCanDrawStateChanged(CanDraw()); | 1727 client_->OnCanDrawStateChanged(CanDraw()); |
1718 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); | 1728 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); |
1719 } | 1729 } |
1720 | 1730 |
1721 void LayerTreeHostImpl::UpdateVisibleTiles() { | |
1722 if (tile_manager_ && tile_manager_->UpdateVisibleTiles()) | |
1723 DidInitializeVisibleTile(); | |
1724 need_to_update_visible_tiles_before_draw_ = false; | |
1725 } | |
1726 | |
1727 void LayerTreeHostImpl::ActivateSyncTree() { | 1731 void LayerTreeHostImpl::ActivateSyncTree() { |
1728 need_to_update_visible_tiles_before_draw_ = true; | |
1729 | |
1730 if (pending_tree_) { | 1732 if (pending_tree_) { |
1731 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); | 1733 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); |
1732 | 1734 |
1733 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); | 1735 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); |
1734 active_tree_->PushPersistedState(pending_tree_.get()); | 1736 active_tree_->PushPersistedState(pending_tree_.get()); |
1735 // Process any requests in the UI resource queue. The request queue is | 1737 // Process any requests in the UI resource queue. The request queue is |
1736 // given in LayerTreeHost::FinishCommitOnImplThread. This must take place | 1738 // given in LayerTreeHost::FinishCommitOnImplThread. This must take place |
1737 // before the swap. | 1739 // before the swap. |
1738 pending_tree_->ProcessUIResourceRequestQueue(); | 1740 pending_tree_->ProcessUIResourceRequestQueue(); |
1739 | 1741 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1922 IsSynchronousSingleThreaded() ? std::numeric_limits<size_t>::max() | 1924 IsSynchronousSingleThreaded() ? std::numeric_limits<size_t>::max() |
1923 : settings_.scheduled_raster_task_limit; | 1925 : settings_.scheduled_raster_task_limit; |
1924 tile_manager_ = TileManager::Create(this, | 1926 tile_manager_ = TileManager::Create(this, |
1925 task_runner, | 1927 task_runner, |
1926 resource_pool_.get(), | 1928 resource_pool_.get(), |
1927 raster_worker_pool_->AsRasterizer(), | 1929 raster_worker_pool_->AsRasterizer(), |
1928 rendering_stats_instrumentation_, | 1930 rendering_stats_instrumentation_, |
1929 scheduled_raster_task_limit); | 1931 scheduled_raster_task_limit); |
1930 | 1932 |
1931 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); | 1933 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); |
1932 need_to_update_visible_tiles_before_draw_ = false; | |
1933 } | 1934 } |
1934 | 1935 |
1935 void LayerTreeHostImpl::CreateResourceAndRasterWorkerPool( | 1936 void LayerTreeHostImpl::CreateResourceAndRasterWorkerPool( |
1936 scoped_ptr<RasterWorkerPool>* raster_worker_pool, | 1937 scoped_ptr<RasterWorkerPool>* raster_worker_pool, |
1937 scoped_ptr<ResourcePool>* resource_pool, | 1938 scoped_ptr<ResourcePool>* resource_pool, |
1938 scoped_ptr<ResourcePool>* staging_resource_pool) { | 1939 scoped_ptr<ResourcePool>* staging_resource_pool) { |
1939 base::SingleThreadTaskRunner* task_runner = | 1940 base::SingleThreadTaskRunner* task_runner = |
1940 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() | 1941 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() |
1941 : proxy_->MainThreadTaskRunner(); | 1942 : proxy_->MainThreadTaskRunner(); |
1942 DCHECK(task_runner); | 1943 DCHECK(task_runner); |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2922 ClearCurrentlyScrollingLayer(); | 2923 ClearCurrentlyScrollingLayer(); |
2923 } | 2924 } |
2924 if (top_controls_manager_) | 2925 if (top_controls_manager_) |
2925 top_controls_manager_->PinchEnd(); | 2926 top_controls_manager_->PinchEnd(); |
2926 client_->SetNeedsCommitOnImplThread(); | 2927 client_->SetNeedsCommitOnImplThread(); |
2927 // When a pinch ends, we may be displaying content cached at incorrect scales, | 2928 // When a pinch ends, we may be displaying content cached at incorrect scales, |
2928 // so updating draw properties and drawing will ensure we are using the right | 2929 // so updating draw properties and drawing will ensure we are using the right |
2929 // scales that we want when we're not inside a pinch. | 2930 // scales that we want when we're not inside a pinch. |
2930 active_tree_->set_needs_update_draw_properties(); | 2931 active_tree_->set_needs_update_draw_properties(); |
2931 SetNeedsRedraw(); | 2932 SetNeedsRedraw(); |
2932 // TODO(danakj): Don't set root damage. Just updating draw properties and | |
2933 // getting new tiles rastered should be enough! crbug.com/427423 | |
2934 SetFullRootLayerDamage(); | |
2935 } | 2933 } |
2936 | 2934 |
2937 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, | 2935 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, |
2938 LayerImpl* layer_impl) { | 2936 LayerImpl* layer_impl) { |
2939 if (!layer_impl) | 2937 if (!layer_impl) |
2940 return; | 2938 return; |
2941 | 2939 |
2942 gfx::Vector2d scroll_delta = | 2940 gfx::Vector2d scroll_delta = |
2943 gfx::ToFlooredVector2d(layer_impl->ScrollDelta()); | 2941 gfx::ToFlooredVector2d(layer_impl->ScrollDelta()); |
2944 if (!scroll_delta.IsZero()) { | 2942 if (!scroll_delta.IsZero()) { |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3415 } | 3413 } |
3416 | 3414 |
3417 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3415 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3418 std::vector<PictureLayerImpl*>::iterator it = | 3416 std::vector<PictureLayerImpl*>::iterator it = |
3419 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3417 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3420 DCHECK(it != picture_layers_.end()); | 3418 DCHECK(it != picture_layers_.end()); |
3421 picture_layers_.erase(it); | 3419 picture_layers_.erase(it); |
3422 } | 3420 } |
3423 | 3421 |
3424 } // namespace cc | 3422 } // namespace cc |
OLD | NEW |