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

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

Issue 716283003: cc: Remove GetRasterSource from PictureLayerTilingClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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
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/resources/picture_layer_tiling_set.h" 5 #include "cc/resources/picture_layer_tiling_set.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 namespace cc { 9 namespace cc {
10 10
11 namespace { 11 namespace {
12 12
13 class LargestToSmallestScaleFunctor { 13 class LargestToSmallestScaleFunctor {
14 public: 14 public:
15 bool operator() (PictureLayerTiling* left, PictureLayerTiling* right) { 15 bool operator() (PictureLayerTiling* left, PictureLayerTiling* right) {
16 return left->contents_scale() > right->contents_scale(); 16 return left->contents_scale() > right->contents_scale();
17 } 17 }
18 }; 18 };
19 19
20 } // namespace 20 } // namespace
21 21
22 PictureLayerTilingSet::PictureLayerTilingSet(PictureLayerTilingClient* client) 22 // static
23 : client_(client) { 23 scoped_ptr<PictureLayerTilingSet> PictureLayerTilingSet::Create(
24 PictureLayerTilingClient* client,
25 RasterSource* raster_source) {
26 return make_scoped_ptr(new PictureLayerTilingSet(client, raster_source));
27 }
28
29 PictureLayerTilingSet::PictureLayerTilingSet(PictureLayerTilingClient* client,
30 RasterSource* raster_source)
31 : client_(client), raster_source_(raster_source) {
24 } 32 }
25 33
26 PictureLayerTilingSet::~PictureLayerTilingSet() { 34 PictureLayerTilingSet::~PictureLayerTilingSet() {
27 } 35 }
28 36
29 void PictureLayerTilingSet::SetClient(PictureLayerTilingClient* client) { 37 void PictureLayerTilingSet::SetClient(PictureLayerTilingClient* client) {
30 client_ = client; 38 client_ = client;
31 for (size_t i = 0; i < tilings_.size(); ++i) 39 for (size_t i = 0; i < tilings_.size(); ++i)
32 tilings_[i]->SetClient(client_); 40 tilings_[i]->SetClient(client_);
33 } 41 }
34 42
43 void PictureLayerTilingSet::SetRasterSource(RasterSource* raster_source) {
44 raster_source_ = raster_source;
45 }
46
35 void PictureLayerTilingSet::RemoveTilesInRegion(const Region& region) { 47 void PictureLayerTilingSet::RemoveTilesInRegion(const Region& region) {
36 for (size_t i = 0; i < tilings_.size(); ++i) 48 for (size_t i = 0; i < tilings_.size(); ++i)
37 tilings_[i]->RemoveTilesInRegion(region); 49 tilings_[i]->RemoveTilesInRegion(region);
38 } 50 }
39 51
40 bool PictureLayerTilingSet::SyncTilings(const PictureLayerTilingSet& other, 52 bool PictureLayerTilingSet::SyncTilings(const PictureLayerTilingSet& other,
danakj 2014/11/14 21:39:51 how about passing it in here instead of adding a m
vmpstr 2014/11/14 23:49:02 I kind of like it as a PLTS member... My reason is
41 const gfx::Size& new_layer_bounds, 53 const gfx::Size& new_layer_bounds,
42 const Region& layer_invalidation, 54 const Region& layer_invalidation,
43 float minimum_contents_scale) { 55 float minimum_contents_scale) {
44 if (new_layer_bounds.IsEmpty()) { 56 if (new_layer_bounds.IsEmpty()) {
45 RemoveAllTilings(); 57 RemoveAllTilings();
46 return false; 58 return false;
47 } 59 }
48 60
49 tilings_.reserve(other.tilings_.size()); 61 tilings_.reserve(other.tilings_.size());
50 62
51 // Remove any tilings that aren't in |other| or don't meet the minimum. 63 // Remove any tilings that aren't in |other| or don't meet the minimum.
52 for (size_t i = 0; i < tilings_.size(); ++i) { 64 for (size_t i = 0; i < tilings_.size(); ++i) {
53 float scale = tilings_[i]->contents_scale(); 65 float scale = tilings_[i]->contents_scale();
54 if (scale >= minimum_contents_scale && !!other.TilingAtScale(scale)) 66 if (scale >= minimum_contents_scale && !!other.TilingAtScale(scale))
55 continue; 67 continue;
56 // Swap with the last element and remove it. 68 // Swap with the last element and remove it.
57 tilings_.swap(tilings_.begin() + i, tilings_.end() - 1); 69 tilings_.swap(tilings_.begin() + i, tilings_.end() - 1);
58 tilings_.pop_back(); 70 tilings_.pop_back();
59 --i; 71 --i;
60 } 72 }
61 73
74 DCHECK(raster_source_);
62 bool have_high_res_tiling = false; 75 bool have_high_res_tiling = false;
63 76
64 // Add any missing tilings from |other| that meet the minimum. 77 // Add any missing tilings from |other| that meet the minimum.
65 for (size_t i = 0; i < other.tilings_.size(); ++i) { 78 for (size_t i = 0; i < other.tilings_.size(); ++i) {
66 float contents_scale = other.tilings_[i]->contents_scale(); 79 float contents_scale = other.tilings_[i]->contents_scale();
67 if (contents_scale < minimum_contents_scale) 80 if (contents_scale < minimum_contents_scale)
68 continue; 81 continue;
69 if (PictureLayerTiling* this_tiling = TilingAtScale(contents_scale)) { 82 if (PictureLayerTiling* this_tiling = TilingAtScale(contents_scale)) {
70 this_tiling->set_resolution(other.tilings_[i]->resolution()); 83 this_tiling->set_resolution(other.tilings_[i]->resolution());
71 84
72 this_tiling->UpdateTilesToCurrentRasterSource(layer_invalidation, 85 this_tiling->UpdateTilesToCurrentRasterSource(
73 new_layer_bounds); 86 raster_source_, layer_invalidation, new_layer_bounds);
74 this_tiling->CreateMissingTilesInLiveTilesRect(); 87 this_tiling->CreateMissingTilesInLiveTilesRect();
75 if (this_tiling->resolution() == HIGH_RESOLUTION) 88 if (this_tiling->resolution() == HIGH_RESOLUTION)
76 have_high_res_tiling = true; 89 have_high_res_tiling = true;
77 90
78 DCHECK(this_tiling->tile_size() == 91 DCHECK(this_tiling->tile_size() ==
79 client_->CalculateTileSize(this_tiling->tiling_size())) 92 client_->CalculateTileSize(this_tiling->tiling_size()))
80 << "tile_size: " << this_tiling->tile_size().ToString() 93 << "tile_size: " << this_tiling->tile_size().ToString()
81 << " tiling_size: " << this_tiling->tiling_size().ToString() 94 << " tiling_size: " << this_tiling->tiling_size().ToString()
82 << " CalculateTileSize: " 95 << " CalculateTileSize: "
83 << client_->CalculateTileSize(this_tiling->tiling_size()).ToString(); 96 << client_->CalculateTileSize(this_tiling->tiling_size()).ToString();
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 case LOWER_THAN_LOW_RES: 378 case LOWER_THAN_LOW_RES:
366 range = TilingRange(low_res_range.end, tilings_.size()); 379 range = TilingRange(low_res_range.end, tilings_.size());
367 break; 380 break;
368 } 381 }
369 382
370 DCHECK_LE(range.start, range.end); 383 DCHECK_LE(range.start, range.end);
371 return range; 384 return range;
372 } 385 }
373 386
374 } // namespace cc 387 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling_set.h ('k') | cc/resources/picture_layer_tiling_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698