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

Side by Side Diff: cc/tiles/picture_layer_tiling_set.cc

Issue 2566613002: [4/5] Add translated rasterization support for PictureLayerTilingSet & below (Closed)
Patch Set: Created 4 years 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
OLDNEW
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/tiles/picture_layer_tiling_set.h" 5 #include "cc/tiles/picture_layer_tiling_set.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <set> 10 #include <set>
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 if (pending_twin_set->tilings_.empty()) { 76 if (pending_twin_set->tilings_.empty()) {
77 // If the twin (pending) tiling set is empty, it was not updated for the 77 // If the twin (pending) tiling set is empty, it was not updated for the
78 // current frame. So we drop tilings from our set as well, instead of 78 // current frame. So we drop tilings from our set as well, instead of
79 // leaving behind unshared tilings that are all non-ideal. 79 // leaving behind unshared tilings that are all non-ideal.
80 RemoveAllTilings(); 80 RemoveAllTilings();
81 return; 81 return;
82 } 82 }
83 83
84 bool tiling_sort_required = false; 84 bool tiling_sort_required = false;
85 for (const auto& pending_twin_tiling : pending_twin_set->tilings_) { 85 for (const auto& pending_twin_tiling : pending_twin_set->tilings_) {
86 ScaleTranslate2d raster_transform = pending_twin_tiling->raster_transform();
86 PictureLayerTiling* this_tiling = 87 PictureLayerTiling* this_tiling =
87 FindTilingWithScaleKey(pending_twin_tiling->contents_scale_key()); 88 FindTilingWithScaleKey(pending_twin_tiling->contents_scale_key());
89 if (this_tiling && this_tiling->raster_transform() != raster_transform) {
enne (OOO) 2017/01/03 22:53:53 This could use some unit testing too.
trchen 2017/03/28 21:44:01 Done.
90 Remove(this_tiling);
91 this_tiling = nullptr;
92 }
88 if (!this_tiling) { 93 if (!this_tiling) {
89 std::unique_ptr<PictureLayerTiling> new_tiling(new PictureLayerTiling( 94 std::unique_ptr<PictureLayerTiling> new_tiling(new PictureLayerTiling(
90 tree_, pending_twin_tiling->raster_scales(), raster_source_, client_, 95 tree_, raster_transform, raster_source_, client_,
91 kMaxSoonBorderDistanceInScreenPixels, max_preraster_distance_)); 96 kMaxSoonBorderDistanceInScreenPixels, max_preraster_distance_));
92 tilings_.push_back(std::move(new_tiling)); 97 tilings_.push_back(std::move(new_tiling));
93 this_tiling = tilings_.back().get(); 98 this_tiling = tilings_.back().get();
94 tiling_sort_required = true; 99 tiling_sort_required = true;
95 state_since_last_tile_priority_update_.added_tilings = true; 100 state_since_last_tile_priority_update_.added_tilings = true;
96 } 101 }
97 this_tiling->TakeTilesAndPropertiesFrom(pending_twin_tiling.get(), 102 this_tiling->TakeTilesAndPropertiesFrom(pending_twin_tiling.get(),
98 layer_invalidation); 103 layer_invalidation);
99 } 104 }
100 105
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 }); 268 });
264 tilings_.erase(to_remove, tilings_.end()); 269 tilings_.erase(to_remove, tilings_.end());
265 } 270 }
266 271
267 void PictureLayerTilingSet::MarkAllTilingsNonIdeal() { 272 void PictureLayerTilingSet::MarkAllTilingsNonIdeal() {
268 for (const auto& tiling : tilings_) 273 for (const auto& tiling : tilings_)
269 tiling->set_resolution(NON_IDEAL_RESOLUTION); 274 tiling->set_resolution(NON_IDEAL_RESOLUTION);
270 } 275 }
271 276
272 PictureLayerTiling* PictureLayerTilingSet::AddTiling( 277 PictureLayerTiling* PictureLayerTilingSet::AddTiling(
273 float contents_scale_key, 278 const ScaleTranslate2d& raster_transform,
274 scoped_refptr<RasterSource> raster_source) { 279 scoped_refptr<RasterSource> raster_source) {
275 if (!raster_source_) 280 if (!raster_source_)
276 raster_source_ = raster_source; 281 raster_source_ = raster_source;
277 282
278 #if DCHECK_IS_ON() 283 #if DCHECK_IS_ON()
279 for (size_t i = 0; i < tilings_.size(); ++i) { 284 for (size_t i = 0; i < tilings_.size(); ++i) {
280 DCHECK_NE(tilings_[i]->contents_scale_key(), contents_scale_key); 285 DCHECK_NE(tilings_[i]->contents_scale_key(), raster_transform.scale());
281 DCHECK_EQ(tilings_[i]->raster_source(), raster_source.get()); 286 DCHECK_EQ(tilings_[i]->raster_source(), raster_source.get());
282 } 287 }
283 #endif // DCHECK_IS_ON() 288 #endif // DCHECK_IS_ON()
284 289
285 gfx::SizeF raster_scales(contents_scale_key,
286 contents_scale_key / aspect_ratio_);
287 tilings_.push_back(base::MakeUnique<PictureLayerTiling>( 290 tilings_.push_back(base::MakeUnique<PictureLayerTiling>(
288 tree_, raster_scales, raster_source, client_, 291 tree_, raster_transform, raster_source, client_,
289 kMaxSoonBorderDistanceInScreenPixels, max_preraster_distance_)); 292 kMaxSoonBorderDistanceInScreenPixels, max_preraster_distance_));
290 PictureLayerTiling* appended = tilings_.back().get(); 293 PictureLayerTiling* appended = tilings_.back().get();
291 state_since_last_tile_priority_update_.added_tilings = true; 294 state_since_last_tile_priority_update_.added_tilings = true;
292 295
293 std::sort(tilings_.begin(), tilings_.end(), LargestToSmallestScaleFunctor()); 296 std::sort(tilings_.begin(), tilings_.end(), LargestToSmallestScaleFunctor());
294 return appended; 297 return appended;
295 } 298 }
296 299
297 int PictureLayerTilingSet::NumHighResTilings() const { 300 int PictureLayerTilingSet::NumHighResTilings() const {
298 return std::count_if(tilings_.begin(), tilings_.end(), 301 return std::count_if(tilings_.begin(), tilings_.end(),
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 snapped_ratio = ratio; 379 snapped_ratio = ratio;
377 } 380 }
378 } 381 }
379 return snapped_contents_scale; 382 return snapped_contents_scale;
380 } 383 }
381 384
382 float PictureLayerTilingSet::GetMaximumContentsScale() const { 385 float PictureLayerTilingSet::GetMaximumContentsScale() const {
383 if (tilings_.empty()) 386 if (tilings_.empty())
384 return 0.f; 387 return 0.f;
385 // The first tiling has the largest contents scale. 388 // The first tiling has the largest contents scale.
386 return std::max(tilings_[0]->raster_scales().width(), 389 return tilings_[0]->raster_transform().scale();
387 tilings_[0]->raster_scales().height());
388 } 390 }
389 391
390 bool PictureLayerTilingSet::TilingsNeedUpdate( 392 bool PictureLayerTilingSet::TilingsNeedUpdate(
391 const gfx::Rect& visible_rect_in_layer_space, 393 const gfx::Rect& visible_rect_in_layer_space,
392 double current_frame_time_in_seconds) { 394 double current_frame_time_in_seconds) {
393 // If we don't have any tilings, we don't need an update. 395 // If we don't have any tilings, we don't need an update.
394 if (num_tilings() == 0) 396 if (num_tilings() == 0)
395 return false; 397 return false;
396 398
397 // If we never updated the tiling set, then our history is empty. We should 399 // If we never updated the tiling set, then our history is empty. We should
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 case LOWER_THAN_LOW_RES: 785 case LOWER_THAN_LOW_RES:
784 range = TilingRange(low_res_range.end, tilings_size); 786 range = TilingRange(low_res_range.end, tilings_size);
785 break; 787 break;
786 } 788 }
787 789
788 DCHECK_LE(range.start, range.end); 790 DCHECK_LE(range.start, range.end);
789 return range; 791 return range;
790 } 792 }
791 793
792 } // namespace cc 794 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698