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/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
14 #include "base/trace_event/trace_event_argument.h" | 14 #include "base/trace_event/trace_event_argument.h" |
15 #include "cc/base/math_util.h" | 15 #include "cc/base/math_util.h" |
| 16 #include "cc/resources/prioritized_tile.h" |
16 #include "cc/resources/tile.h" | 17 #include "cc/resources/tile.h" |
17 #include "cc/resources/tile_priority.h" | 18 #include "cc/resources/tile_priority.h" |
18 #include "ui/gfx/geometry/point_conversions.h" | 19 #include "ui/gfx/geometry/point_conversions.h" |
19 #include "ui/gfx/geometry/rect_conversions.h" | 20 #include "ui/gfx/geometry/rect_conversions.h" |
20 #include "ui/gfx/geometry/safe_integer_conversions.h" | 21 #include "ui/gfx/geometry/safe_integer_conversions.h" |
21 #include "ui/gfx/geometry/size_conversions.h" | 22 #include "ui/gfx/geometry/size_conversions.h" |
22 | 23 |
23 namespace cc { | 24 namespace cc { |
24 namespace { | 25 namespace { |
25 | 26 |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 | 804 |
804 bool tile_is_visible = current_visible_rect_.Intersects(tile->content_rect()); | 805 bool tile_is_visible = current_visible_rect_.Intersects(tile->content_rect()); |
805 if (!tile_is_visible) | 806 if (!tile_is_visible) |
806 return false; | 807 return false; |
807 | 808 |
808 if (IsTileOccludedOnCurrentTree(tile)) | 809 if (IsTileOccludedOnCurrentTree(tile)) |
809 return false; | 810 return false; |
810 return true; | 811 return true; |
811 } | 812 } |
812 | 813 |
813 void PictureLayerTiling::UpdateTilePriority(Tile* tile) const { | 814 void PictureLayerTiling::UpdateRequiredStatesOnTile(Tile* tile) const { |
814 tile->set_priority(ComputePriorityForTile(tile)); | 815 DCHECK(tile); |
815 tile->set_is_occluded(IsTileOccluded(tile)); | |
816 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); | 816 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); |
817 tile->set_required_for_draw(IsTileRequiredForDraw(tile)); | 817 tile->set_required_for_draw(IsTileRequiredForDraw(tile)); |
818 } | 818 } |
819 | 819 |
| 820 PrioritizedTile PictureLayerTiling::MakePrioritizedTile(Tile* tile) const { |
| 821 DCHECK(tile); |
| 822 return PrioritizedTile(tile, ComputePriorityForTile(tile), |
| 823 IsTileOccluded(tile)); |
| 824 } |
| 825 |
| 826 std::map<const Tile*, PrioritizedTile> |
| 827 PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() { |
| 828 std::map<const Tile*, PrioritizedTile> result; |
| 829 for (const auto& key_tile_pair : tiles_) { |
| 830 UpdateRequiredStatesOnTile(key_tile_pair.second); |
| 831 PrioritizedTile prioritized_tile = |
| 832 MakePrioritizedTile(key_tile_pair.second); |
| 833 result.insert(std::make_pair(prioritized_tile.tile(), prioritized_tile)); |
| 834 } |
| 835 return result; |
| 836 } |
| 837 |
820 void PictureLayerTiling::VerifyAllTilesHaveCurrentRasterSource() const { | 838 void PictureLayerTiling::VerifyAllTilesHaveCurrentRasterSource() const { |
821 #if DCHECK_IS_ON() | 839 #if DCHECK_IS_ON() |
822 for (const auto& tile_pair : tiles_) | 840 for (const auto& tile_pair : tiles_) |
823 DCHECK_EQ(raster_source_.get(), tile_pair.second->raster_source()); | 841 DCHECK_EQ(raster_source_.get(), tile_pair.second->raster_source()); |
824 #endif | 842 #endif |
825 } | 843 } |
826 | 844 |
827 TilePriority PictureLayerTiling::ComputePriorityForTile( | 845 TilePriority PictureLayerTiling::ComputePriorityForTile( |
828 const Tile* tile) const { | 846 const Tile* tile) const { |
829 // TODO(vmpstr): See if this can be moved to iterators. | 847 // TODO(vmpstr): See if this can be moved to iterators. |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 break; | 1053 break; |
1036 } | 1054 } |
1037 | 1055 |
1038 gfx::Rect result(origin_x, origin_y, width, height); | 1056 gfx::Rect result(origin_x, origin_y, width, height); |
1039 if (cache) | 1057 if (cache) |
1040 cache->previous_result = result; | 1058 cache->previous_result = result; |
1041 return result; | 1059 return result; |
1042 } | 1060 } |
1043 | 1061 |
1044 } // namespace cc | 1062 } // namespace cc |
OLD | NEW |