OLD | NEW |
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/picture_layer_tiling.h" | 5 #include "cc/picture_layer_tiling.h" |
| 6 |
| 7 #include "cc/math_util.h" |
6 #include "ui/gfx/rect_conversions.h" | 8 #include "ui/gfx/rect_conversions.h" |
7 #include "ui/gfx/size_conversions.h" | 9 #include "ui/gfx/size_conversions.h" |
8 | 10 |
9 namespace cc { | 11 namespace cc { |
10 | 12 |
11 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( | 13 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( |
12 float contents_scale, | 14 float contents_scale, |
13 gfx::Size tile_size) { | 15 gfx::Size tile_size) { |
14 return make_scoped_ptr(new PictureLayerTiling(contents_scale, tile_size)); | 16 return make_scoped_ptr(new PictureLayerTiling(contents_scale, tile_size)); |
15 } | 17 } |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 DCHECK_LE(texture_rect.right(), texture_size().width()); | 261 DCHECK_LE(texture_rect.right(), texture_size().width()); |
260 DCHECK_LE(texture_rect.bottom(), texture_size().height()); | 262 DCHECK_LE(texture_rect.bottom(), texture_size().height()); |
261 | 263 |
262 return texture_rect; | 264 return texture_rect; |
263 } | 265 } |
264 | 266 |
265 gfx::Size PictureLayerTiling::Iterator::texture_size() const { | 267 gfx::Size PictureLayerTiling::Iterator::texture_size() const { |
266 return tiling_->tiling_data_.max_texture_size(); | 268 return tiling_->tiling_data_.max_texture_size(); |
267 } | 269 } |
268 | 270 |
| 271 void PictureLayerTiling::UpdateTilePriorities( |
| 272 const gfx::Size& device_viewport, |
| 273 float layer_content_scale_x, |
| 274 float layer_content_scale_y, |
| 275 const gfx::Transform& last_screen_transform, |
| 276 const gfx::Transform& current_screen_transform, |
| 277 double time_delta) { |
| 278 gfx::Rect content_rect = ContentRect(); |
| 279 if (content_rect.IsEmpty()) |
| 280 return; |
| 281 |
| 282 gfx::Rect view_rect(gfx::Point(), device_viewport); |
| 283 int right = tiling_data_.TileXIndexFromSrcCoord(content_rect.width() - 1); |
| 284 int bottom = tiling_data_.TileYIndexFromSrcCoord(content_rect.height() - 1); |
| 285 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 286 TileMapKey key = it->first; |
| 287 TilePriority priority; |
| 288 if (key.first > right || key.second > bottom) { |
| 289 priority.distance_to_visible_in_pixels = std::numeric_limits<int>::max(); |
| 290 priority.time_to_visible_in_seconds = |
| 291 TilePriority::kMaxTimeToVisibleInSeconds; |
| 292 // TODO(qinmin): pass the correct tree to this function. |
| 293 it->second->set_priority(ACTIVE_TREE, priority); |
| 294 continue; |
| 295 } |
| 296 |
| 297 gfx::Rect tile_bound = tiling_data_.TileBounds(key.first, key.second); |
| 298 gfx::RectF layer_content_rect = gfx::ScaleRect( |
| 299 tile_bound, |
| 300 layer_content_scale_x / contents_scale_, |
| 301 layer_content_scale_y / contents_scale_); |
| 302 gfx::RectF screen_rect = MathUtil::mapClippedRect( |
| 303 current_screen_transform, layer_content_rect); |
| 304 gfx::RectF previous_rect = MathUtil::mapClippedRect( |
| 305 last_screen_transform, layer_content_rect); |
| 306 |
| 307 priority.resolution = HIGH_RESOLUTION; |
| 308 priority.time_to_visible_in_seconds = |
| 309 TilePriority::TimeForBoundsToIntersect( |
| 310 previous_rect, screen_rect, time_delta, view_rect); |
| 311 |
| 312 priority.distance_to_visible_in_pixels = |
| 313 TilePriority::manhattanDistance(screen_rect, view_rect); |
| 314 // TODO(qinmin): pass the correct tree to this function. |
| 315 it->second->set_priority(ACTIVE_TREE, priority); |
| 316 } |
| 317 } |
| 318 |
269 } // namespace cc | 319 } // namespace cc |
OLD | NEW |