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