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

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

Issue 640063010: cc: Don't swap PictureLayerTilingSet on activate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: noswap: perftest Created 6 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/resources/picture_layer_tiling_set.h" 5 #include "cc/resources/picture_layer_tiling_set.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 22 matching lines...) Expand all
33 return make_scoped_ptr(new PictureLayerTilingSet(client)); 33 return make_scoped_ptr(new PictureLayerTilingSet(client));
34 } 34 }
35 35
36 PictureLayerTilingSet::PictureLayerTilingSet(PictureLayerTilingClient* client) 36 PictureLayerTilingSet::PictureLayerTilingSet(PictureLayerTilingClient* client)
37 : client_(client) { 37 : client_(client) {
38 } 38 }
39 39
40 PictureLayerTilingSet::~PictureLayerTilingSet() { 40 PictureLayerTilingSet::~PictureLayerTilingSet() {
41 } 41 }
42 42
43 void PictureLayerTilingSet::SetClient(PictureLayerTilingClient* client) { 43 void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSource(
44 client_ = client; 44 RasterSource* raster_source,
45 for (size_t i = 0; i < tilings_.size(); ++i) 45 const gfx::Size& layer_bounds,
46 tilings_[i]->SetClient(client_); 46 bool solid_color,
47 const Region& layer_invalidation,
48 float minimum_contents_scale) {
49 if (layer_bounds.IsEmpty() || solid_color) {
vmpstr 2014/12/01 22:38:04 I'd like to at some point see this move to the cal
danakj 2014/12/05 22:30:44 Done. CanHaveTilings() should actually already cov
50 RemoveAllTilings();
51 return;
52 }
53
54 for (size_t i = 0; i < tilings_.size(); ++i) {
vmpstr 2014/12/01 22:38:03 nit: would erase(remove_if) with a lambda work her
danakj 2014/12/05 22:30:44 remove_if does not work with ScopedPtrVector becau
55 float scale = tilings_[i]->contents_scale();
56 if (scale < minimum_contents_scale) {
57 tilings_.swap(tilings_.begin() + i, tilings_.end() - 1);
58 tilings_.pop_back();
59 --i;
60 }
61 }
62
63 for (PictureLayerTiling* tiling : tilings_) {
64 tiling->UpdateTilesToCurrentRasterSource(raster_source, layer_invalidation,
vmpstr 2014/12/01 22:38:04 I think this function should have the word "invali
danakj 2014/12/08 16:49:25 To give my POV here.. to me "invalidate" is actual
65 layer_bounds);
66 tiling->CreateMissingTilesInLiveTilesRect();
67
68 DCHECK(tiling->tile_size() ==
69 client_->CalculateTileSize(tiling->tiling_size()))
70 << "tile_size: " << tiling->tile_size().ToString()
71 << " tiling_size: " << tiling->tiling_size().ToString()
72 << " CalculateTileSize: "
73 << client_->CalculateTileSize(tiling->tiling_size()).ToString();
74 }
47 } 75 }
48 76
49 void PictureLayerTilingSet::RemoveTilesInRegion(const Region& region) { 77 void PictureLayerTilingSet::UpdateTilingsFromPending(
50 for (size_t i = 0; i < tilings_.size(); ++i) 78 RasterSource* raster_source,
51 tilings_[i]->RemoveTilesInRegion(region); 79 const PictureLayerTilingSet& other,
80 const gfx::Size& layer_bounds,
81 bool solid_color,
82 const Region& layer_invalidation,
83 float minimum_contents_scale) {
84 DCHECK_EQ(ACTIVE_TREE, client_->GetTree());
85
86 if (layer_bounds.IsEmpty() || solid_color) {
87 RemoveAllTilings();
88 return;
89 }
90
91 for (size_t i = 0; i < tilings_.size(); ++i) {
vmpstr 2014/12/01 22:38:04 This can probably be a separate function
danakj 2014/12/05 22:30:44 Done.
92 float scale = tilings_[i]->contents_scale();
93 if (scale < minimum_contents_scale) {
94 tilings_.swap(tilings_.begin() + i, tilings_.end() - 1);
95 tilings_.pop_back();
96 --i;
97 }
98 }
99
100 for (PictureLayerTiling* tiling : tilings_) {
101 // TODO(danakj): In the activate case can we do something simpler? Just copy
enne (OOO) 2014/12/01 22:08:17 That sounds nice, although I think you'd still kee
vmpstr 2014/12/01 22:38:03 I agree... I think we should be able to "blit" pen
102 // things from the pending tree and share all the tiles?
103 tiling->UpdateTilesToCurrentRasterSource(raster_source, layer_invalidation,
104 layer_bounds);
105 tiling->CreateMissingTilesInLiveTilesRect();
106 tiling->set_resolution(NON_IDEAL_RESOLUTION);
107
108 DCHECK(tiling->tile_size() ==
109 client_->CalculateTileSize(tiling->tiling_size()))
110 << "tile_size: " << tiling->tile_size().ToString()
111 << " tiling_size: " << tiling->tiling_size().ToString()
112 << " CalculateTileSize: "
113 << client_->CalculateTileSize(tiling->tiling_size()).ToString();
114 }
115
116 // Copy missing tilings, tiles and tiling resolutions from the pending tiling
117 // set.
118 for (size_t i = 0; i < other.tilings_.size(); ++i) {
vmpstr 2014/12/01 22:38:04 nit: for (PLT* tiling : other.tilings)
danakj 2014/12/05 22:30:44 Done.
119 float contents_scale = other.tilings_[i]->contents_scale();
120 DCHECK_GE(contents_scale, minimum_contents_scale);
121
122 PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale);
123 if (!this_tiling) {
124 scoped_ptr<PictureLayerTiling> new_tiling =
125 PictureLayerTiling::Create(contents_scale, layer_bounds, client_);
126 tilings_.push_back(new_tiling.Pass());
127 this_tiling = tilings_.back();
128 }
129 this_tiling->CreateSharedTilesFromPending(*other.tilings_[i]);
vmpstr 2014/12/01 22:38:03 I personally like this style of functionality, mod
danakj 2014/12/05 22:30:44 Done. CloneTilesAndPropertiesFrom()
130 this_tiling->set_resolution(other.tilings_[i]->resolution());
131
132 DCHECK_EQ(other.tilings_[i]->live_tiles_rect().ToString(),
133 this_tiling->live_tiles_rect().ToString());
134 }
135
136 tilings_.sort(LargestToSmallestScaleFunctor());
137
138 #if DCHECK_IS_ON
139 if (!tilings_.empty()) {
140 size_t num_high_res = 0;
141 for (const auto& t : tilings_)
vmpstr 2014/12/01 22:38:03 count_if?
danakj 2014/12/05 22:30:44 Oh, cool. Done.
142 num_high_res += t->resolution() == HIGH_RESOLUTION ? 1 : 0;
143 DCHECK_EQ(1u, num_high_res);
144 }
145 #endif
52 } 146 }
53 147
54 void PictureLayerTilingSet::CleanUpTilings( 148 void PictureLayerTilingSet::CleanUpTilings(
55 float min_acceptable_high_res_scale, 149 float min_acceptable_high_res_scale,
56 float max_acceptable_high_res_scale, 150 float max_acceptable_high_res_scale,
57 const std::vector<PictureLayerTiling*>& needed_tilings, 151 const std::vector<PictureLayerTiling*>& needed_tilings,
58 bool should_have_low_res, 152 bool should_have_low_res,
59 PictureLayerTilingSet* twin_set, 153 PictureLayerTilingSet* twin_set,
60 PictureLayerTilingSet* recycled_twin_set) { 154 PictureLayerTilingSet* recycled_twin_set) {
61 float twin_low_res_scale = 0.f; 155 float twin_low_res_scale = 0.f;
(...skipping 22 matching lines...) Expand all
84 // Don't remove tilings that are required. 178 // Don't remove tilings that are required.
85 if (std::find(needed_tilings.begin(), needed_tilings.end(), tiling) != 179 if (std::find(needed_tilings.begin(), needed_tilings.end(), tiling) !=
86 needed_tilings.end()) { 180 needed_tilings.end()) {
87 continue; 181 continue;
88 } 182 }
89 183
90 to_remove.push_back(tiling); 184 to_remove.push_back(tiling);
91 } 185 }
92 186
93 for (auto* tiling : to_remove) { 187 for (auto* tiling : to_remove) {
94 PictureLayerTiling* twin_tiling =
95 twin_set ? twin_set->FindTilingWithScale(tiling->contents_scale())
96 : nullptr;
97 // Only remove tilings from the twin layer if they have
98 // NON_IDEAL_RESOLUTION.
99 if (twin_tiling && twin_tiling->resolution() == NON_IDEAL_RESOLUTION)
100 twin_set->Remove(twin_tiling);
101
102 PictureLayerTiling* recycled_twin_tiling = 188 PictureLayerTiling* recycled_twin_tiling =
103 recycled_twin_set 189 recycled_twin_set
104 ? recycled_twin_set->FindTilingWithScale(tiling->contents_scale()) 190 ? recycled_twin_set->FindTilingWithScale(tiling->contents_scale())
105 : nullptr; 191 : nullptr;
106 // Remove the tiling from the recycle tree. Note that we ignore resolution, 192 // Remove the tiling from the recycle tree. Note that we ignore resolution,
107 // since we don't need to maintain high/low res on the recycle set. 193 // since we don't need to maintain high/low res on the recycle set.
108 if (recycled_twin_tiling) 194 if (recycled_twin_tiling)
109 recycled_twin_set->Remove(recycled_twin_tiling); 195 recycled_twin_set->Remove(recycled_twin_tiling);
110 196
111 DCHECK_NE(HIGH_RESOLUTION, tiling->resolution()); 197 DCHECK_NE(HIGH_RESOLUTION, tiling->resolution());
112 Remove(tiling); 198 Remove(tiling);
113 } 199 }
114 } 200 }
115 201
202 void PictureLayerTilingSet::RemoveNonIdealTilings() {
203 for (size_t i = 0; i < tilings_.size(); ++i) {
vmpstr 2014/12/01 22:38:04 nit: I'd prefer erase/remove_if, but feel free to
danakj 2014/12/05 22:30:44 Done.
204 PictureLayerTiling* tiling = tilings_[i];
205 if (tiling->resolution() == NON_IDEAL_RESOLUTION) {
206 tilings_.erase(tilings_.begin() + i);
207 --i;
208 }
209 }
210 }
211
116 void PictureLayerTilingSet::MarkAllTilingsNonIdeal() { 212 void PictureLayerTilingSet::MarkAllTilingsNonIdeal() {
117 for (auto* tiling : tilings_) 213 for (auto* tiling : tilings_)
118 tiling->set_resolution(NON_IDEAL_RESOLUTION); 214 tiling->set_resolution(NON_IDEAL_RESOLUTION);
119 } 215 }
120 216
121 bool PictureLayerTilingSet::SyncTilings(const PictureLayerTilingSet& other, 217 bool PictureLayerTilingSet::SyncTilings(const PictureLayerTilingSet& other,
122 const gfx::Size& new_layer_bounds, 218 const gfx::Size& new_layer_bounds,
123 const Region& layer_invalidation, 219 const Region& layer_invalidation,
124 float minimum_contents_scale, 220 float minimum_contents_scale,
125 RasterSource* raster_source) { 221 RasterSource* raster_source) {
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 case LOWER_THAN_LOW_RES: 614 case LOWER_THAN_LOW_RES:
519 range = TilingRange(low_res_range.end, tilings_.size()); 615 range = TilingRange(low_res_range.end, tilings_.size());
520 break; 616 break;
521 } 617 }
522 618
523 DCHECK_LE(range.start, range.end); 619 DCHECK_LE(range.start, range.end);
524 return range; 620 return range;
525 } 621 }
526 622
527 } // namespace cc 623 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698