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::UpdateRequiredStatesOnTile(Tile* tile) const { |
813 tile->set_priority(ComputePriorityForTile(tile)); | 814 if (tile) { |
vmpstr
2015/05/11 16:44:44
This should be a dcheck and checked by the caller
hendrikw
2015/05/11 17:38:30
Done.
| |
814 tile->set_is_occluded(IsTileOccluded(tile)); | 815 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); |
815 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); | 816 tile->set_required_for_draw(IsTileRequiredForDraw(tile)); |
816 tile->set_required_for_draw(IsTileRequiredForDraw(tile)); | 817 } |
818 } | |
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.get()); | |
831 PrioritizedTile prioritized_tile = | |
832 MakePrioritizedTile(key_tile_pair.second.get()); | |
833 result.insert(std::make_pair(prioritized_tile.tile(), prioritized_tile)); | |
834 } | |
835 return result; | |
817 } | 836 } |
818 | 837 |
819 void PictureLayerTiling::VerifyAllTilesHaveCurrentRasterSource() const { | 838 void PictureLayerTiling::VerifyAllTilesHaveCurrentRasterSource() const { |
820 #if DCHECK_IS_ON() | 839 #if DCHECK_IS_ON() |
821 for (const auto& tile_pair : tiles_) | 840 for (const auto& tile_pair : tiles_) |
822 DCHECK_EQ(raster_source_.get(), tile_pair.second->raster_source()); | 841 DCHECK_EQ(raster_source_.get(), tile_pair.second->raster_source()); |
823 #endif | 842 #endif |
824 } | 843 } |
825 | 844 |
826 TilePriority PictureLayerTiling::ComputePriorityForTile( | 845 TilePriority PictureLayerTiling::ComputePriorityForTile( |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1034 break; | 1053 break; |
1035 } | 1054 } |
1036 | 1055 |
1037 gfx::Rect result(origin_x, origin_y, width, height); | 1056 gfx::Rect result(origin_x, origin_y, width, height); |
1038 if (cache) | 1057 if (cache) |
1039 cache->previous_result = result; | 1058 cache->previous_result = result; |
1040 return result; | 1059 return result; |
1041 } | 1060 } |
1042 | 1061 |
1043 } // namespace cc | 1062 } // namespace cc |
OLD | NEW |