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

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

Issue 732423002: Update from chromium https://crrev.com/304586 (Closed) Base URL: https://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
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 if (iter == tilings_.end()) 145 if (iter == tilings_.end())
139 return; 146 return;
140 tilings_.erase(iter); 147 tilings_.erase(iter);
141 } 148 }
142 149
143 void PictureLayerTilingSet::RemoveAllTiles() { 150 void PictureLayerTilingSet::RemoveAllTiles() {
144 for (size_t i = 0; i < tilings_.size(); ++i) 151 for (size_t i = 0; i < tilings_.size(); ++i)
145 tilings_[i]->Reset(); 152 tilings_[i]->Reset();
146 } 153 }
147 154
155 bool PictureLayerTilingSet::UpdateTilePriorities(
156 const gfx::Rect& required_rect_in_layer_space,
157 float ideal_contents_scale,
158 double current_frame_time_in_seconds,
159 const Occlusion& occlusion_in_layer_space,
160 bool can_require_tiles_for_activation) {
161 bool tiling_needs_update = false;
162 // TODO(vmpstr): Check if we have to early out here, or if we can just do it
163 // as part of computing tile priority rects for tilings.
164 for (auto* tiling : tilings_) {
165 if (tiling->NeedsUpdateForFrameAtTimeAndViewport(
166 current_frame_time_in_seconds, required_rect_in_layer_space)) {
167 tiling_needs_update = true;
168 break;
169 }
170 }
171 if (!tiling_needs_update)
172 return false;
173
174 for (auto* tiling : tilings_) {
175 tiling->set_can_require_tiles_for_activation(
176 can_require_tiles_for_activation);
177 tiling->ComputeTilePriorityRects(
178 required_rect_in_layer_space, ideal_contents_scale,
179 current_frame_time_in_seconds, occlusion_in_layer_space);
180 }
181 return true;
182 }
183
148 PictureLayerTilingSet::CoverageIterator::CoverageIterator( 184 PictureLayerTilingSet::CoverageIterator::CoverageIterator(
149 const PictureLayerTilingSet* set, 185 const PictureLayerTilingSet* set,
150 float contents_scale, 186 float contents_scale,
151 const gfx::Rect& content_rect, 187 const gfx::Rect& content_rect,
152 float ideal_contents_scale) 188 float ideal_contents_scale)
153 : set_(set), 189 : set_(set),
154 contents_scale_(contents_scale), 190 contents_scale_(contents_scale),
155 ideal_contents_scale_(ideal_contents_scale), 191 ideal_contents_scale_(ideal_contents_scale),
156 current_tiling_(-1) { 192 current_tiling_(-1) {
157 missing_region_.Union(content_rect); 193 missing_region_.Union(content_rect);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 case LOWER_THAN_LOW_RES: 401 case LOWER_THAN_LOW_RES:
366 range = TilingRange(low_res_range.end, tilings_.size()); 402 range = TilingRange(low_res_range.end, tilings_.size());
367 break; 403 break;
368 } 404 }
369 405
370 DCHECK_LE(range.start, range.end); 406 DCHECK_LE(range.start, range.end);
371 return range; 407 return range;
372 } 408 }
373 409
374 } // namespace cc 410 } // 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