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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
802 | 803 |
803 bool tile_is_visible = current_visible_rect_.Intersects(tile->content_rect()); | 804 bool tile_is_visible = current_visible_rect_.Intersects(tile->content_rect()); |
804 if (!tile_is_visible) | 805 if (!tile_is_visible) |
805 return false; | 806 return false; |
806 | 807 |
807 if (IsTileOccludedOnCurrentTree(tile)) | 808 if (IsTileOccludedOnCurrentTree(tile)) |
808 return false; | 809 return false; |
809 return true; | 810 return true; |
810 } | 811 } |
811 | 812 |
812 void PictureLayerTiling::UpdateTilePriority(Tile* tile) const { | 813 void PictureLayerTiling::UpdateTilePriority( |
vmpstr
2015/05/08 18:11:06
If you do go the route of GetPrioritizedTile(tile)
hendrikw
2015/05/08 19:21:02
messier, dangerous, but I like to live dangerously
| |
813 tile->set_priority(ComputePriorityForTile(tile)); | 814 PrioritizedTile* prioritized_tile) const { |
814 tile->set_is_occluded(IsTileOccluded(tile)); | 815 Tile* tile = prioritized_tile->tile(); |
816 prioritized_tile->set_priority(ComputePriorityForTile(tile)); | |
817 prioritized_tile->set_is_occluded(IsTileOccluded(tile)); | |
815 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); | 818 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); |
816 tile->set_required_for_draw(IsTileRequiredForDraw(tile)); | 819 tile->set_required_for_draw(IsTileRequiredForDraw(tile)); |
817 } | 820 } |
818 | 821 |
822 std::map<const Tile*, PrioritizedTile> | |
823 PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() { | |
824 std::map<const Tile*, PrioritizedTile> result; | |
825 for (auto& key_tile_pair : tiles_) { | |
vmpstr
2015/05/08 18:11:06
const auto&?
hendrikw
2015/05/08 19:21:02
Done.
| |
826 PrioritizedTile prioritized_tile; | |
827 prioritized_tile.UpdateTile(key_tile_pair.second.get(), this); | |
828 result.insert(std::make_pair(prioritized_tile.tile(), prioritized_tile)); | |
829 } | |
830 return result; | |
831 } | |
832 | |
819 void PictureLayerTiling::VerifyAllTilesHaveCurrentRasterSource() const { | 833 void PictureLayerTiling::VerifyAllTilesHaveCurrentRasterSource() const { |
820 #if DCHECK_IS_ON() | 834 #if DCHECK_IS_ON() |
821 for (const auto& tile_pair : tiles_) | 835 for (const auto& tile_pair : tiles_) |
822 DCHECK_EQ(raster_source_.get(), tile_pair.second->raster_source()); | 836 DCHECK_EQ(raster_source_.get(), tile_pair.second->raster_source()); |
823 #endif | 837 #endif |
824 } | 838 } |
825 | 839 |
826 TilePriority PictureLayerTiling::ComputePriorityForTile( | 840 TilePriority PictureLayerTiling::ComputePriorityForTile( |
827 const Tile* tile) const { | 841 const Tile* tile) const { |
828 // TODO(vmpstr): See if this can be moved to iterators. | 842 // TODO(vmpstr): See if this can be moved to iterators. |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1034 break; | 1048 break; |
1035 } | 1049 } |
1036 | 1050 |
1037 gfx::Rect result(origin_x, origin_y, width, height); | 1051 gfx::Rect result(origin_x, origin_y, width, height); |
1038 if (cache) | 1052 if (cache) |
1039 cache->previous_result = result; | 1053 cache->previous_result = result; |
1040 return result; | 1054 return result; |
1041 } | 1055 } |
1042 | 1056 |
1043 } // namespace cc | 1057 } // namespace cc |
OLD | NEW |