OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/tiles/tile_manager.h" | 5 #include "cc/tiles/tile_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 // We don't reserve memory for required-for-activation tiles during | 890 // We don't reserve memory for required-for-activation tiles during |
891 // accelerated gestures, so we just postpone activation when we don't | 891 // accelerated gestures, so we just postpone activation when we don't |
892 // have these tiles, and activate after the accelerated gesture. | 892 // have these tiles, and activate after the accelerated gesture. |
893 // Likewise if we don't allow any tiles (as is the case when we're | 893 // Likewise if we don't allow any tiles (as is the case when we're |
894 // invisible), if we have tiles that aren't ready, then we shouldn't | 894 // invisible), if we have tiles that aren't ready, then we shouldn't |
895 // activate as activation can cause checkerboards. | 895 // activate as activation can cause checkerboards. |
896 bool wait_for_all_required_tiles = | 896 bool wait_for_all_required_tiles = |
897 global_state_.tree_priority == SMOOTHNESS_TAKES_PRIORITY || | 897 global_state_.tree_priority == SMOOTHNESS_TAKES_PRIORITY || |
898 global_state_.memory_limit_policy == ALLOW_NOTHING; | 898 global_state_.memory_limit_policy == ALLOW_NOTHING; |
899 | 899 |
900 // Mark any required-for-activation tiles that have not been been assigned | 900 // If we have tiles left to raster for activation, and we don't allow |
901 // memory after reaching a steady memory state as OOM. This ensures that we | 901 // activating without them, then skip activation and return early. |
902 // activate even when OOM. Note that we can't reuse the queue we used for | 902 if (wait_for_all_required_tiles) |
| 903 return; |
| 904 |
| 905 // Mark any required tiles that have not been been assigned memory after |
| 906 // reaching a steady memory state as OOM. This ensures that we activate/draw |
| 907 // even when OOM. Note that we can't reuse the queue we used for |
903 // AssignGpuMemoryToTiles, since the AssignGpuMemoryToTiles call could have | 908 // AssignGpuMemoryToTiles, since the AssignGpuMemoryToTiles call could have |
904 // evicted some tiles that would not be picked up by the old raster queue. | 909 // evicted some tiles that would not be picked up by the old raster queue. |
905 scoped_ptr<RasterTilePriorityQueue> required_for_activation_queue( | 910 bool need_to_signal_activate = MarkTilesOutOfMemory(client_->BuildRasterQueue( |
906 client_->BuildRasterQueue( | 911 global_state_.tree_priority, |
907 global_state_.tree_priority, | 912 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); |
908 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | 913 bool need_to_signal_draw = MarkTilesOutOfMemory(client_->BuildRasterQueue( |
| 914 global_state_.tree_priority, |
| 915 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); |
909 | 916 |
910 // If we have tiles left to raster for activation, and we don't allow | 917 DCHECK(IsReadyToActivate()); |
911 // activating without them, then skip activation and return early. | 918 DCHECK(IsReadyToDraw()); |
912 if (!required_for_activation_queue->IsEmpty() && wait_for_all_required_tiles) | 919 signals_.ready_to_activate = need_to_signal_activate; |
913 return; | 920 signals_.ready_to_draw = need_to_signal_draw; |
| 921 // TODO(ericrk): Investigate why we need to schedule this (not just call it |
| 922 // inline). http://crbug.com/498439 |
| 923 signals_check_notifier_.Schedule(); |
| 924 } |
914 | 925 |
915 // Mark required tiles as OOM so that we can activate without them. | 926 bool TileManager::MarkTilesOutOfMemory( |
916 for (; !required_for_activation_queue->IsEmpty(); | 927 scoped_ptr<RasterTilePriorityQueue> queue) const { |
917 required_for_activation_queue->Pop()) { | 928 // Mark required tiles as OOM so that we can activate/draw without them. |
918 Tile* tile = required_for_activation_queue->Top().tile(); | 929 if (queue->IsEmpty()) |
| 930 return false; |
| 931 |
| 932 for (; !queue->IsEmpty(); queue->Pop()) { |
| 933 Tile* tile = queue->Top().tile(); |
919 tile->draw_info().set_oom(); | 934 tile->draw_info().set_oom(); |
920 client_->NotifyTileStateChanged(tile); | 935 client_->NotifyTileStateChanged(tile); |
921 } | 936 } |
922 | 937 return true; |
923 DCHECK(IsReadyToActivate()); | |
924 // TODO(ericrk): Investigate why we need to schedule this (not just call it | |
925 // inline). http://crbug.com/498439 | |
926 signals_.ready_to_activate = true; | |
927 signals_check_notifier_.Schedule(); | |
928 } | 938 } |
929 | 939 |
930 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const { | 940 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const { |
931 return tile_task_runner_->GetResourceFormat(!tile->is_opaque()); | 941 return tile_task_runner_->GetResourceFormat(!tile->is_opaque()); |
932 } | 942 } |
933 | 943 |
934 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { | 944 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { |
935 return tile_task_runner_->GetResourceRequiresSwizzle(!tile->is_opaque()); | 945 return tile_task_runner_->GetResourceRequiresSwizzle(!tile->is_opaque()); |
936 } | 946 } |
937 | 947 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 void TileManager::Signals::reset() { | 1015 void TileManager::Signals::reset() { |
1006 ready_to_activate = false; | 1016 ready_to_activate = false; |
1007 did_notify_ready_to_activate = false; | 1017 did_notify_ready_to_activate = false; |
1008 ready_to_draw = false; | 1018 ready_to_draw = false; |
1009 did_notify_ready_to_draw = false; | 1019 did_notify_ready_to_draw = false; |
1010 all_tile_tasks_completed = false; | 1020 all_tile_tasks_completed = false; |
1011 did_notify_all_tile_tasks_completed = false; | 1021 did_notify_all_tile_tasks_completed = false; |
1012 } | 1022 } |
1013 | 1023 |
1014 } // namespace cc | 1024 } // namespace cc |
OLD | NEW |