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

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

Issue 98113005: Revert "cc: Added tile bundles" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « cc/resources/picture_layer_tiling.h ('k') | cc/resources/picture_layer_tiling_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.h" 5 #include "cc/resources/picture_layer_tiling.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 10
11 #include "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
12 #include "cc/base/math_util.h" 12 #include "cc/base/math_util.h"
13 #include "ui/gfx/point_conversions.h" 13 #include "ui/gfx/point_conversions.h"
14 #include "ui/gfx/rect_conversions.h" 14 #include "ui/gfx/rect_conversions.h"
15 #include "ui/gfx/safe_integer_conversions.h" 15 #include "ui/gfx/safe_integer_conversions.h"
16 #include "ui/gfx/size_conversions.h" 16 #include "ui/gfx/size_conversions.h"
17 17
18 namespace cc { 18 namespace cc {
19 19
20 namespace {
21
22 const int kTileBundleWidth = 2;
23 const int kTileBundleHeight = 2;
24
25 std::pair<int, int> ComputeTileBundleIndex(int i, int j) {
26 return std::make_pair(i / kTileBundleWidth, j / kTileBundleHeight);
27 }
28
29 gfx::Size ComputeBundleTextureSize(gfx::Size tile_size,
30 const TilingData& tiling_data) {
31 int border_texels = tiling_data.border_texels();
32
33 int inner_tile_width = tile_size.width() - 2 * border_texels;
34 int bundle_width = inner_tile_width * kTileBundleWidth + 2 * border_texels;
35
36 int inner_tile_height = tile_size.height() - 2 * border_texels;
37 int bundle_height = inner_tile_height * kTileBundleHeight + 2 * border_texels;
38 return gfx::Size(bundle_width, bundle_height);
39 }
40
41 } // namespace
42
43 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( 20 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create(
44 float contents_scale, 21 float contents_scale,
45 gfx::Size layer_bounds, 22 gfx::Size layer_bounds,
46 PictureLayerTilingClient* client) { 23 PictureLayerTilingClient* client) {
47 return make_scoped_ptr(new PictureLayerTiling(contents_scale, 24 return make_scoped_ptr(new PictureLayerTiling(contents_scale,
48 layer_bounds, 25 layer_bounds,
49 client)); 26 client));
50 } 27 }
51 28
52 PictureLayerTiling::PictureLayerTiling(float contents_scale, 29 PictureLayerTiling::PictureLayerTiling(float contents_scale,
53 gfx::Size layer_bounds, 30 gfx::Size layer_bounds,
54 PictureLayerTilingClient* client) 31 PictureLayerTilingClient* client)
55 : contents_scale_(contents_scale), 32 : contents_scale_(contents_scale),
56 layer_bounds_(layer_bounds), 33 layer_bounds_(layer_bounds),
57 resolution_(NON_IDEAL_RESOLUTION), 34 resolution_(NON_IDEAL_RESOLUTION),
58 client_(client), 35 client_(client),
59 tiling_data_(gfx::Size(), gfx::Size(), true), 36 tiling_data_(gfx::Size(), gfx::Size(), true),
60 bundle_tiling_data_(gfx::Size(), gfx::Size(), true),
61 current_tree_(PENDING_TREE),
62 last_impl_frame_time_in_seconds_(0.0) { 37 last_impl_frame_time_in_seconds_(0.0) {
63 gfx::Size content_bounds = 38 gfx::Size content_bounds =
64 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)); 39 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale));
65 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); 40 gfx::Size tile_size = client_->CalculateTileSize(content_bounds);
66 41
67 DCHECK(!gfx::ToFlooredSize( 42 DCHECK(!gfx::ToFlooredSize(
68 gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) << 43 gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) <<
69 "Tiling created with scale too small as contents become empty." << 44 "Tiling created with scale too small as contents become empty." <<
70 " Layer bounds: " << layer_bounds.ToString() << 45 " Layer bounds: " << layer_bounds.ToString() <<
71 " Contents scale: " << contents_scale; 46 " Contents scale: " << contents_scale;
72 47
73 tiling_data_.SetTotalSize(content_bounds); 48 tiling_data_.SetTotalSize(content_bounds);
74 tiling_data_.SetMaxTextureSize(tile_size); 49 tiling_data_.SetMaxTextureSize(tile_size);
75 bundle_tiling_data_.SetTotalSize(content_bounds);
76 bundle_tiling_data_.SetMaxTextureSize(
77 ComputeBundleTextureSize(tile_size, tiling_data_));
78 } 50 }
79 51
80 PictureLayerTiling::~PictureLayerTiling() { 52 PictureLayerTiling::~PictureLayerTiling() {
81 SetLiveTilesRect(gfx::Rect());
82 } 53 }
83 54
84 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { 55 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) {
85 client_ = client; 56 client_ = client;
86 } 57 }
87 58
88 gfx::Rect PictureLayerTiling::ContentRect() const { 59 gfx::Rect PictureLayerTiling::ContentRect() const {
89 return gfx::Rect(tiling_data_.total_size()); 60 return gfx::Rect(tiling_data_.total_size());
90 } 61 }
91 62
92 gfx::SizeF PictureLayerTiling::ContentSizeF() const { 63 gfx::SizeF PictureLayerTiling::ContentSizeF() const {
93 return gfx::ScaleSize(layer_bounds_, contents_scale_); 64 return gfx::ScaleSize(layer_bounds_, contents_scale_);
94 } 65 }
95 66
96 TileBundle* PictureLayerTiling::CreateBundleForTileAt( 67 Tile* PictureLayerTiling::TileAt(int i, int j) const {
97 int i, 68 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j));
98 int j, 69 if (iter == tiles_.end())
99 const PictureLayerTiling* twin_tiling) { 70 return NULL;
100 TileBundleMapKey key = ComputeTileBundleIndex(i, j); 71 return iter->second.get();
101 DCHECK(tile_bundles_.find(key) == tile_bundles_.end());
102
103 scoped_refptr<TileBundle> candidate_bundle = NULL;
104
105 // Always try to get the twin bundle first. TileBundles are always shared
106 // between trees.
107 if (twin_tiling &&
108 tiling_data_.max_texture_size() ==
109 twin_tiling->tiling_data_.max_texture_size()) {
110 candidate_bundle = twin_tiling->TileBundleAt(key.first, key.second);
111 }
112
113 // If we couldn't get a tile bundle, create a new one.
114 if (!candidate_bundle) {
115 candidate_bundle = client_->CreateTileBundle(key.first * kTileBundleWidth,
116 key.second * kTileBundleHeight,
117 kTileBundleWidth,
118 kTileBundleHeight);
119 }
120 candidate_bundle->SwapTilesIfRequired();
121 tile_bundles_[key] = candidate_bundle;
122 return candidate_bundle.get();
123 } 72 }
124 73
125 TileBundle* PictureLayerTiling::TileBundleContainingTileAt(int i, int j) const { 74 void PictureLayerTiling::CreateTile(int i,
126 TileBundleMapKey key = ComputeTileBundleIndex(i, j);
127 return TileBundleAt(key.first, key.second);
128 }
129
130 TileBundle* PictureLayerTiling::TileBundleAt(int i, int j) const {
131 TileBundleMapKey key(i, j);
132 TileBundleMap::const_iterator it = tile_bundles_.find(key);
133 if (it == tile_bundles_.end())
134 return NULL;
135 it->second->SwapTilesIfRequired();
136 return it->second.get();
137 }
138
139 Tile* PictureLayerTiling::TileAt(WhichTree tree, int i, int j) const {
140 TileBundle* bundle = TileBundleContainingTileAt(i, j);
141 if (!bundle)
142 return NULL;
143 return bundle->TileAt(tree, i, j);
144 }
145
146 void PictureLayerTiling::CreateTile(WhichTree tree,
147 int i,
148 int j, 75 int j,
149 const PictureLayerTiling* twin_tiling) { 76 const PictureLayerTiling* twin_tiling) {
150 TileBundle* bundle = TileBundleContainingTileAt(i, j); 77 TileMapKey key(i, j);
151 if (!bundle) 78 DCHECK(tiles_.find(key) == tiles_.end());
152 bundle = CreateBundleForTileAt(i, j, twin_tiling);
153 79
154 gfx::Rect paint_rect = tiling_data_.TileBoundsWithBorder(i, j); 80 gfx::Rect paint_rect = tiling_data_.TileBoundsWithBorder(i, j);
155 gfx::Rect tile_rect = paint_rect; 81 gfx::Rect tile_rect = paint_rect;
156 tile_rect.set_size(tiling_data_.max_texture_size()); 82 tile_rect.set_size(tiling_data_.max_texture_size());
157 83
158 // Check our twin for a valid tile. 84 // Check our twin for a valid tile.
159 WhichTree twin_tree = (tree == ACTIVE_TREE) ? PENDING_TREE : ACTIVE_TREE; 85 if (twin_tiling &&
160 if (Tile* candidate_tile = bundle->TileAt(twin_tree, i, j)) { 86 tiling_data_.max_texture_size() ==
161 gfx::Rect rect = 87 twin_tiling->tiling_data_.max_texture_size()) {
162 gfx::ScaleToEnclosingRect(paint_rect, 1.0f / contents_scale_); 88 if (Tile* candidate_tile = twin_tiling->TileAt(i, j)) {
163 if (!client_->GetInvalidation()->Intersects(rect)) { 89 gfx::Rect rect =
164 bundle->AddTileAt(tree, i, j, candidate_tile); 90 gfx::ScaleToEnclosingRect(paint_rect, 1.0f / contents_scale_);
165 return; 91 if (!client_->GetInvalidation()->Intersects(rect)) {
92 tiles_[key] = candidate_tile;
93 return;
94 }
166 } 95 }
167 } 96 }
168 97
169 // Create a new tile because our twin didn't have a valid one. 98 // Create a new tile because our twin didn't have a valid one.
170 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); 99 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect);
171 if (tile.get()) 100 if (tile.get())
172 bundle->AddTileAt(tree, i, j, tile); 101 tiles_[key] = tile;
173 }
174
175 bool PictureLayerTiling::RemoveTile(WhichTree tree, int i, int j) {
176 TileBundleMapKey key = ComputeTileBundleIndex(i, j);
177 TileBundleMap::iterator it = tile_bundles_.find(key);
178 if (it == tile_bundles_.end())
179 return false;
180
181 it->second->SwapTilesIfRequired();
182 return it->second->RemoveTileAt(tree, i, j);
183 }
184
185 void PictureLayerTiling::RemoveBundleContainingTileAtIfEmpty(int i, int j) {
186 TileBundleMapKey key = ComputeTileBundleIndex(i, j);
187 TileBundleMap::iterator it = tile_bundles_.find(key);
188 if (it == tile_bundles_.end())
189 return;
190
191 if (it->second->IsEmpty())
192 tile_bundles_.erase(it);
193 } 102 }
194 103
195 Region PictureLayerTiling::OpaqueRegionInContentRect( 104 Region PictureLayerTiling::OpaqueRegionInContentRect(
196 gfx::Rect content_rect) const { 105 gfx::Rect content_rect) const {
197 Region opaque_region; 106 Region opaque_region;
198 // TODO(enne): implement me 107 // TODO(enne): implement me
199 return opaque_region; 108 return opaque_region;
200 } 109 }
201 110
202 void PictureLayerTiling::SetCanUseLCDText(bool can_use_lcd_text) { 111 void PictureLayerTiling::SetCanUseLCDText(bool can_use_lcd_text) {
203 // TODO(vmpstr): This can be done per bundle with results used 112 for (TileMap::iterator it = tiles_.begin(); it != tiles_.end(); ++it)
204 // in tile manager. 113 it->second->set_can_use_lcd_text(can_use_lcd_text);
205 for (TileBundleMap::iterator it = tile_bundles_.begin(); 114 }
206 it != tile_bundles_.end(); 115
207 ++it) { 116 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() {
208 for (TileBundle::Iterator tile_it(it->second, current_tree_); 117 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this);
209 tile_it; 118 for (TilingData::Iterator iter(&tiling_data_, live_tiles_rect_); iter;
210 ++tile_it) 119 ++iter) {
211 tile_it->set_can_use_lcd_text(can_use_lcd_text); 120 TileMapKey key = iter.index();
121 TileMap::iterator find = tiles_.find(key);
122 if (find != tiles_.end())
123 continue;
124 CreateTile(key.first, key.second, twin_tiling);
212 } 125 }
213 } 126 }
214 127
215 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() {
216 DCHECK(current_tree_ == PENDING_TREE);
217
218 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this);
219 for (TilingData::Iterator iter(&tiling_data_, live_tiles_rect_); iter;
220 ++iter) {
221 int tile_x = iter.index_x();
222 int tile_y = iter.index_y();
223 Tile* tile = TileAt(PENDING_TREE, tile_x, tile_y);
224 if (tile)
225 continue;
226 CreateTile(PENDING_TREE, tile_x, tile_y, twin_tiling);
227 }
228 }
229
230 void PictureLayerTiling::SetLayerBounds(gfx::Size layer_bounds) { 128 void PictureLayerTiling::SetLayerBounds(gfx::Size layer_bounds) {
231 if (layer_bounds_ == layer_bounds) 129 if (layer_bounds_ == layer_bounds)
232 return; 130 return;
233 131
234 DCHECK(current_tree_ == PENDING_TREE);
235 DCHECK(!layer_bounds.IsEmpty()); 132 DCHECK(!layer_bounds.IsEmpty());
236 133
237 gfx::Size old_layer_bounds = layer_bounds_; 134 gfx::Size old_layer_bounds = layer_bounds_;
238 layer_bounds_ = layer_bounds; 135 layer_bounds_ = layer_bounds;
239 gfx::Size old_content_bounds = tiling_data_.total_size(); 136 gfx::Size old_content_bounds = tiling_data_.total_size();
240 gfx::Size content_bounds = 137 gfx::Size content_bounds =
241 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds_, contents_scale_)); 138 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds_, contents_scale_));
242 139
243 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); 140 gfx::Size tile_size = client_->CalculateTileSize(content_bounds);
244 if (tile_size != tiling_data_.max_texture_size()) { 141 if (tile_size != tiling_data_.max_texture_size()) {
245 tiling_data_.SetTotalSize(content_bounds); 142 tiling_data_.SetTotalSize(content_bounds);
246 tiling_data_.SetMaxTextureSize(tile_size); 143 tiling_data_.SetMaxTextureSize(tile_size);
247 bundle_tiling_data_.SetTotalSize(content_bounds);
248 bundle_tiling_data_.SetMaxTextureSize(
249 ComputeBundleTextureSize(tile_size, tiling_data_));
250 Reset(); 144 Reset();
251 return; 145 return;
252 } 146 }
253 147
254 // Any tiles outside our new bounds are invalid and should be dropped. 148 // Any tiles outside our new bounds are invalid and should be dropped.
255 gfx::Rect bounded_live_tiles_rect(live_tiles_rect_); 149 gfx::Rect bounded_live_tiles_rect(live_tiles_rect_);
256 bounded_live_tiles_rect.Intersect(gfx::Rect(content_bounds)); 150 bounded_live_tiles_rect.Intersect(gfx::Rect(content_bounds));
257 SetLiveTilesRect(bounded_live_tiles_rect); 151 SetLiveTilesRect(bounded_live_tiles_rect);
258 tiling_data_.SetTotalSize(content_bounds); 152 tiling_data_.SetTotalSize(content_bounds);
259 bundle_tiling_data_.SetTotalSize(content_bounds);
260 153
261 // Create tiles for newly exposed areas. 154 // Create tiles for newly exposed areas.
262 Region layer_region((gfx::Rect(layer_bounds_))); 155 Region layer_region((gfx::Rect(layer_bounds_)));
263 layer_region.Subtract(gfx::Rect(old_layer_bounds)); 156 layer_region.Subtract(gfx::Rect(old_layer_bounds));
264 Invalidate(layer_region); 157 Invalidate(layer_region);
265 } 158 }
266 159
267 void PictureLayerTiling::Invalidate(const Region& layer_region) { 160 void PictureLayerTiling::Invalidate(const Region& layer_region) {
268 DCHECK(current_tree_ == PENDING_TREE); 161 std::vector<TileMapKey> new_tile_keys;
269
270 std::vector<std::pair<int, int> > new_tile_keys;
271 for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) { 162 for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) {
272 gfx::Rect layer_rect = iter.rect(); 163 gfx::Rect layer_rect = iter.rect();
273 gfx::Rect content_rect = 164 gfx::Rect content_rect =
274 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_); 165 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_);
275 content_rect.Intersect(live_tiles_rect_); 166 content_rect.Intersect(live_tiles_rect_);
276 if (content_rect.IsEmpty()) 167 if (content_rect.IsEmpty())
277 continue; 168 continue;
278 for (TilingData::Iterator iter(&tiling_data_, content_rect); iter; ++iter) { 169 for (TilingData::Iterator iter(&tiling_data_, content_rect); iter; ++iter) {
279 int tile_x = iter.index_x(); 170 TileMapKey key(iter.index());
280 int tile_y = iter.index_y(); 171 TileMap::iterator find = tiles_.find(key);
281 172 if (find == tiles_.end())
282 // If there is no bundle for the given tile, we can skip. 173 continue;
283 bool deleted = RemoveTile(PENDING_TREE, tile_x, tile_y); 174 tiles_.erase(find);
284 if (deleted) 175 new_tile_keys.push_back(key);
285 new_tile_keys.push_back(std::make_pair(tile_x, tile_y));
286 } 176 }
287 } 177 }
288 178
289 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); 179 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this);
290 for (size_t i = 0; i < new_tile_keys.size(); ++i) { 180 for (size_t i = 0; i < new_tile_keys.size(); ++i)
291 CreateTile(PENDING_TREE, 181 CreateTile(new_tile_keys[i].first, new_tile_keys[i].second, twin_tiling);
292 new_tile_keys[i].first,
293 new_tile_keys[i].second,
294 twin_tiling);
295 }
296 } 182 }
297 183
298 PictureLayerTiling::CoverageIterator::CoverageIterator() 184 PictureLayerTiling::CoverageIterator::CoverageIterator()
299 : tiling_(NULL), 185 : tiling_(NULL),
300 current_tile_(NULL), 186 current_tile_(NULL),
301 tile_i_(0), 187 tile_i_(0),
302 tile_j_(0), 188 tile_j_(0),
303 left_(0), 189 left_(0),
304 top_(0), 190 top_(0),
305 right_(-1), 191 right_(-1),
306 bottom_(-1) { 192 bottom_(-1) {
307 } 193 }
308 194
309 PictureLayerTiling::CoverageIterator::CoverageIterator( 195 PictureLayerTiling::CoverageIterator::CoverageIterator(
310 const PictureLayerTiling* tiling, 196 const PictureLayerTiling* tiling,
311 float dest_scale, 197 float dest_scale,
312 gfx::Rect dest_rect) 198 gfx::Rect dest_rect)
313 : tiling_(tiling), 199 : tiling_(tiling),
314 dest_rect_(dest_rect), 200 dest_rect_(dest_rect),
315 dest_to_content_scale_(0), 201 dest_to_content_scale_(0),
316 current_tile_(NULL), 202 current_tile_(NULL),
317 tile_i_(0), 203 tile_i_(0),
318 tile_j_(0), 204 tile_j_(0),
319 left_(0), 205 left_(0),
320 top_(0), 206 top_(0),
321 right_(-1), 207 right_(-1),
322 bottom_(-1), 208 bottom_(-1) {
323 tree_(tiling->current_tree_) {
324 DCHECK(tiling_); 209 DCHECK(tiling_);
325 if (dest_rect_.IsEmpty()) 210 if (dest_rect_.IsEmpty())
326 return; 211 return;
327 212
328 dest_to_content_scale_ = tiling_->contents_scale_ / dest_scale; 213 dest_to_content_scale_ = tiling_->contents_scale_ / dest_scale;
329 // This is the maximum size that the dest rect can be, given the content size. 214 // This is the maximum size that the dest rect can be, given the content size.
330 gfx::Size dest_content_size = gfx::ToCeiledSize(gfx::ScaleSize( 215 gfx::Size dest_content_size = gfx::ToCeiledSize(gfx::ScaleSize(
331 tiling_->ContentRect().size(), 216 tiling_->ContentRect().size(),
332 1 / dest_to_content_scale_, 217 1 / dest_to_content_scale_,
333 1 / dest_to_content_scale_)); 218 1 / dest_to_content_scale_));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 if (tile_i_ > right_) { 253 if (tile_i_ > right_) {
369 tile_i_ = left_; 254 tile_i_ = left_;
370 tile_j_++; 255 tile_j_++;
371 new_row = true; 256 new_row = true;
372 if (tile_j_ > bottom_) { 257 if (tile_j_ > bottom_) {
373 current_tile_ = NULL; 258 current_tile_ = NULL;
374 return *this; 259 return *this;
375 } 260 }
376 } 261 }
377 262
378 current_tile_ = tiling_->TileAt(tree_, tile_i_, tile_j_); 263 current_tile_ = tiling_->TileAt(tile_i_, tile_j_);
379 264
380 // Calculate the current geometry rect. Due to floating point rounding 265 // Calculate the current geometry rect. Due to floating point rounding
381 // and ToEnclosingRect, tiles might overlap in destination space on the 266 // and ToEnclosingRect, tiles might overlap in destination space on the
382 // edges. 267 // edges.
383 gfx::Rect last_geometry_rect = current_geometry_rect_; 268 gfx::Rect last_geometry_rect = current_geometry_rect_;
384 269
385 gfx::Rect content_rect = tiling_->tiling_data_.TileBounds(tile_i_, tile_j_); 270 gfx::Rect content_rect = tiling_->tiling_data_.TileBounds(tile_i_, tile_j_);
386 271
387 current_geometry_rect_ = 272 current_geometry_rect_ =
388 gfx::ScaleToEnclosingRect(content_rect, 273 gfx::ScaleToEnclosingRect(content_rect,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 return current_geometry_rect_; 309 return current_geometry_rect_;
425 } 310 }
426 311
427 gfx::Rect 312 gfx::Rect
428 PictureLayerTiling::CoverageIterator::full_tile_geometry_rect() const { 313 PictureLayerTiling::CoverageIterator::full_tile_geometry_rect() const {
429 gfx::Rect rect = tiling_->tiling_data_.TileBoundsWithBorder(tile_i_, tile_j_); 314 gfx::Rect rect = tiling_->tiling_data_.TileBoundsWithBorder(tile_i_, tile_j_);
430 rect.set_size(tiling_->tiling_data_.max_texture_size()); 315 rect.set_size(tiling_->tiling_data_.max_texture_size());
431 return rect; 316 return rect;
432 } 317 }
433 318
434 TilePriority PictureLayerTiling::CoverageIterator::priority() {
435 TileBundle* bundle = tiling_->TileBundleContainingTileAt(tile_i_, tile_j_);
436 if (bundle)
437 return bundle->GetPriority(tree_);
438 return TilePriority();
439 }
440
441 void PictureLayerTiling::CoverageIterator::SetPriorityForTesting(
442 const TilePriority& priority) {
443 TileBundle* bundle = tiling_->TileBundleContainingTileAt(tile_i_, tile_j_);
444 bundle->SetPriority(tree_, priority);
445 }
446
447 gfx::RectF PictureLayerTiling::CoverageIterator::texture_rect() const { 319 gfx::RectF PictureLayerTiling::CoverageIterator::texture_rect() const {
448 gfx::PointF tex_origin = 320 gfx::PointF tex_origin =
449 tiling_->tiling_data_.TileBoundsWithBorder(tile_i_, tile_j_).origin(); 321 tiling_->tiling_data_.TileBoundsWithBorder(tile_i_, tile_j_).origin();
450 322
451 // Convert from dest space => content space => texture space. 323 // Convert from dest space => content space => texture space.
452 gfx::RectF texture_rect(current_geometry_rect_); 324 gfx::RectF texture_rect(current_geometry_rect_);
453 texture_rect.Scale(dest_to_content_scale_, 325 texture_rect.Scale(dest_to_content_scale_,
454 dest_to_content_scale_); 326 dest_to_content_scale_);
455 texture_rect.Offset(-tex_origin.OffsetFromOrigin()); 327 texture_rect.Offset(-tex_origin.OffsetFromOrigin());
456 texture_rect.Intersect(tiling_->ContentRect()); 328 texture_rect.Intersect(tiling_->ContentRect());
457 329
458 return texture_rect; 330 return texture_rect;
459 } 331 }
460 332
461 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const { 333 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const {
462 return tiling_->tiling_data_.max_texture_size(); 334 return tiling_->tiling_data_.max_texture_size();
463 } 335 }
464 336
465 void PictureLayerTiling::Reset() { 337 void PictureLayerTiling::Reset() {
466 live_tiles_rect_ = gfx::Rect(); 338 live_tiles_rect_ = gfx::Rect();
467 tile_bundles_.clear(); 339 tiles_.clear();
468 } 340 }
469 341
470 void PictureLayerTiling::UpdateTilePriorities( 342 void PictureLayerTiling::UpdateTilePriorities(
471 WhichTree tree, 343 WhichTree tree,
472 gfx::Size device_viewport, 344 gfx::Size device_viewport,
473 gfx::Rect viewport_in_layer_space, 345 gfx::Rect viewport_in_layer_space,
474 gfx::Rect visible_layer_rect, 346 gfx::Rect visible_layer_rect,
475 gfx::Size last_layer_bounds, 347 gfx::Size last_layer_bounds,
476 gfx::Size current_layer_bounds, 348 gfx::Size current_layer_bounds,
477 float last_layer_contents_scale, 349 float last_layer_contents_scale,
478 float current_layer_contents_scale, 350 float current_layer_contents_scale,
479 const gfx::Transform& last_screen_transform, 351 const gfx::Transform& last_screen_transform,
480 const gfx::Transform& current_screen_transform, 352 const gfx::Transform& current_screen_transform,
481 double current_frame_time_in_seconds, 353 double current_frame_time_in_seconds,
482 size_t max_tiles_for_interest_area) { 354 size_t max_tiles_for_interest_area) {
483 if (!has_ever_been_updated())
484 current_tree_ = tree;
485
486 DCHECK_EQ(tree, current_tree_);
487 if (!NeedsUpdateForFrameAtTime(current_frame_time_in_seconds)) { 355 if (!NeedsUpdateForFrameAtTime(current_frame_time_in_seconds)) {
488 // This should never be zero for the purposes of has_ever_been_updated(). 356 // This should never be zero for the purposes of has_ever_been_updated().
489 DCHECK_NE(current_frame_time_in_seconds, 0.0); 357 DCHECK_NE(current_frame_time_in_seconds, 0.0);
490 return; 358 return;
491 } 359 }
492 if (ContentRect().IsEmpty()) { 360 if (ContentRect().IsEmpty()) {
493 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds; 361 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds;
494 return; 362 return;
495 } 363 }
496 364
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 std::numeric_limits<float>::epsilon()) && 400 std::numeric_limits<float>::epsilon()) &&
533 current_screen_transform.IsApproximatelyIdentityOrTranslation( 401 current_screen_transform.IsApproximatelyIdentityOrTranslation(
534 std::numeric_limits<float>::epsilon())) { 402 std::numeric_limits<float>::epsilon())) {
535 gfx::Vector2dF current_offset( 403 gfx::Vector2dF current_offset(
536 current_screen_transform.matrix().get(0, 3), 404 current_screen_transform.matrix().get(0, 3),
537 current_screen_transform.matrix().get(1, 3)); 405 current_screen_transform.matrix().get(1, 3));
538 gfx::Vector2dF last_offset( 406 gfx::Vector2dF last_offset(
539 last_screen_transform.matrix().get(0, 3), 407 last_screen_transform.matrix().get(0, 3),
540 last_screen_transform.matrix().get(1, 3)); 408 last_screen_transform.matrix().get(1, 3));
541 409
542 for (TilingData::Iterator iter(&bundle_tiling_data_, interest_rect); 410 for (TilingData::Iterator iter(&tiling_data_, interest_rect);
543 iter; ++iter) { 411 iter; ++iter) {
544 int bundle_x = iter.index_x(); 412 TileMap::iterator find = tiles_.find(iter.index());
545 int bundle_y = iter.index_y(); 413 if (find == tiles_.end())
546 TileBundle* bundle = TileBundleAt(bundle_x, bundle_y);
547 if (!bundle)
548 continue; 414 continue;
415 Tile* tile = find->second.get();
549 416
550 gfx::Rect bundle_bounds = 417 gfx::Rect tile_bounds =
551 bundle_tiling_data_.TileBounds(bundle_x, bundle_y); 418 tiling_data_.TileBounds(iter.index_x(), iter.index_y());
552 gfx::RectF current_screen_rect = 419 gfx::RectF current_screen_rect = gfx::ScaleRect(
553 gfx::ScaleRect(bundle_bounds, current_scale, current_scale) + 420 tile_bounds,
554 current_offset; 421 current_scale,
555 gfx::RectF last_screen_rect = 422 current_scale) + current_offset;
556 gfx::ScaleRect(bundle_bounds, last_scale, last_scale) + 423 gfx::RectF last_screen_rect = gfx::ScaleRect(
557 last_offset; 424 tile_bounds,
425 last_scale,
426 last_scale) + last_offset;
558 427
559 float distance_to_visible_in_pixels = 428 float distance_to_visible_in_pixels =
560 current_screen_rect.ManhattanInternalDistance(view_rect); 429 current_screen_rect.ManhattanInternalDistance(view_rect);
561 430
562 float time_to_visible_in_seconds = 431 float time_to_visible_in_seconds =
563 TilePriority::TimeForBoundsToIntersect( 432 TilePriority::TimeForBoundsToIntersect(
564 last_screen_rect, current_screen_rect, time_delta, view_rect); 433 last_screen_rect, current_screen_rect, time_delta, view_rect);
565 TilePriority priority( 434 TilePriority priority(
566 resolution_, 435 resolution_,
567 time_to_visible_in_seconds, 436 time_to_visible_in_seconds,
568 distance_to_visible_in_pixels); 437 distance_to_visible_in_pixels);
569 438 tile->SetPriority(tree, priority);
570 bundle->SetPriority(tree, priority);
571 } 439 }
572 } else if (!last_screen_transform.HasPerspective() && 440 } else if (!last_screen_transform.HasPerspective() &&
573 !current_screen_transform.HasPerspective()) { 441 !current_screen_transform.HasPerspective()) {
574 // Secondary fast path that can be applied for any affine transforms. 442 // Secondary fast path that can be applied for any affine transforms.
575 443
576 // Initialize the necessary geometry in screen space, so that we can 444 // Initialize the necessary geometry in screen space, so that we can
577 // iterate over tiles in screen space without needing a costly transform 445 // iterate over tiles in screen space without needing a costly transform
578 // mapping for each tile. 446 // mapping for each tile.
579 447
580 // Apply screen space transform to the local origin point (0, 0); only the 448 // Apply screen space transform to the local origin point (0, 0); only the
581 // translation component is needed and can be initialized directly. 449 // translation component is needed and can be initialized directly.
582 gfx::Point current_screen_space_origin( 450 gfx::Point current_screen_space_origin(
583 current_screen_transform.matrix().get(0, 3), 451 current_screen_transform.matrix().get(0, 3),
584 current_screen_transform.matrix().get(1, 3)); 452 current_screen_transform.matrix().get(1, 3));
585 453
586 gfx::Point last_screen_space_origin( 454 gfx::Point last_screen_space_origin(
587 last_screen_transform.matrix().get(0, 3), 455 last_screen_transform.matrix().get(0, 3),
588 last_screen_transform.matrix().get(1, 3)); 456 last_screen_transform.matrix().get(1, 3));
589 457
590 float current_bundle_width = 458 float current_tile_width = tiling_data_.TileSizeX(0) * current_scale;
591 bundle_tiling_data_.TileSizeX(0) * current_scale; 459 float last_tile_width = tiling_data_.TileSizeX(0) * last_scale;
592 float last_bundle_width = 460 float current_tile_height = tiling_data_.TileSizeY(0) * current_scale;
593 bundle_tiling_data_.TileSizeX(0) * last_scale; 461 float last_tile_height = tiling_data_.TileSizeY(0) * last_scale;
594 float current_bundle_height =
595 bundle_tiling_data_.TileSizeY(0) * current_scale;
596 float last_bundle_height =
597 bundle_tiling_data_.TileSizeY(0) * last_scale;
598 462
599 // Apply screen space transform to local basis vectors (tile_width, 0) and 463 // Apply screen space transform to local basis vectors (tile_width, 0) and
600 // (0, tile_height); the math simplifies and can be initialized directly. 464 // (0, tile_height); the math simplifies and can be initialized directly.
601 gfx::Vector2dF current_horizontal( 465 gfx::Vector2dF current_horizontal(
602 current_screen_transform.matrix().get(0, 0) * current_bundle_width, 466 current_screen_transform.matrix().get(0, 0) * current_tile_width,
603 current_screen_transform.matrix().get(1, 0) * current_bundle_width); 467 current_screen_transform.matrix().get(1, 0) * current_tile_width);
604 gfx::Vector2dF current_vertical( 468 gfx::Vector2dF current_vertical(
605 current_screen_transform.matrix().get(0, 1) * current_bundle_height, 469 current_screen_transform.matrix().get(0, 1) * current_tile_height,
606 current_screen_transform.matrix().get(1, 1) * current_bundle_height); 470 current_screen_transform.matrix().get(1, 1) * current_tile_height);
607 471
608 gfx::Vector2dF last_horizontal( 472 gfx::Vector2dF last_horizontal(
609 last_screen_transform.matrix().get(0, 0) * last_bundle_width, 473 last_screen_transform.matrix().get(0, 0) * last_tile_width,
610 last_screen_transform.matrix().get(1, 0) * last_bundle_width); 474 last_screen_transform.matrix().get(1, 0) * last_tile_width);
611 gfx::Vector2dF last_vertical( 475 gfx::Vector2dF last_vertical(
612 last_screen_transform.matrix().get(0, 1) * last_bundle_height, 476 last_screen_transform.matrix().get(0, 1) * last_tile_height,
613 last_screen_transform.matrix().get(1, 1) * last_bundle_height); 477 last_screen_transform.matrix().get(1, 1) * last_tile_height);
614 478
615 for (TilingData::Iterator iter(&bundle_tiling_data_, interest_rect); 479 for (TilingData::Iterator iter(&tiling_data_, interest_rect);
616 iter; ++iter) { 480 iter; ++iter) {
617 int bundle_x = iter.index_x(); 481 TileMap::iterator find = tiles_.find(iter.index());
618 int bundle_y = iter.index_y(); 482 if (find == tiles_.end())
619 TileBundle* bundle = TileBundleAt(bundle_x, bundle_y);
620 if (!bundle)
621 continue; 483 continue;
622 484
623 gfx::PointF current_bundle_origin = current_screen_space_origin + 485 Tile* tile = find->second.get();
624 ScaleVector2d(current_horizontal, bundle_x) + 486
625 ScaleVector2d(current_vertical, bundle_y); 487 int i = iter.index_x();
626 gfx::PointF last_bundle_origin = last_screen_space_origin + 488 int j = iter.index_y();
627 ScaleVector2d(last_horizontal, bundle_x) + 489 gfx::PointF current_tile_origin = current_screen_space_origin +
628 ScaleVector2d(last_vertical, bundle_y); 490 ScaleVector2d(current_horizontal, i) +
491 ScaleVector2d(current_vertical, j);
492 gfx::PointF last_tile_origin = last_screen_space_origin +
493 ScaleVector2d(last_horizontal, i) +
494 ScaleVector2d(last_vertical, j);
629 495
630 gfx::RectF current_screen_rect = gfx::QuadF( 496 gfx::RectF current_screen_rect = gfx::QuadF(
631 current_bundle_origin, 497 current_tile_origin,
632 current_bundle_origin + current_horizontal, 498 current_tile_origin + current_horizontal,
633 current_bundle_origin + current_horizontal + current_vertical, 499 current_tile_origin + current_horizontal + current_vertical,
634 current_bundle_origin + current_vertical).BoundingBox(); 500 current_tile_origin + current_vertical).BoundingBox();
635 501
636 gfx::RectF last_screen_rect = gfx::QuadF( 502 gfx::RectF last_screen_rect = gfx::QuadF(
637 last_bundle_origin, 503 last_tile_origin,
638 last_bundle_origin + last_horizontal, 504 last_tile_origin + last_horizontal,
639 last_bundle_origin + last_horizontal + last_vertical, 505 last_tile_origin + last_horizontal + last_vertical,
640 last_bundle_origin + last_vertical).BoundingBox(); 506 last_tile_origin + last_vertical).BoundingBox();
641 507
642 float distance_to_visible_in_pixels = 508 float distance_to_visible_in_pixels =
643 current_screen_rect.ManhattanInternalDistance(view_rect); 509 current_screen_rect.ManhattanInternalDistance(view_rect);
644 510
645 float time_to_visible_in_seconds = 511 float time_to_visible_in_seconds =
646 TilePriority::TimeForBoundsToIntersect( 512 TilePriority::TimeForBoundsToIntersect(
647 last_screen_rect, current_screen_rect, time_delta, view_rect); 513 last_screen_rect, current_screen_rect, time_delta, view_rect);
648 TilePriority priority( 514 TilePriority priority(
649 resolution_, 515 resolution_,
650 time_to_visible_in_seconds, 516 time_to_visible_in_seconds,
651 distance_to_visible_in_pixels); 517 distance_to_visible_in_pixels);
652 518 tile->SetPriority(tree, priority);
653 bundle->SetPriority(tree, priority);
654 } 519 }
655 } else { 520 } else {
656 for (TilingData::Iterator iter(&bundle_tiling_data_, interest_rect); 521 for (TilingData::Iterator iter(&tiling_data_, interest_rect);
657 iter; ++iter) { 522 iter; ++iter) {
658 int bundle_x = iter.index_x(); 523 TileMap::iterator find = tiles_.find(iter.index());
659 int bundle_y = iter.index_y(); 524 if (find == tiles_.end())
660 TileBundle* bundle = TileBundleAt(bundle_x, bundle_y);
661 if (!bundle)
662 continue; 525 continue;
526 Tile* tile = find->second.get();
663 527
664 gfx::Rect bundle_bounds = 528 gfx::Rect tile_bounds =
665 bundle_tiling_data_.TileBounds(bundle_x, bundle_y); 529 tiling_data_.TileBounds(iter.index_x(), iter.index_y());
666 gfx::RectF current_layer_content_rect = gfx::ScaleRect( 530 gfx::RectF current_layer_content_rect = gfx::ScaleRect(
667 bundle_bounds, 531 tile_bounds,
668 current_scale, 532 current_scale,
669 current_scale); 533 current_scale);
670 gfx::RectF current_screen_rect = MathUtil::MapClippedRect( 534 gfx::RectF current_screen_rect = MathUtil::MapClippedRect(
671 current_screen_transform, current_layer_content_rect); 535 current_screen_transform, current_layer_content_rect);
672 gfx::RectF last_layer_content_rect = gfx::ScaleRect( 536 gfx::RectF last_layer_content_rect = gfx::ScaleRect(
673 bundle_bounds, 537 tile_bounds,
674 last_scale, 538 last_scale,
675 last_scale); 539 last_scale);
676 gfx::RectF last_screen_rect = MathUtil::MapClippedRect( 540 gfx::RectF last_screen_rect = MathUtil::MapClippedRect(
677 last_screen_transform, last_layer_content_rect); 541 last_screen_transform, last_layer_content_rect);
678 542
679 float distance_to_visible_in_pixels = 543 float distance_to_visible_in_pixels =
680 current_screen_rect.ManhattanInternalDistance(view_rect); 544 current_screen_rect.ManhattanInternalDistance(view_rect);
681 545
682 float time_to_visible_in_seconds = 546 float time_to_visible_in_seconds =
683 TilePriority::TimeForBoundsToIntersect( 547 TilePriority::TimeForBoundsToIntersect(
684 last_screen_rect, current_screen_rect, time_delta, view_rect); 548 last_screen_rect, current_screen_rect, time_delta, view_rect);
685 549
686 TilePriority priority( 550 TilePriority priority(
687 resolution_, 551 resolution_,
688 time_to_visible_in_seconds, 552 time_to_visible_in_seconds,
689 distance_to_visible_in_pixels); 553 distance_to_visible_in_pixels);
690 554 tile->SetPriority(tree, priority);
691 bundle->SetPriority(tree, priority);
692 } 555 }
693 } 556 }
694 557
695 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds; 558 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds;
696 } 559 }
697 560
698 void PictureLayerTiling::SetLiveTilesRect(gfx::Rect new_live_tiles_rect) { 561 void PictureLayerTiling::SetLiveTilesRect(
562 gfx::Rect new_live_tiles_rect) {
699 DCHECK(new_live_tiles_rect.IsEmpty() || 563 DCHECK(new_live_tiles_rect.IsEmpty() ||
700 ContentRect().Contains(new_live_tiles_rect)); 564 ContentRect().Contains(new_live_tiles_rect));
701 if (live_tiles_rect_ == new_live_tiles_rect) 565 if (live_tiles_rect_ == new_live_tiles_rect)
702 return; 566 return;
703 567
704 // Iterate to delete all tiles outside of our new live_tiles rect. 568 // Iterate to delete all tiles outside of our new live_tiles rect.
705 for (TilingData::DifferenceIterator iter(&tiling_data_, 569 for (TilingData::DifferenceIterator iter(&tiling_data_,
706 live_tiles_rect_, 570 live_tiles_rect_,
707 new_live_tiles_rect); 571 new_live_tiles_rect);
708 iter; 572 iter;
709 ++iter) { 573 ++iter) {
710 int tile_x = iter.index_x(); 574 TileMapKey key(iter.index());
711 int tile_y = iter.index_y(); 575 TileMap::iterator found = tiles_.find(key);
712
713 // If the tile was outside of the recorded region, it won't exist even 576 // If the tile was outside of the recorded region, it won't exist even
714 // though it was in the live rect. 577 // though it was in the live rect.
715 RemoveTile(current_tree_, tile_x, tile_y); 578 if (found != tiles_.end())
716 RemoveBundleContainingTileAtIfEmpty(tile_x, tile_y); 579 tiles_.erase(found);
717 }
718
719 if (new_live_tiles_rect.IsEmpty()) {
720 live_tiles_rect_ = new_live_tiles_rect;
721 return;
722 } 580 }
723 581
724 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); 582 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this);
725 583
726 // Iterate to allocate new tiles for all regions with newly exposed area. 584 // Iterate to allocate new tiles for all regions with newly exposed area.
727 for (TilingData::DifferenceIterator iter(&tiling_data_, 585 for (TilingData::DifferenceIterator iter(&tiling_data_,
728 new_live_tiles_rect, 586 new_live_tiles_rect,
729 live_tiles_rect_); 587 live_tiles_rect_);
730 iter; 588 iter;
731 ++iter) { 589 ++iter) {
732 CreateTile(current_tree_, iter.index_x(), iter.index_y(), twin_tiling); 590 TileMapKey key(iter.index());
591 CreateTile(key.first, key.second, twin_tiling);
733 } 592 }
734 593
735 live_tiles_rect_ = new_live_tiles_rect; 594 live_tiles_rect_ = new_live_tiles_rect;
736 } 595 }
737 596
738 void PictureLayerTiling::DidBecomeRecycled() { 597 void PictureLayerTiling::DidBecomeRecycled() {
739 // DidBecomeActive below will set the active priority for tiles that are 598 // DidBecomeActive below will set the active priority for tiles that are
740 // still in the tree. Calling this first on an active tiling that is becoming 599 // still in the tree. Calling this first on an active tiling that is becoming
741 // recycled takes care of tiles that are no longer in the active tree (eg. 600 // recycled takes care of tiles that are no longer in the active tree (eg.
742 // due to a pending invalidation). 601 // due to a pending invalidation).
743 for (TileBundleMap::const_iterator it = tile_bundles_.begin(); 602 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
744 it != tile_bundles_.end(); 603 it->second->SetPriority(ACTIVE_TREE, TilePriority());
745 ++it) {
746 it->second->DidBecomeRecycled();
747 } 604 }
748 // Note that recycled tree would not be accessed, and the next tree
749 // stage after recycled in pending, so we can just set the state to
750 // pending here.
751 current_tree_ = PENDING_TREE;
752 } 605 }
753 606
754 void PictureLayerTiling::DidBecomeActive() { 607 void PictureLayerTiling::DidBecomeActive() {
755 for (TileBundleMap::const_iterator it = tile_bundles_.begin(); 608 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
756 it != tile_bundles_.end(); 609 it->second->SetPriority(ACTIVE_TREE, it->second->priority(PENDING_TREE));
757 ++it) { 610 it->second->SetPriority(PENDING_TREE, TilePriority());
758 it->second->DidBecomeActive(); 611
759 for (TileBundle::Iterator tile_it(it->second.get(), ACTIVE_TREE); 612 // Tile holds a ref onto a picture pile. If the tile never gets invalidated
760 tile_it; 613 // and recreated, then that picture pile ref could exist indefinitely. To
761 ++tile_it) { 614 // prevent this, ask the client to update the pile to its own ref. This
762 // Tile holds a ref onto a picture pile. If the tile never gets 615 // will cause PicturePileImpls and their clones to get deleted once the
763 // invalidated and recreated, then that picture pile ref could exist 616 // corresponding PictureLayerImpl and any in flight raster jobs go out of
764 // indefinitely. To prevent this, ask the client to update the pile to 617 // scope.
765 // its own ref. This will cause PicturePileImpls and their clones to get 618 client_->UpdatePile(it->second.get());
766 // deleted once the corresponding PictureLayerImpl and any in flight
767 // raster jobs go out of scope.
768 client_->UpdatePile(*tile_it);
769 }
770 } 619 }
771 current_tree_ = ACTIVE_TREE;
772 } 620 }
773 621
774 void PictureLayerTiling::UpdateTilesToCurrentPile() { 622 void PictureLayerTiling::UpdateTilesToCurrentPile() {
775 for (TileBundleMap::const_iterator it = tile_bundles_.begin(); 623 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
776 it != tile_bundles_.end(); 624 client_->UpdatePile(it->second.get());
777 ++it) {
778 for (TileBundle::Iterator tile_it(it->second.get(), PENDING_TREE);
779 tile_it;
780 ++tile_it) {
781 client_->UpdatePile(*tile_it);
782 }
783 } 625 }
784 } 626 }
785 627
786 scoped_ptr<base::Value> PictureLayerTiling::AsValue() const { 628 scoped_ptr<base::Value> PictureLayerTiling::AsValue() const {
787 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 629 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
788 state->SetInteger("num_tile_bundles", tile_bundles_.size()); 630 state->SetInteger("num_tiles", tiles_.size());
789 state->SetDouble("content_scale", contents_scale_); 631 state->SetDouble("content_scale", contents_scale_);
790 state->Set("content_bounds", 632 state->Set("content_bounds",
791 MathUtil::AsValue(ContentRect().size()).release()); 633 MathUtil::AsValue(ContentRect().size()).release());
792 return state.PassAs<base::Value>(); 634 return state.PassAs<base::Value>();
793 } 635 }
794 636
795 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { 637 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const {
796 size_t amount = 0; 638 size_t amount = 0;
797 for (TileBundleMap::const_iterator it = tile_bundles_.begin(); 639 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
798 it != tile_bundles_.end(); 640 const Tile* tile = it->second.get();
799 ++it) { 641 amount += tile->GPUMemoryUsageInBytes();
800 for (TileBundle::Iterator tile_it(it->second.get()); tile_it; ++tile_it)
801 amount += tile_it->GPUMemoryUsageInBytes();
802 } 642 }
803 return amount; 643 return amount;
804 } 644 }
805 645
806 PictureLayerTiling::RectExpansionCache::RectExpansionCache() 646 PictureLayerTiling::RectExpansionCache::RectExpansionCache()
807 : previous_target(0) { 647 : previous_target(0) {
808 } 648 }
809 649
810 namespace { 650 namespace {
811 651
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 break; 786 break;
947 } 787 }
948 788
949 gfx::Rect result(origin_x, origin_y, width, height); 789 gfx::Rect result(origin_x, origin_y, width, height);
950 if (cache) 790 if (cache)
951 cache->previous_result = result; 791 cache->previous_result = result;
952 return result; 792 return result;
953 } 793 }
954 794
955 } // namespace cc 795 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling.h ('k') | cc/resources/picture_layer_tiling_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698