| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 return GL_TEXTURE_2D; | 167 return GL_TEXTURE_2D; |
| 168 } | 168 } |
| 169 | 169 |
| 170 size_t GetMaxStagingResourceCount() { | 170 size_t GetMaxStagingResourceCount() { |
| 171 // Upper bound for number of staging resource to allow. | 171 // Upper bound for number of staging resource to allow. |
| 172 return 32; | 172 return 32; |
| 173 } | 173 } |
| 174 | 174 |
| 175 } // namespace | 175 } // namespace |
| 176 | 176 |
| 177 LayerTreeHostImpl::FrameData::FrameData() | 177 LayerTreeHostImpl::FrameData::FrameData() : has_no_damage(false) { |
| 178 : contains_incomplete_tile(false), has_no_damage(false) {} | 178 } |
| 179 | 179 |
| 180 LayerTreeHostImpl::FrameData::~FrameData() {} | 180 LayerTreeHostImpl::FrameData::~FrameData() {} |
| 181 | 181 |
| 182 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::Create( | 182 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::Create( |
| 183 const LayerTreeSettings& settings, | 183 const LayerTreeSettings& settings, |
| 184 LayerTreeHostImplClient* client, | 184 LayerTreeHostImplClient* client, |
| 185 Proxy* proxy, | 185 Proxy* proxy, |
| 186 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 186 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 187 SharedBitmapManager* shared_bitmap_manager, | 187 SharedBitmapManager* shared_bitmap_manager, |
| 188 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 188 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 : proxy_->MainThreadTaskRunner())), | 232 : proxy_->MainThreadTaskRunner())), |
| 233 max_memory_needed_bytes_(0), | 233 max_memory_needed_bytes_(0), |
| 234 zero_budget_(false), | 234 zero_budget_(false), |
| 235 device_scale_factor_(1.f), | 235 device_scale_factor_(1.f), |
| 236 overhang_ui_resource_id_(0), | 236 overhang_ui_resource_id_(0), |
| 237 resourceless_software_draw_(false), | 237 resourceless_software_draw_(false), |
| 238 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), | 238 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), |
| 239 animation_registrar_(AnimationRegistrar::Create()), | 239 animation_registrar_(AnimationRegistrar::Create()), |
| 240 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 240 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
| 241 micro_benchmark_controller_(this), | 241 micro_benchmark_controller_(this), |
| 242 need_to_update_visible_tiles_before_draw_(false), | |
| 243 shared_bitmap_manager_(shared_bitmap_manager), | 242 shared_bitmap_manager_(shared_bitmap_manager), |
| 244 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 243 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
| 245 id_(id), | 244 id_(id), |
| 246 requires_high_res_to_draw_(false) { | 245 requires_high_res_to_draw_(false), |
| 246 required_for_draw_tile_is_top_of_raster_queue_(false) { |
| 247 DCHECK(proxy_->IsImplThread()); | 247 DCHECK(proxy_->IsImplThread()); |
| 248 DidVisibilityChange(this, visible_); | 248 DidVisibilityChange(this, visible_); |
| 249 animation_registrar_->set_supports_scroll_animations( | 249 animation_registrar_->set_supports_scroll_animations( |
| 250 proxy_->SupportsImplScrolling()); | 250 proxy_->SupportsImplScrolling()); |
| 251 | 251 |
| 252 SetDebugState(settings.initial_debug_state); | 252 SetDebugState(settings.initial_debug_state); |
| 253 | 253 |
| 254 // LTHI always has an active tree. | 254 // LTHI always has an active tree. |
| 255 active_tree_ = LayerTreeImpl::create(this); | 255 active_tree_ = LayerTreeImpl::create(this); |
| 256 TRACE_EVENT_OBJECT_CREATED_WITH_ID( | 256 TRACE_EVENT_OBJECT_CREATED_WITH_ID( |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 render_surface_layer->id(), | 482 render_surface_layer->id(), |
| 483 render_surface->SurfacePropertyChangedOnlyFromDescendant(), | 483 render_surface->SurfacePropertyChangedOnlyFromDescendant(), |
| 484 render_surface->content_rect(), | 484 render_surface->content_rect(), |
| 485 render_surface_layer->mask_layer(), | 485 render_surface_layer->mask_layer(), |
| 486 render_surface_layer->filters()); | 486 render_surface_layer->filters()); |
| 487 } | 487 } |
| 488 } | 488 } |
| 489 | 489 |
| 490 void LayerTreeHostImpl::FrameData::AsValueInto( | 490 void LayerTreeHostImpl::FrameData::AsValueInto( |
| 491 base::debug::TracedValue* value) const { | 491 base::debug::TracedValue* value) const { |
| 492 value->SetBoolean("contains_incomplete_tile", contains_incomplete_tile); | |
| 493 value->SetBoolean("has_no_damage", has_no_damage); | 492 value->SetBoolean("has_no_damage", has_no_damage); |
| 494 | 493 |
| 495 // Quad data can be quite large, so only dump render passes if we select | 494 // Quad data can be quite large, so only dump render passes if we select |
| 496 // cc.debug.quads. | 495 // cc.debug.quads. |
| 497 bool quads_enabled; | 496 bool quads_enabled; |
| 498 TRACE_EVENT_CATEGORY_GROUP_ENABLED( | 497 TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
| 499 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); | 498 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); |
| 500 if (quads_enabled) { | 499 if (quads_enabled) { |
| 501 value->BeginArray("render_passes"); | 500 value->BeginArray("render_passes"); |
| 502 for (size_t i = 0; i < render_passes.size(); ++i) { | 501 for (size_t i = 0; i < render_passes.size(); ++i) { |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 if (append_quads_data.num_missing_tiles) { | 831 if (append_quads_data.num_missing_tiles) { |
| 833 bool layer_has_animating_transform = | 832 bool layer_has_animating_transform = |
| 834 it->screen_space_transform_is_animating() || | 833 it->screen_space_transform_is_animating() || |
| 835 it->draw_transform_is_animating(); | 834 it->draw_transform_is_animating(); |
| 836 if (layer_has_animating_transform) | 835 if (layer_has_animating_transform) |
| 837 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; | 836 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; |
| 838 } | 837 } |
| 839 | 838 |
| 840 if (append_quads_data.num_incomplete_tiles || | 839 if (append_quads_data.num_incomplete_tiles || |
| 841 append_quads_data.num_missing_tiles) { | 840 append_quads_data.num_missing_tiles) { |
| 842 frame->contains_incomplete_tile = true; | |
| 843 if (RequiresHighResToDraw()) | 841 if (RequiresHighResToDraw()) |
| 844 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT; | 842 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT; |
| 845 } | 843 } |
| 846 | 844 |
| 847 occlusion_tracker.LeaveLayer(it); | 845 occlusion_tracker.LeaveLayer(it); |
| 848 } | 846 } |
| 849 | 847 |
| 850 if (have_copy_request || | 848 if (have_copy_request || |
| 851 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) | 849 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) |
| 852 draw_result = DRAW_SUCCESS; | 850 draw_result = DRAW_SUCCESS; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 DCHECK_GE(frame->render_passes.size(), position_from_end); | 1025 DCHECK_GE(frame->render_passes.size(), position_from_end); |
| 1028 } | 1026 } |
| 1029 } | 1027 } |
| 1030 } | 1028 } |
| 1031 | 1029 |
| 1032 DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { | 1030 DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { |
| 1033 TRACE_EVENT1("cc", | 1031 TRACE_EVENT1("cc", |
| 1034 "LayerTreeHostImpl::PrepareToDraw", | 1032 "LayerTreeHostImpl::PrepareToDraw", |
| 1035 "SourceFrameNumber", | 1033 "SourceFrameNumber", |
| 1036 active_tree_->source_frame_number()); | 1034 active_tree_->source_frame_number()); |
| 1037 | 1035 // This will cause NotifyTileStateChanged() to be called for any visible tiles |
| 1038 if (need_to_update_visible_tiles_before_draw_ && | 1036 // that completed, which will add damage to the frame for them so they appear |
| 1039 tile_manager_ && tile_manager_->UpdateVisibleTiles()) { | 1037 // as part of the current frame being drawn. |
| 1040 DidInitializeVisibleTile(); | 1038 if (settings().impl_side_painting) |
| 1041 } | 1039 tile_manager_->UpdateVisibleTiles(); |
| 1042 need_to_update_visible_tiles_before_draw_ = true; | |
| 1043 | 1040 |
| 1044 UMA_HISTOGRAM_CUSTOM_COUNTS( | 1041 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 1045 "Compositing.NumActiveLayers", active_tree_->NumLayers(), 1, 400, 20); | 1042 "Compositing.NumActiveLayers", active_tree_->NumLayers(), 1, 400, 20); |
| 1046 | 1043 |
| 1047 bool ok = active_tree_->UpdateDrawProperties(); | 1044 bool ok = active_tree_->UpdateDrawProperties(); |
| 1048 DCHECK(ok) << "UpdateDrawProperties failed during draw"; | 1045 DCHECK(ok) << "UpdateDrawProperties failed during draw"; |
| 1049 | 1046 |
| 1050 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); | 1047 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); |
| 1051 frame->render_passes.clear(); | 1048 frame->render_passes.clear(); |
| 1052 frame->render_passes_by_id.clear(); | 1049 frame->render_passes_by_id.clear(); |
| 1053 frame->will_draw_layers.clear(); | 1050 frame->will_draw_layers.clear(); |
| 1054 frame->contains_incomplete_tile = false; | |
| 1055 frame->has_no_damage = false; | 1051 frame->has_no_damage = false; |
| 1056 | 1052 |
| 1057 if (active_tree_->root_layer()) { | 1053 if (active_tree_->root_layer()) { |
| 1058 gfx::Rect device_viewport_damage_rect = viewport_damage_rect_; | 1054 gfx::Rect device_viewport_damage_rect = viewport_damage_rect_; |
| 1059 viewport_damage_rect_ = gfx::Rect(); | 1055 viewport_damage_rect_ = gfx::Rect(); |
| 1060 | 1056 |
| 1061 active_tree_->root_layer()->render_surface()->damage_tracker()-> | 1057 active_tree_->root_layer()->render_surface()->damage_tracker()-> |
| 1062 AddDamageNextUpdate(device_viewport_damage_rect); | 1058 AddDamageNextUpdate(device_viewport_damage_rect); |
| 1063 } | 1059 } |
| 1064 | 1060 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1075 } | 1071 } |
| 1076 | 1072 |
| 1077 void LayerTreeHostImpl::EvictTexturesForTesting() { | 1073 void LayerTreeHostImpl::EvictTexturesForTesting() { |
| 1078 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0)); | 1074 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0)); |
| 1079 } | 1075 } |
| 1080 | 1076 |
| 1081 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { | 1077 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { |
| 1082 NOTREACHED(); | 1078 NOTREACHED(); |
| 1083 } | 1079 } |
| 1084 | 1080 |
| 1085 void LayerTreeHostImpl::DidInitializeVisibleTileForTesting() { | |
| 1086 // Add arbitrary damage, to trigger prepare-to-draws. | |
| 1087 // Here, setting damage as viewport size, used only for testing. | |
| 1088 SetFullRootLayerDamage(); | |
| 1089 DidInitializeVisibleTile(); | |
| 1090 } | |
| 1091 | |
| 1092 void LayerTreeHostImpl::ResetTreesForTesting() { | 1081 void LayerTreeHostImpl::ResetTreesForTesting() { |
| 1093 if (active_tree_) | 1082 if (active_tree_) |
| 1094 active_tree_->DetachLayerTree(); | 1083 active_tree_->DetachLayerTree(); |
| 1095 active_tree_ = LayerTreeImpl::create(this); | 1084 active_tree_ = LayerTreeImpl::create(this); |
| 1096 if (pending_tree_) | 1085 if (pending_tree_) |
| 1097 pending_tree_->DetachLayerTree(); | 1086 pending_tree_->DetachLayerTree(); |
| 1098 pending_tree_ = nullptr; | 1087 pending_tree_ = nullptr; |
| 1099 if (recycle_tree_) | 1088 if (recycle_tree_) |
| 1100 recycle_tree_->DetachLayerTree(); | 1089 recycle_tree_->DetachLayerTree(); |
| 1101 recycle_tree_ = nullptr; | 1090 recycle_tree_ = nullptr; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 DidModifyTilePriorities(); | 1162 DidModifyTilePriorities(); |
| 1174 } | 1163 } |
| 1175 | 1164 |
| 1176 void LayerTreeHostImpl::DidModifyTilePriorities() { | 1165 void LayerTreeHostImpl::DidModifyTilePriorities() { |
| 1177 DCHECK(settings_.impl_side_painting); | 1166 DCHECK(settings_.impl_side_painting); |
| 1178 // Mark priorities as dirty and schedule a ManageTiles(). | 1167 // Mark priorities as dirty and schedule a ManageTiles(). |
| 1179 tile_priorities_dirty_ = true; | 1168 tile_priorities_dirty_ = true; |
| 1180 client_->SetNeedsManageTilesOnImplThread(); | 1169 client_->SetNeedsManageTilesOnImplThread(); |
| 1181 } | 1170 } |
| 1182 | 1171 |
| 1183 void LayerTreeHostImpl::DidInitializeVisibleTile() { | |
| 1184 if (client_ && !client_->IsInsideDraw()) | |
| 1185 client_->DidInitializeVisibleTileOnImplThread(); | |
| 1186 } | |
| 1187 | |
| 1188 void LayerTreeHostImpl::GetPictureLayerImplPairs( | 1172 void LayerTreeHostImpl::GetPictureLayerImplPairs( |
| 1189 std::vector<PictureLayerImpl::Pair>* layer_pairs, | 1173 std::vector<PictureLayerImpl::Pair>* layer_pairs, |
| 1190 bool need_valid_tile_priorities) const { | 1174 bool need_valid_tile_priorities) const { |
| 1191 DCHECK(layer_pairs->empty()); | 1175 DCHECK(layer_pairs->empty()); |
| 1192 for (std::vector<PictureLayerImpl*>::const_iterator it = | 1176 for (std::vector<PictureLayerImpl*>::const_iterator it = |
| 1193 picture_layers_.begin(); | 1177 picture_layers_.begin(); |
| 1194 it != picture_layers_.end(); | 1178 it != picture_layers_.end(); |
| 1195 ++it) { | 1179 ++it) { |
| 1196 PictureLayerImpl* layer = *it; | 1180 PictureLayerImpl* layer = *it; |
| 1197 | 1181 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1218 } | 1202 } |
| 1219 } | 1203 } |
| 1220 } | 1204 } |
| 1221 | 1205 |
| 1222 void LayerTreeHostImpl::BuildRasterQueue(RasterTilePriorityQueue* queue, | 1206 void LayerTreeHostImpl::BuildRasterQueue(RasterTilePriorityQueue* queue, |
| 1223 TreePriority tree_priority) { | 1207 TreePriority tree_priority) { |
| 1224 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); | 1208 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); |
| 1225 picture_layer_pairs_.clear(); | 1209 picture_layer_pairs_.clear(); |
| 1226 GetPictureLayerImplPairs(&picture_layer_pairs_, true); | 1210 GetPictureLayerImplPairs(&picture_layer_pairs_, true); |
| 1227 queue->Build(picture_layer_pairs_, tree_priority); | 1211 queue->Build(picture_layer_pairs_, tree_priority); |
| 1212 |
| 1213 if (!queue->IsEmpty()) { |
| 1214 // Only checking the Top() tile here isn't a definite answer that there is |
| 1215 // or isn't something required for draw in this raster queue. It's just a |
| 1216 // heuristic to let us hit the common case and proactively tell the |
| 1217 // scheduler that we expect to draw within each vsync until we get all the |
| 1218 // tiles ready to draw. If we happen to miss a required for draw tile here, |
| 1219 // then we will miss telling the scheduler each frame that we intend to draw |
| 1220 // so it may make worse scheduling decisions. |
| 1221 required_for_draw_tile_is_top_of_raster_queue_ = |
| 1222 queue->Top()->required_for_draw(); |
| 1223 } else { |
| 1224 required_for_draw_tile_is_top_of_raster_queue_ = false; |
| 1225 } |
| 1228 } | 1226 } |
| 1229 | 1227 |
| 1230 void LayerTreeHostImpl::BuildEvictionQueue(EvictionTilePriorityQueue* queue, | 1228 void LayerTreeHostImpl::BuildEvictionQueue(EvictionTilePriorityQueue* queue, |
| 1231 TreePriority tree_priority) { | 1229 TreePriority tree_priority) { |
| 1232 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); | 1230 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); |
| 1233 picture_layer_pairs_.clear(); | 1231 picture_layer_pairs_.clear(); |
| 1234 GetPictureLayerImplPairs(&picture_layer_pairs_, false); | 1232 GetPictureLayerImplPairs(&picture_layer_pairs_, false); |
| 1235 queue->Build(picture_layer_pairs_, tree_priority); | 1233 queue->Build(picture_layer_pairs_, tree_priority); |
| 1236 } | 1234 } |
| 1237 | 1235 |
| 1238 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() | 1236 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() |
| 1239 const { | 1237 const { |
| 1240 return picture_layers_; | 1238 return picture_layers_; |
| 1241 } | 1239 } |
| 1242 | 1240 |
| 1243 void LayerTreeHostImpl::NotifyReadyToActivate() { | 1241 void LayerTreeHostImpl::NotifyReadyToActivate() { |
| 1244 client_->NotifyReadyToActivate(); | 1242 client_->NotifyReadyToActivate(); |
| 1245 } | 1243 } |
| 1246 | 1244 |
| 1247 void LayerTreeHostImpl::NotifyReadyToDraw() { | 1245 void LayerTreeHostImpl::NotifyReadyToDraw() { |
| 1246 // 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 |
| 1248 // causing optimistic requests to draw a frame. |
| 1249 required_for_draw_tile_is_top_of_raster_queue_ = false; |
| 1250 |
| 1248 client_->NotifyReadyToDraw(); | 1251 client_->NotifyReadyToDraw(); |
| 1249 } | 1252 } |
| 1250 | 1253 |
| 1251 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { | 1254 void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { |
| 1252 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); | 1255 TRACE_EVENT0("cc", "LayerTreeHostImpl::NotifyTileStateChanged"); |
| 1253 | 1256 |
| 1254 if (active_tree_) { | 1257 if (active_tree_) { |
| 1255 LayerImpl* layer_impl = | 1258 LayerImpl* layer_impl = |
| 1256 active_tree_->FindActiveTreeLayerById(tile->layer_id()); | 1259 active_tree_->FindActiveTreeLayerById(tile->layer_id()); |
| 1257 if (layer_impl) | 1260 if (layer_impl) |
| 1258 layer_impl->NotifyTileStateChanged(tile); | 1261 layer_impl->NotifyTileStateChanged(tile); |
| 1259 } | 1262 } |
| 1260 | 1263 |
| 1261 if (pending_tree_) { | 1264 if (pending_tree_) { |
| 1262 LayerImpl* layer_impl = | 1265 LayerImpl* layer_impl = |
| 1263 pending_tree_->FindPendingTreeLayerById(tile->layer_id()); | 1266 pending_tree_->FindPendingTreeLayerById(tile->layer_id()); |
| 1264 if (layer_impl) | 1267 if (layer_impl) |
| 1265 layer_impl->NotifyTileStateChanged(tile); | 1268 layer_impl->NotifyTileStateChanged(tile); |
| 1266 } | 1269 } |
| 1270 |
| 1271 // Check for a non-null active tree to avoid doing this during shutdown. |
| 1272 if (active_tree_ && !client_->IsInsideDraw() && tile->required_for_draw()) { |
| 1273 // The LayerImpl::NotifyTileStateChanged() should damage the layer, so this |
| 1274 // redraw will make those tiles be displayed. |
| 1275 SetNeedsRedraw(); |
| 1276 } |
| 1267 } | 1277 } |
| 1268 | 1278 |
| 1269 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { | 1279 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { |
| 1270 SetManagedMemoryPolicy(policy, zero_budget_); | 1280 SetManagedMemoryPolicy(policy, zero_budget_); |
| 1271 } | 1281 } |
| 1272 | 1282 |
| 1273 void LayerTreeHostImpl::SetTreeActivationCallback( | 1283 void LayerTreeHostImpl::SetTreeActivationCallback( |
| 1274 const base::Closure& callback) { | 1284 const base::Closure& callback) { |
| 1275 DCHECK(proxy_->IsImplThread()); | 1285 DCHECK(proxy_->IsImplThread()); |
| 1276 DCHECK(settings_.impl_side_painting || callback.is_null()); | 1286 DCHECK(settings_.impl_side_painting || callback.is_null()); |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1595 renderer_->SwapBuffers(metadata); | 1605 renderer_->SwapBuffers(metadata); |
| 1596 return true; | 1606 return true; |
| 1597 } | 1607 } |
| 1598 | 1608 |
| 1599 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1609 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
| 1600 // Sample the frame time now. This time will be used for updating animations | 1610 // Sample the frame time now. This time will be used for updating animations |
| 1601 // when we draw. | 1611 // when we draw. |
| 1602 UpdateCurrentBeginFrameArgs(args); | 1612 UpdateCurrentBeginFrameArgs(args); |
| 1603 // Cache the begin impl frame interval | 1613 // Cache the begin impl frame interval |
| 1604 begin_impl_frame_interval_ = args.interval; | 1614 begin_impl_frame_interval_ = args.interval; |
| 1615 |
| 1616 if (required_for_draw_tile_is_top_of_raster_queue_) { |
| 1617 // Optimistically schedule a draw, as a tile required for draw is at the top |
| 1618 // of the current raster queue. This will let us expect the tile to complete |
| 1619 // and draw it within the impl frame we are beginning now. |
| 1620 SetNeedsRedraw(); |
| 1621 } |
| 1605 } | 1622 } |
| 1606 | 1623 |
| 1607 void LayerTreeHostImpl::UpdateViewportContainerSizes() { | 1624 void LayerTreeHostImpl::UpdateViewportContainerSizes() { |
| 1608 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); | 1625 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); |
| 1609 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); | 1626 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); |
| 1610 | 1627 |
| 1611 if (!inner_container || !top_controls_manager_) | 1628 if (!inner_container || !top_controls_manager_) |
| 1612 return; | 1629 return; |
| 1613 | 1630 |
| 1614 ViewportAnchor anchor(InnerViewportScrollLayer(), | 1631 ViewportAnchor anchor(InnerViewportScrollLayer(), |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1722 pending_tree_->SetPageScaleDelta(active_tree_->page_scale_delta() / | 1739 pending_tree_->SetPageScaleDelta(active_tree_->page_scale_delta() / |
| 1723 active_tree_->sent_page_scale_delta()); | 1740 active_tree_->sent_page_scale_delta()); |
| 1724 pending_tree_->set_top_controls_delta( | 1741 pending_tree_->set_top_controls_delta( |
| 1725 active_tree_->top_controls_delta() - | 1742 active_tree_->top_controls_delta() - |
| 1726 active_tree_->sent_top_controls_delta()); | 1743 active_tree_->sent_top_controls_delta()); |
| 1727 | 1744 |
| 1728 client_->OnCanDrawStateChanged(CanDraw()); | 1745 client_->OnCanDrawStateChanged(CanDraw()); |
| 1729 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); | 1746 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); |
| 1730 } | 1747 } |
| 1731 | 1748 |
| 1732 void LayerTreeHostImpl::UpdateVisibleTiles() { | |
| 1733 if (tile_manager_ && tile_manager_->UpdateVisibleTiles()) | |
| 1734 DidInitializeVisibleTile(); | |
| 1735 need_to_update_visible_tiles_before_draw_ = false; | |
| 1736 } | |
| 1737 | |
| 1738 void LayerTreeHostImpl::ActivateSyncTree() { | 1749 void LayerTreeHostImpl::ActivateSyncTree() { |
| 1739 need_to_update_visible_tiles_before_draw_ = true; | |
| 1740 | |
| 1741 if (pending_tree_) { | 1750 if (pending_tree_) { |
| 1742 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); | 1751 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); |
| 1743 | 1752 |
| 1744 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); | 1753 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); |
| 1745 active_tree_->PushPersistedState(pending_tree_.get()); | 1754 active_tree_->PushPersistedState(pending_tree_.get()); |
| 1746 // Process any requests in the UI resource queue. The request queue is | 1755 // Process any requests in the UI resource queue. The request queue is |
| 1747 // given in LayerTreeHost::FinishCommitOnImplThread. This must take place | 1756 // given in LayerTreeHost::FinishCommitOnImplThread. This must take place |
| 1748 // before the swap. | 1757 // before the swap. |
| 1749 pending_tree_->ProcessUIResourceRequestQueue(); | 1758 pending_tree_->ProcessUIResourceRequestQueue(); |
| 1750 | 1759 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1933 IsSynchronousSingleThreaded() ? std::numeric_limits<size_t>::max() | 1942 IsSynchronousSingleThreaded() ? std::numeric_limits<size_t>::max() |
| 1934 : settings_.scheduled_raster_task_limit; | 1943 : settings_.scheduled_raster_task_limit; |
| 1935 tile_manager_ = TileManager::Create(this, | 1944 tile_manager_ = TileManager::Create(this, |
| 1936 task_runner, | 1945 task_runner, |
| 1937 resource_pool_.get(), | 1946 resource_pool_.get(), |
| 1938 raster_worker_pool_->AsRasterizer(), | 1947 raster_worker_pool_->AsRasterizer(), |
| 1939 rendering_stats_instrumentation_, | 1948 rendering_stats_instrumentation_, |
| 1940 scheduled_raster_task_limit); | 1949 scheduled_raster_task_limit); |
| 1941 | 1950 |
| 1942 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); | 1951 UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); |
| 1943 need_to_update_visible_tiles_before_draw_ = false; | |
| 1944 } | 1952 } |
| 1945 | 1953 |
| 1946 void LayerTreeHostImpl::CreateResourceAndRasterWorkerPool( | 1954 void LayerTreeHostImpl::CreateResourceAndRasterWorkerPool( |
| 1947 scoped_ptr<RasterWorkerPool>* raster_worker_pool, | 1955 scoped_ptr<RasterWorkerPool>* raster_worker_pool, |
| 1948 scoped_ptr<ResourcePool>* resource_pool, | 1956 scoped_ptr<ResourcePool>* resource_pool, |
| 1949 scoped_ptr<ResourcePool>* staging_resource_pool) { | 1957 scoped_ptr<ResourcePool>* staging_resource_pool) { |
| 1950 base::SingleThreadTaskRunner* task_runner = | 1958 base::SingleThreadTaskRunner* task_runner = |
| 1951 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() | 1959 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() |
| 1952 : proxy_->MainThreadTaskRunner(); | 1960 : proxy_->MainThreadTaskRunner(); |
| 1953 DCHECK(task_runner); | 1961 DCHECK(task_runner); |
| (...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2933 ClearCurrentlyScrollingLayer(); | 2941 ClearCurrentlyScrollingLayer(); |
| 2934 } | 2942 } |
| 2935 if (top_controls_manager_) | 2943 if (top_controls_manager_) |
| 2936 top_controls_manager_->PinchEnd(); | 2944 top_controls_manager_->PinchEnd(); |
| 2937 client_->SetNeedsCommitOnImplThread(); | 2945 client_->SetNeedsCommitOnImplThread(); |
| 2938 // When a pinch ends, we may be displaying content cached at incorrect scales, | 2946 // When a pinch ends, we may be displaying content cached at incorrect scales, |
| 2939 // so updating draw properties and drawing will ensure we are using the right | 2947 // so updating draw properties and drawing will ensure we are using the right |
| 2940 // scales that we want when we're not inside a pinch. | 2948 // scales that we want when we're not inside a pinch. |
| 2941 active_tree_->set_needs_update_draw_properties(); | 2949 active_tree_->set_needs_update_draw_properties(); |
| 2942 SetNeedsRedraw(); | 2950 SetNeedsRedraw(); |
| 2943 // TODO(danakj): Don't set root damage. Just updating draw properties and | |
| 2944 // getting new tiles rastered should be enough! crbug.com/427423 | |
| 2945 SetFullRootLayerDamage(); | |
| 2946 } | 2951 } |
| 2947 | 2952 |
| 2948 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, | 2953 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, |
| 2949 LayerImpl* layer_impl) { | 2954 LayerImpl* layer_impl) { |
| 2950 if (!layer_impl) | 2955 if (!layer_impl) |
| 2951 return; | 2956 return; |
| 2952 | 2957 |
| 2953 gfx::Vector2d scroll_delta = | 2958 gfx::Vector2d scroll_delta = |
| 2954 gfx::ToFlooredVector2d(layer_impl->ScrollDelta()); | 2959 gfx::ToFlooredVector2d(layer_impl->ScrollDelta()); |
| 2955 if (!scroll_delta.IsZero()) { | 2960 if (!scroll_delta.IsZero()) { |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3426 } | 3431 } |
| 3427 | 3432 |
| 3428 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3433 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3429 std::vector<PictureLayerImpl*>::iterator it = | 3434 std::vector<PictureLayerImpl*>::iterator it = |
| 3430 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3435 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3431 DCHECK(it != picture_layers_.end()); | 3436 DCHECK(it != picture_layers_.end()); |
| 3432 picture_layers_.erase(it); | 3437 picture_layers_.erase(it); |
| 3433 } | 3438 } |
| 3434 | 3439 |
| 3435 } // namespace cc | 3440 } // namespace cc |
| OLD | NEW |