Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: cc/test/fake_picture_layer_impl.cc

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/test/fake_picture_layer_impl.h ('k') | cc/test/fake_picture_layer_tiling_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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(LayerTreeImpl* tree_impl, 13 FakePictureLayerImpl::FakePictureLayerImpl(
14 int id, 14 LayerTreeImpl* tree_impl,
15 scoped_refptr<PicturePileImpl> pile) 15 int id,
16 scoped_refptr<RasterSource> raster_source)
16 : PictureLayerImpl(tree_impl, id), 17 : PictureLayerImpl(tree_impl, id),
17 append_quads_count_(0), 18 append_quads_count_(0),
18 did_become_active_call_count_(0), 19 did_become_active_call_count_(0),
19 has_valid_tile_priorities_(false), 20 has_valid_tile_priorities_(false),
20 use_set_valid_tile_priorities_flag_(false), 21 use_set_valid_tile_priorities_flag_(false),
21 release_resources_count_(0) { 22 release_resources_count_(0) {
22 pile_ = pile; 23 raster_source_ = raster_source;
23 SetBounds(pile_->tiling_size()); 24 SetBounds(raster_source_->GetSize());
24 SetContentBounds(pile_->tiling_size()); 25 SetContentBounds(raster_source_->GetSize());
25 } 26 }
26 27
27 FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl, 28 FakePictureLayerImpl::FakePictureLayerImpl(
28 int id, 29 LayerTreeImpl* tree_impl,
29 scoped_refptr<PicturePileImpl> pile, 30 int id,
30 const gfx::Size& layer_bounds) 31 scoped_refptr<RasterSource> raster_source,
32 const gfx::Size& layer_bounds)
31 : PictureLayerImpl(tree_impl, id), 33 : PictureLayerImpl(tree_impl, id),
32 append_quads_count_(0), 34 append_quads_count_(0),
33 did_become_active_call_count_(0), 35 did_become_active_call_count_(0),
34 has_valid_tile_priorities_(false), 36 has_valid_tile_priorities_(false),
35 use_set_valid_tile_priorities_flag_(false), 37 use_set_valid_tile_priorities_flag_(false),
36 release_resources_count_(0) { 38 release_resources_count_(0) {
37 pile_ = pile; 39 raster_source_ = raster_source;
38 SetBounds(layer_bounds); 40 SetBounds(layer_bounds);
39 SetContentBounds(layer_bounds); 41 SetContentBounds(layer_bounds);
40 } 42 }
41 43
42 FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl, int id) 44 FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl, int id)
43 : PictureLayerImpl(tree_impl, id), 45 : PictureLayerImpl(tree_impl, id),
44 append_quads_count_(0), 46 append_quads_count_(0),
45 did_become_active_call_count_(0), 47 did_become_active_call_count_(0),
46 has_valid_tile_priorities_(false), 48 has_valid_tile_priorities_(false),
47 use_set_valid_tile_priorities_flag_(false), 49 use_set_valid_tile_priorities_flag_(false),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 PictureLayerTiling* tiling = tilings_->tiling_at(i); 92 PictureLayerTiling* tiling = tilings_->tiling_at(i);
91 if (tiling->resolution() == LOW_RESOLUTION) { 93 if (tiling->resolution() == LOW_RESOLUTION) {
92 // There should be only one low res tiling. 94 // There should be only one low res tiling.
93 CHECK(!result); 95 CHECK(!result);
94 result = tiling; 96 result = tiling;
95 } 97 }
96 } 98 }
97 return result; 99 return result;
98 } 100 }
99 101
100 void FakePictureLayerImpl::SetPile(scoped_refptr<PicturePileImpl> pile) { 102 void FakePictureLayerImpl::SetRasterSource(
101 pile_.swap(pile); 103 scoped_refptr<RasterSource> raster_source) {
104 raster_source_.swap(raster_source);
102 if (tilings()) { 105 if (tilings()) {
103 for (size_t i = 0; i < num_tilings(); ++i) { 106 for (size_t i = 0; i < num_tilings(); ++i) {
104 tilings()->tiling_at(i)->UpdateTilesToCurrentPile(Region(), 107 tilings()->tiling_at(i)->UpdateTilesToCurrentRasterSource(
105 pile_->tiling_size()); 108 Region(), raster_source_->GetSize());
106 } 109 }
107 } 110 }
108 } 111 }
109 112
110 void FakePictureLayerImpl::SetAllTilesVisible() { 113 void FakePictureLayerImpl::SetAllTilesVisible() {
111 WhichTree tree = 114 WhichTree tree =
112 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; 115 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE;
113 116
114 for (size_t tiling_idx = 0; tiling_idx < tilings_->num_tilings(); 117 for (size_t tiling_idx = 0; tiling_idx < tilings_->num_tilings();
115 ++tiling_idx) { 118 ++tiling_idx) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 PictureLayerImpl::DidBecomeActive(); 186 PictureLayerImpl::DidBecomeActive();
184 ++did_become_active_call_count_; 187 ++did_become_active_call_count_;
185 } 188 }
186 189
187 bool FakePictureLayerImpl::HasValidTilePriorities() const { 190 bool FakePictureLayerImpl::HasValidTilePriorities() const {
188 return use_set_valid_tile_priorities_flag_ 191 return use_set_valid_tile_priorities_flag_
189 ? has_valid_tile_priorities_ 192 ? has_valid_tile_priorities_
190 : PictureLayerImpl::HasValidTilePriorities(); 193 : PictureLayerImpl::HasValidTilePriorities();
191 } 194 }
192 195
196 size_t FakePictureLayerImpl::CountTilesRequired(
197 TileRequirementCheck is_tile_required_callback) const {
198 if (!HasValidTilePriorities())
199 return 0;
200
201 if (!tilings_)
202 return 0;
203
204 if (visible_rect_for_tile_priority_.IsEmpty())
205 return 0;
206
207 gfx::Rect rect = GetViewportForTilePriorityInContentSpace();
208 rect.Intersect(visible_rect_for_tile_priority_);
209
210 size_t count = 0;
211
212 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
213 PictureLayerTiling* tiling = tilings_->tiling_at(i);
214 if (tiling->resolution() != HIGH_RESOLUTION &&
215 tiling->resolution() != LOW_RESOLUTION)
216 continue;
217
218 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, rect); iter;
219 ++iter) {
220 const Tile* tile = *iter;
221 // A null tile (i.e. missing recording) can just be skipped.
222 // TODO(vmpstr): Verify this is true if we create tiles in raster
223 // iterators.
224 if (!tile)
225 continue;
226
227 // We can't check tile->required_for_activation, because that value might
228 // be out of date. It is updated in the raster/eviction iterators.
229 // TODO(vmpstr): Remove the comment once you can't access this information
230 // from the tile.
231 if ((tiling->*is_tile_required_callback)(tile))
232 ++count;
233 }
234 }
235
236 return count;
237 }
238
239 size_t FakePictureLayerImpl::CountTilesRequiredForActivation() const {
240 if (!layer_tree_impl()->IsPendingTree())
241 return 0;
242
243 return CountTilesRequired(
244 &PictureLayerTiling::IsTileRequiredForActivationIfVisible);
245 }
246
247 size_t FakePictureLayerImpl::CountTilesRequiredForDraw() const {
248 if (!layer_tree_impl()->IsActiveTree())
249 return 0;
250
251 return CountTilesRequired(
252 &PictureLayerTiling::IsTileRequiredForDrawIfVisible);
253 }
254
193 void FakePictureLayerImpl::ReleaseResources() { 255 void FakePictureLayerImpl::ReleaseResources() {
194 PictureLayerImpl::ReleaseResources(); 256 PictureLayerImpl::ReleaseResources();
195 ++release_resources_count_; 257 ++release_resources_count_;
196 } 258 }
197 259
198 } // namespace cc 260 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_picture_layer_impl.h ('k') | cc/test/fake_picture_layer_tiling_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698