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

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 // static
23 scoped_ptr<PictureLayerTilingSet> PictureLayerTilingSet::Create(
24 PictureLayerTilingClient* client) {
25 return make_scoped_ptr(new PictureLayerTilingSet(client));
26 }
27
22 PictureLayerTilingSet::PictureLayerTilingSet(PictureLayerTilingClient* client) 28 PictureLayerTilingSet::PictureLayerTilingSet(PictureLayerTilingClient* client)
23 : client_(client) { 29 : client_(client) {
24 } 30 }
25 31
26 PictureLayerTilingSet::~PictureLayerTilingSet() { 32 PictureLayerTilingSet::~PictureLayerTilingSet() {
27 } 33 }
28 34
29 void PictureLayerTilingSet::SetClient(PictureLayerTilingClient* client) { 35 void PictureLayerTilingSet::SetClient(PictureLayerTilingClient* client) {
30 client_ = client; 36 client_ = client;
31 for (size_t i = 0; i < tilings_.size(); ++i) 37 for (size_t i = 0; i < tilings_.size(); ++i)
32 tilings_[i]->SetClient(client_); 38 tilings_[i]->SetClient(client_);
33 } 39 }
34 40
35 void PictureLayerTilingSet::RemoveTilesInRegion(const Region& region) { 41 void PictureLayerTilingSet::RemoveTilesInRegion(const Region& region) {
36 for (size_t i = 0; i < tilings_.size(); ++i) 42 for (size_t i = 0; i < tilings_.size(); ++i)
37 tilings_[i]->RemoveTilesInRegion(region); 43 tilings_[i]->RemoveTilesInRegion(region);
38 } 44 }
39 45
40 bool PictureLayerTilingSet::SyncTilings(const PictureLayerTilingSet& other, 46 bool PictureLayerTilingSet::SyncTilings(const PictureLayerTilingSet& other,
41 const gfx::Size& new_layer_bounds, 47 const gfx::Size& new_layer_bounds,
42 const Region& layer_invalidation, 48 const Region& layer_invalidation,
43 float minimum_contents_scale) { 49 float minimum_contents_scale,
50 RasterSource* raster_source) {
44 if (new_layer_bounds.IsEmpty()) { 51 if (new_layer_bounds.IsEmpty()) {
45 RemoveAllTilings(); 52 RemoveAllTilings();
46 return false; 53 return false;
47 } 54 }
48 55
49 tilings_.reserve(other.tilings_.size()); 56 tilings_.reserve(other.tilings_.size());
50 57
51 // Remove any tilings that aren't in |other| or don't meet the minimum. 58 // Remove any tilings that aren't in |other| or don't meet the minimum.
52 for (size_t i = 0; i < tilings_.size(); ++i) { 59 for (size_t i = 0; i < tilings_.size(); ++i) {
53 float scale = tilings_[i]->contents_scale(); 60 float scale = tilings_[i]->contents_scale();
54 if (scale >= minimum_contents_scale && !!other.TilingAtScale(scale)) 61 if (scale >= minimum_contents_scale && !!other.TilingAtScale(scale))
55 continue; 62 continue;
56 // Swap with the last element and remove it. 63 // Swap with the last element and remove it.
57 tilings_.swap(tilings_.begin() + i, tilings_.end() - 1); 64 tilings_.swap(tilings_.begin() + i, tilings_.end() - 1);
58 tilings_.pop_back(); 65 tilings_.pop_back();
59 --i; 66 --i;
60 } 67 }
61 68
62 bool have_high_res_tiling = false; 69 bool have_high_res_tiling = false;
63 70
64 // Add any missing tilings from |other| that meet the minimum. 71 // Add any missing tilings from |other| that meet the minimum.
65 for (size_t i = 0; i < other.tilings_.size(); ++i) { 72 for (size_t i = 0; i < other.tilings_.size(); ++i) {
66 float contents_scale = other.tilings_[i]->contents_scale(); 73 float contents_scale = other.tilings_[i]->contents_scale();
67 if (contents_scale < minimum_contents_scale) 74 if (contents_scale < minimum_contents_scale)
68 continue; 75 continue;
69 if (PictureLayerTiling* this_tiling = TilingAtScale(contents_scale)) { 76 if (PictureLayerTiling* this_tiling = TilingAtScale(contents_scale)) {
70 this_tiling->set_resolution(other.tilings_[i]->resolution()); 77 this_tiling->set_resolution(other.tilings_[i]->resolution());
71 78
72 this_tiling->UpdateTilesToCurrentRasterSource(layer_invalidation, 79 this_tiling->UpdateTilesToCurrentRasterSource(
73 new_layer_bounds); 80 raster_source, layer_invalidation, new_layer_bounds);
74 this_tiling->CreateMissingTilesInLiveTilesRect(); 81 this_tiling->CreateMissingTilesInLiveTilesRect();
75 if (this_tiling->resolution() == HIGH_RESOLUTION) 82 if (this_tiling->resolution() == HIGH_RESOLUTION)
76 have_high_res_tiling = true; 83 have_high_res_tiling = true;
77 84
78 DCHECK(this_tiling->tile_size() == 85 DCHECK(this_tiling->tile_size() ==
79 client_->CalculateTileSize(this_tiling->tiling_size())) 86 client_->CalculateTileSize(this_tiling->tiling_size()))
80 << "tile_size: " << this_tiling->tile_size().ToString() 87 << "tile_size: " << this_tiling->tile_size().ToString()
81 << " tiling_size: " << this_tiling->tiling_size().ToString() 88 << " tiling_size: " << this_tiling->tiling_size().ToString()
82 << " CalculateTileSize: " 89 << " CalculateTileSize: "
83 << client_->CalculateTileSize(this_tiling->tiling_size()).ToString(); 90 << 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: 372 case LOWER_THAN_LOW_RES:
366 range = TilingRange(low_res_range.end, tilings_.size()); 373 range = TilingRange(low_res_range.end, tilings_.size());
367 break; 374 break;
368 } 375 }
369 376
370 DCHECK_LE(range.start, range.end); 377 DCHECK_LE(range.start, range.end);
371 return range; 378 return range;
372 } 379 }
373 380
374 } // namespace cc 381 } // 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