Chromium Code Reviews| 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 DCHECK(tile); |
| 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 } | 817 } |
| 818 | 818 |
| 819 PrioritizedTile PictureLayerTiling::MakePrioritizedTile(Tile* tile) const { | |
| 820 DCHECK(tile); | |
| 821 return PrioritizedTile(tile, ComputePriorityForTile(tile), | |
| 822 IsTileOccluded(tile)); | |
| 823 } | |
| 824 | |
| 825 std::map<const Tile*, PrioritizedTile> | |
| 826 PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() { | |
| 827 std::map<const Tile*, PrioritizedTile> result; | |
| 828 for (const auto& key_tile_pair : tiles_) { | |
| 829 UpdateRequiredStatesOnTile(key_tile_pair.second.get()); | |
| 830 PrioritizedTile prioritized_tile = | |
| 831 MakePrioritizedTile(key_tile_pair.second.get()); | |
| 832 result.insert(std::make_pair(prioritized_tile.tile(), prioritized_tile)); | |
|
vmpstr
2015/05/11 23:44:28
This doesn't really matter in test, but this incur
| |
| 833 } | |
| 834 return result; | |
| 835 } | |
| 836 | |
| 819 void PictureLayerTiling::VerifyAllTilesHaveCurrentRasterSource() const { | 837 void PictureLayerTiling::VerifyAllTilesHaveCurrentRasterSource() const { |
| 820 #if DCHECK_IS_ON() | 838 #if DCHECK_IS_ON() |
| 821 for (const auto& tile_pair : tiles_) | 839 for (const auto& tile_pair : tiles_) |
| 822 DCHECK_EQ(raster_source_.get(), tile_pair.second->raster_source()); | 840 DCHECK_EQ(raster_source_.get(), tile_pair.second->raster_source()); |
| 823 #endif | 841 #endif |
| 824 } | 842 } |
| 825 | 843 |
| 826 TilePriority PictureLayerTiling::ComputePriorityForTile( | 844 TilePriority PictureLayerTiling::ComputePriorityForTile( |
| 827 const Tile* tile) const { | 845 const Tile* tile) const { |
| 828 // TODO(vmpstr): See if this can be moved to iterators. | 846 // 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; | 1052 break; |
| 1035 } | 1053 } |
| 1036 | 1054 |
| 1037 gfx::Rect result(origin_x, origin_y, width, height); | 1055 gfx::Rect result(origin_x, origin_y, width, height); |
| 1038 if (cache) | 1056 if (cache) |
| 1039 cache->previous_result = result; | 1057 cache->previous_result = result; |
| 1040 return result; | 1058 return result; |
| 1041 } | 1059 } |
| 1042 | 1060 |
| 1043 } // namespace cc | 1061 } // namespace cc |
| OLD | NEW |