| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/fake_picture_layer_impl.h" | 5 #include "cc/test/fake_picture_layer_impl.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 #include "cc/resources/tile.h" | 8 #include "cc/resources/tile.h" |
| 9 #include "cc/trees/layer_tree_impl.h" | 9 #include "cc/trees/layer_tree_impl.h" |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 return result; | 70 return result; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void FakePictureLayerImpl::SetAllTilesVisible() { | 73 void FakePictureLayerImpl::SetAllTilesVisible() { |
| 74 WhichTree tree = | 74 WhichTree tree = |
| 75 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 75 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
| 76 | 76 |
| 77 for (size_t tiling_idx = 0; tiling_idx < tilings_->num_tilings(); | 77 for (size_t tiling_idx = 0; tiling_idx < tilings_->num_tilings(); |
| 78 ++tiling_idx) { | 78 ++tiling_idx) { |
| 79 PictureLayerTiling* tiling = tilings_->tiling_at(tiling_idx); | 79 PictureLayerTiling* tiling = tilings_->tiling_at(tiling_idx); |
| 80 std::vector<TileBundle*> bundles = tiling->AllTileBundlesForTesting(); | 80 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 81 for (size_t bundle_idx = 0; bundle_idx < bundles.size(); ++bundle_idx) { | 81 for (size_t tile_idx = 0; tile_idx < tiles.size(); ++tile_idx) { |
| 82 TileBundle* bundle = bundles[bundle_idx]; | 82 Tile* tile = tiles[tile_idx]; |
| 83 TilePriority priority; | 83 TilePriority priority; |
| 84 priority.resolution = HIGH_RESOLUTION; | 84 priority.resolution = HIGH_RESOLUTION; |
| 85 priority.time_to_visible_in_seconds = 0.f; | 85 priority.time_to_visible_in_seconds = 0.f; |
| 86 priority.distance_to_visible_in_pixels = 0.f; | 86 priority.distance_to_visible_in_pixels = 0.f; |
| 87 bundle->SetPriority(tree, priority); | 87 tile->SetPriority(tree, priority); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 void FakePictureLayerImpl::SetAllTilesReady() { | 92 void FakePictureLayerImpl::SetAllTilesReady() { |
| 93 for (size_t tiling_idx = 0; tiling_idx < tilings_->num_tilings(); | 93 for (size_t tiling_idx = 0; tiling_idx < tilings_->num_tilings(); |
| 94 ++tiling_idx) { | 94 ++tiling_idx) { |
| 95 PictureLayerTiling* tiling = tilings_->tiling_at(tiling_idx); | 95 PictureLayerTiling* tiling = tilings_->tiling_at(tiling_idx); |
| 96 SetAllTilesReadyInTiling(tiling); | 96 SetAllTilesReadyInTiling(tiling); |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 void FakePictureLayerImpl::SetAllTilesReadyInTiling( | 100 void FakePictureLayerImpl::SetAllTilesReadyInTiling( |
| 101 PictureLayerTiling* tiling) { | 101 PictureLayerTiling* tiling) { |
| 102 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 102 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 103 for (size_t tile_idx = 0; tile_idx < tiles.size(); ++tile_idx) { | 103 for (size_t tile_idx = 0; tile_idx < tiles.size(); ++tile_idx) { |
| 104 Tile* tile = tiles[tile_idx]; | 104 Tile* tile = tiles[tile_idx]; |
| 105 ManagedTileState& state = tile->managed_state(); | 105 ManagedTileState& state = tile->managed_state(); |
| 106 for (size_t mode_idx = 0; mode_idx < NUM_RASTER_MODES; ++mode_idx) | 106 for (size_t mode_idx = 0; mode_idx < NUM_RASTER_MODES; ++mode_idx) |
| 107 state.tile_versions[mode_idx].SetSolidColorForTesting(true); | 107 state.tile_versions[mode_idx].SetSolidColorForTesting(true); |
| 108 DCHECK(tile->IsReadyToDraw()); | 108 DCHECK(tile->IsReadyToDraw()); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 void FakePictureLayerImpl::CreateDefaultTilingsAndTiles(WhichTree tree) { | 112 void FakePictureLayerImpl::CreateDefaultTilingsAndTiles() { |
| 113 layer_tree_impl()->UpdateDrawProperties(); | 113 layer_tree_impl()->UpdateDrawProperties(); |
| 114 | 114 |
| 115 if (CanHaveTilings()) { | 115 if (CanHaveTilings()) { |
| 116 DCHECK_EQ(tilings()->num_tilings(), 2u); | 116 DCHECK_EQ(tilings()->num_tilings(), 2u); |
| 117 DCHECK_EQ(tilings()->tiling_at(0)->resolution(), HIGH_RESOLUTION); | 117 DCHECK_EQ(tilings()->tiling_at(0)->resolution(), HIGH_RESOLUTION); |
| 118 DCHECK_EQ(tilings()->tiling_at(1)->resolution(), LOW_RESOLUTION); | 118 DCHECK_EQ(tilings()->tiling_at(1)->resolution(), LOW_RESOLUTION); |
| 119 if (tree == ACTIVE_TREE) { | 119 HighResTiling()->CreateAllTilesForTesting(); |
| 120 DCHECK(layer_tree_impl()->IsActiveTree()); | 120 LowResTiling()->CreateAllTilesForTesting(); |
| 121 HighResTiling()->CreateTilesForTesting(ACTIVE_TREE); | |
| 122 LowResTiling()->CreateTilesForTesting(ACTIVE_TREE); | |
| 123 } else { | |
| 124 DCHECK(layer_tree_impl()->IsPendingTree()); | |
| 125 HighResTiling()->CreateTilesForTesting(PENDING_TREE); | |
| 126 LowResTiling()->CreateTilesForTesting(PENDING_TREE); | |
| 127 } | |
| 128 } else { | 121 } else { |
| 129 DCHECK_EQ(tilings()->num_tilings(), 0u); | 122 DCHECK_EQ(tilings()->num_tilings(), 0u); |
| 130 } | 123 } |
| 131 } | 124 } |
| 132 | 125 |
| 133 } // namespace cc | 126 } // namespace cc |
| OLD | NEW |