Chromium Code Reviews| Index: cc/picture_layer_tiling.cc |
| diff --git a/cc/picture_layer_tiling.cc b/cc/picture_layer_tiling.cc |
| index 7d3f975bda1c44eda663de9cac9dfd4290d850fd..cc6cf8e3a9fe2179e50db409ea7cd06bd4bb0555 100644 |
| --- a/cc/picture_layer_tiling.cc |
| +++ b/cc/picture_layer_tiling.cc |
| @@ -3,6 +3,8 @@ |
| // found in the LICENSE file. |
| #include "cc/picture_layer_tiling.h" |
| + |
| +#include "cc/math_util.h" |
| #include "ui/gfx/rect_conversions.h" |
| #include "ui/gfx/size_conversions.h" |
| @@ -266,4 +268,52 @@ gfx::Size PictureLayerTiling::Iterator::texture_size() const { |
| return tiling_->tiling_data_.max_texture_size(); |
| } |
| +void PictureLayerTiling::UpdateTilePriorities( |
| + const gfx::Size& device_view_port, |
|
enne (OOO)
2012/12/04 01:13:27
Sorry for the nit, but viewport is one word everyw
qinmin
2012/12/04 01:39:53
Done.
|
| + float layer_content_scale_x, |
| + float layer_content_scale_y, |
| + const gfx::Transform& last_screen_transform, |
| + const gfx::Transform& current_screen_transform, |
| + double time_delta) { |
| + gfx::Rect content_rect = ContentRect(); |
| + if (content_rect.IsEmpty()) |
| + return; |
| + |
| + gfx::Rect view_rect(gfx::Point(), device_view_port); |
| + int right = tiling_data_.TileXIndexFromSrcCoord(content_rect.width() - 1); |
| + int bottom = tiling_data_.TileYIndexFromSrcCoord(content_rect.height() - 1); |
| + for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| + TileMapKey key = it->first; |
| + TilePriority priority; |
| + if (key.first > right || key.second > bottom) { |
| + priority.distance_to_visible_in_pixels = std::numeric_limits<int>::max(); |
| + priority.time_to_visible_in_seconds = |
| + TilePriority::kMaxTimeToVisibleInSeconds; |
| + // TODO(qinmin): pass the correct tree to this function. |
| + it->second->set_priority(ACTIVE_TREE, priority); |
| + continue; |
| + } |
| + |
| + gfx::Rect tile_bound = tiling_data_.TileBounds(key.first, key.second); |
| + gfx::RectF layer_content_rect = gfx::ScaleRect( |
| + tile_bound, |
| + layer_content_scale_x / contents_scale_, |
| + layer_content_scale_y / contents_scale_); |
| + gfx::RectF screen_rect = MathUtil::mapClippedRect( |
| + current_screen_transform, layer_content_rect); |
| + gfx::RectF previous_rect = MathUtil::mapClippedRect( |
| + last_screen_transform, layer_content_rect); |
| + |
| + priority.resolution = HIGH_RESOLUTION; |
| + priority.time_to_visible_in_seconds = |
| + TilePriority::TimeForBoundsToIntersect( |
| + previous_rect, screen_rect, time_delta, view_rect); |
| + |
| + priority.distance_to_visible_in_pixels = |
| + TilePriority::manhattanDistance(screen_rect, view_rect); |
| + // TODO(qinmin): pass the correct tree to this function. |
| + it->second->set_priority(ACTIVE_TREE, priority); |
| + } |
| +} |
| + |
| } // namespace cc |