| 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 |
| 11 namespace cc { | 11 namespace cc { |
| 12 | 12 |
| 13 FakePictureLayerImpl::FakePictureLayerImpl( | 13 FakePictureLayerImpl::FakePictureLayerImpl( |
| 14 LayerTreeImpl* tree_impl, | 14 LayerTreeImpl* tree_impl, |
| 15 int id, | 15 int id, |
| 16 scoped_refptr<RasterSource> raster_source) | 16 scoped_refptr<RasterSource> raster_source, |
| 17 : PictureLayerImpl(tree_impl, id), | 17 bool is_mask) |
| 18 : PictureLayerImpl(tree_impl, id, is_mask), |
| 18 append_quads_count_(0), | 19 append_quads_count_(0), |
| 19 did_become_active_call_count_(0), | 20 did_become_active_call_count_(0), |
| 20 has_valid_tile_priorities_(false), | 21 has_valid_tile_priorities_(false), |
| 21 use_set_valid_tile_priorities_flag_(false), | 22 use_set_valid_tile_priorities_flag_(false), |
| 22 release_resources_count_(0) { | 23 release_resources_count_(0) { |
| 23 raster_source_ = raster_source; | 24 SetBounds(raster_source->GetSize()); |
| 24 SetBounds(raster_source_->GetSize()); | 25 SetContentBounds(raster_source->GetSize()); |
| 25 SetContentBounds(raster_source_->GetSize()); | 26 SetRasterSourceOnPending(raster_source, Region()); |
| 26 } | 27 } |
| 27 | 28 |
| 28 FakePictureLayerImpl::FakePictureLayerImpl( | 29 FakePictureLayerImpl::FakePictureLayerImpl( |
| 29 LayerTreeImpl* tree_impl, | 30 LayerTreeImpl* tree_impl, |
| 30 int id, | 31 int id, |
| 31 scoped_refptr<RasterSource> raster_source, | 32 scoped_refptr<RasterSource> raster_source, |
| 33 bool is_mask, |
| 32 const gfx::Size& layer_bounds) | 34 const gfx::Size& layer_bounds) |
| 33 : PictureLayerImpl(tree_impl, id), | 35 : PictureLayerImpl(tree_impl, id, is_mask), |
| 34 append_quads_count_(0), | 36 append_quads_count_(0), |
| 35 did_become_active_call_count_(0), | 37 did_become_active_call_count_(0), |
| 36 has_valid_tile_priorities_(false), | 38 has_valid_tile_priorities_(false), |
| 37 use_set_valid_tile_priorities_flag_(false), | 39 use_set_valid_tile_priorities_flag_(false), |
| 38 release_resources_count_(0) { | 40 release_resources_count_(0) { |
| 39 raster_source_ = raster_source; | |
| 40 SetBounds(layer_bounds); | 41 SetBounds(layer_bounds); |
| 41 SetContentBounds(layer_bounds); | 42 SetContentBounds(layer_bounds); |
| 43 SetRasterSourceOnPending(raster_source, Region()); |
| 42 } | 44 } |
| 43 | 45 |
| 44 FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl, int id) | 46 FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl, |
| 45 : PictureLayerImpl(tree_impl, id), | 47 int id, |
| 48 bool is_mask) |
| 49 : PictureLayerImpl(tree_impl, id, is_mask), |
| 46 append_quads_count_(0), | 50 append_quads_count_(0), |
| 47 did_become_active_call_count_(0), | 51 did_become_active_call_count_(0), |
| 48 has_valid_tile_priorities_(false), | 52 has_valid_tile_priorities_(false), |
| 49 use_set_valid_tile_priorities_flag_(false), | 53 use_set_valid_tile_priorities_flag_(false), |
| 50 release_resources_count_(0) { | 54 release_resources_count_(0) { |
| 51 } | 55 } |
| 52 | 56 |
| 53 scoped_ptr<LayerImpl> FakePictureLayerImpl::CreateLayerImpl( | 57 scoped_ptr<LayerImpl> FakePictureLayerImpl::CreateLayerImpl( |
| 54 LayerTreeImpl* tree_impl) { | 58 LayerTreeImpl* tree_impl) { |
| 55 return make_scoped_ptr(new FakePictureLayerImpl(tree_impl, id())); | 59 return make_scoped_ptr(new FakePictureLayerImpl(tree_impl, id(), is_mask_)); |
| 60 } |
| 61 |
| 62 void FakePictureLayerImpl::PushPropertiesTo(LayerImpl* layer_impl) { |
| 63 FakePictureLayerImpl* picture_layer_impl = |
| 64 static_cast<FakePictureLayerImpl*>(layer_impl); |
| 65 picture_layer_impl->fixed_tile_size_ = fixed_tile_size_; |
| 66 PictureLayerImpl::PushPropertiesTo(layer_impl); |
| 56 } | 67 } |
| 57 | 68 |
| 58 void FakePictureLayerImpl::AppendQuads( | 69 void FakePictureLayerImpl::AppendQuads( |
| 59 RenderPass* render_pass, | 70 RenderPass* render_pass, |
| 60 const Occlusion& occlusion_in_content_space, | 71 const Occlusion& occlusion_in_content_space, |
| 61 AppendQuadsData* append_quads_data) { | 72 AppendQuadsData* append_quads_data) { |
| 62 PictureLayerImpl::AppendQuads( | 73 PictureLayerImpl::AppendQuads( |
| 63 render_pass, occlusion_in_content_space, append_quads_data); | 74 render_pass, occlusion_in_content_space, append_quads_data); |
| 64 ++append_quads_count_; | 75 ++append_quads_count_; |
| 65 } | 76 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 92 PictureLayerTiling* tiling = tilings_->tiling_at(i); | 103 PictureLayerTiling* tiling = tilings_->tiling_at(i); |
| 93 if (tiling->resolution() == LOW_RESOLUTION) { | 104 if (tiling->resolution() == LOW_RESOLUTION) { |
| 94 // There should be only one low res tiling. | 105 // There should be only one low res tiling. |
| 95 CHECK(!result); | 106 CHECK(!result); |
| 96 result = tiling; | 107 result = tiling; |
| 97 } | 108 } |
| 98 } | 109 } |
| 99 return result; | 110 return result; |
| 100 } | 111 } |
| 101 | 112 |
| 102 void FakePictureLayerImpl::SetRasterSource( | 113 void FakePictureLayerImpl::SetRasterSourceOnPending( |
| 103 scoped_refptr<RasterSource> raster_source) { | 114 scoped_refptr<RasterSource> raster_source, |
| 104 raster_source_.swap(raster_source); | 115 const Region& invalidation) { |
| 105 if (tilings()) { | 116 DCHECK(layer_tree_impl()->IsPendingTree()); |
| 106 for (size_t i = 0; i < num_tilings(); ++i) { | 117 Region invalidation_temp = invalidation; |
| 107 tilings()->tiling_at(i)->UpdateTilesToCurrentRasterSource( | 118 const PictureLayerTilingSet* pending_set = nullptr; |
| 108 raster_source_.get(), Region(), raster_source_->GetSize()); | 119 UpdateRasterSource(raster_source, &invalidation_temp, pending_set); |
| 109 } | |
| 110 } | |
| 111 } | 120 } |
| 112 | 121 |
| 113 void FakePictureLayerImpl::SetAllTilesVisible() { | 122 void FakePictureLayerImpl::SetAllTilesVisible() { |
| 114 WhichTree tree = | 123 WhichTree tree = |
| 115 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 124 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
| 116 | 125 |
| 117 for (size_t tiling_idx = 0; tiling_idx < tilings_->num_tilings(); | 126 for (size_t tiling_idx = 0; tiling_idx < tilings_->num_tilings(); |
| 118 ++tiling_idx) { | 127 ++tiling_idx) { |
| 119 PictureLayerTiling* tiling = tilings_->tiling_at(tiling_idx); | 128 PictureLayerTiling* tiling = tilings_->tiling_at(tiling_idx); |
| 120 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 129 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 return CountTilesRequired( | 260 return CountTilesRequired( |
| 252 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); | 261 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); |
| 253 } | 262 } |
| 254 | 263 |
| 255 void FakePictureLayerImpl::ReleaseResources() { | 264 void FakePictureLayerImpl::ReleaseResources() { |
| 256 PictureLayerImpl::ReleaseResources(); | 265 PictureLayerImpl::ReleaseResources(); |
| 257 ++release_resources_count_; | 266 ++release_resources_count_; |
| 258 } | 267 } |
| 259 | 268 |
| 260 } // namespace cc | 269 } // namespace cc |
| OLD | NEW |