Chromium Code Reviews| 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 | 6 |
| 7 #include "cc/math_util.h" | 7 #include "cc/math_util.h" |
| 8 #include "ui/gfx/rect_conversions.h" | 8 #include "ui/gfx/rect_conversions.h" |
| 9 #include "ui/gfx/size_conversions.h" | 9 #include "ui/gfx/size_conversions.h" |
| 10 | 10 |
| 11 namespace cc { | 11 namespace cc { |
| 12 | 12 |
| 13 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( | 13 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( |
| 14 float contents_scale, | 14 float contents_scale, |
| 15 gfx::Size tile_size) { | 15 gfx::Size tile_size) { |
| 16 return make_scoped_ptr(new PictureLayerTiling(contents_scale, tile_size)); | 16 return make_scoped_ptr(new PictureLayerTiling(contents_scale, tile_size)); |
| 17 } | 17 } |
| 18 | 18 |
| 19 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Clone() const { | 19 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Clone() const { |
| 20 return make_scoped_ptr(new PictureLayerTiling(*this)); | 20 return make_scoped_ptr(new PictureLayerTiling(*this)); |
| 21 } | 21 } |
| 22 | 22 |
| 23 PictureLayerTiling::PictureLayerTiling(float contents_scale, | 23 PictureLayerTiling::PictureLayerTiling(float contents_scale, |
| 24 gfx::Size tile_size) | 24 gfx::Size tile_size) |
| 25 : client_(NULL), | 25 : client_(NULL), |
| 26 contents_scale_(contents_scale), | 26 contents_scale_(contents_scale), |
| 27 tiling_data_(tile_size, gfx::Size(), true) { | 27 tiling_data_(tile_size, gfx::Size(), true), |
| 28 resolution_(NON_IDEAL_RESOLUTION) { | |
| 28 } | 29 } |
| 29 | 30 |
| 30 PictureLayerTiling::~PictureLayerTiling() { | 31 PictureLayerTiling::~PictureLayerTiling() { |
| 31 } | 32 } |
| 32 | 33 |
| 33 const PictureLayerTiling& PictureLayerTiling::operator=( | 34 const PictureLayerTiling& PictureLayerTiling::operator=( |
| 34 const PictureLayerTiling& tiler) { | 35 const PictureLayerTiling& tiler) { |
| 35 tiling_data_ = tiler.tiling_data_; | 36 tiling_data_ = tiler.tiling_data_; |
| 36 tiles_ = tiler.tiles_; | 37 tiles_ = tiler.tiles_; |
| 37 return *this; | 38 return *this; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 53 return NULL; | 54 return NULL; |
| 54 return iter->second.get(); | 55 return iter->second.get(); |
| 55 } | 56 } |
| 56 | 57 |
| 57 void PictureLayerTiling::CreateTile(int i, int j) { | 58 void PictureLayerTiling::CreateTile(int i, int j) { |
| 58 gfx::Rect tile_rect = tiling_data_.TileBoundsWithBorder(i, j); | 59 gfx::Rect tile_rect = tiling_data_.TileBoundsWithBorder(i, j); |
| 59 tile_rect.set_size(tiling_data_.max_texture_size()); | 60 tile_rect.set_size(tiling_data_.max_texture_size()); |
| 60 TileMapKey key(i, j); | 61 TileMapKey key(i, j); |
| 61 DCHECK(!tiles_[key]); | 62 DCHECK(!tiles_[key]); |
| 62 tiles_[key] = client_->CreateTile(this, tile_rect); | 63 tiles_[key] = client_->CreateTile(this, tile_rect); |
| 63 | |
| 64 // TODO(enne): Remove this when we start setting priorities correctly. | |
| 65 TilePriority priority; | |
| 66 priority.resolution = HIGH_RESOLUTION; | |
| 67 priority.time_to_visible_in_seconds = 1000; | |
| 68 tiles_[key]->set_priority(ACTIVE_TREE, priority); | |
| 69 } | 64 } |
| 70 | 65 |
| 71 Region PictureLayerTiling::OpaqueRegionInContentRect( | 66 Region PictureLayerTiling::OpaqueRegionInContentRect( |
| 72 const gfx::Rect& content_rect) const { | 67 const gfx::Rect& content_rect) const { |
| 73 Region opaque_region; | 68 Region opaque_region; |
| 74 // TODO(enne): implement me | 69 // TODO(enne): implement me |
| 75 return opaque_region; | 70 return opaque_region; |
| 76 } | 71 } |
| 77 | 72 |
| 78 void PictureLayerTiling::SetLayerBounds(gfx::Size layer_bounds) { | 73 void PictureLayerTiling::SetLayerBounds(gfx::Size layer_bounds) { |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 return texture_rect; | 259 return texture_rect; |
| 265 } | 260 } |
| 266 | 261 |
| 267 gfx::Size PictureLayerTiling::Iterator::texture_size() const { | 262 gfx::Size PictureLayerTiling::Iterator::texture_size() const { |
| 268 return tiling_->tiling_data_.max_texture_size(); | 263 return tiling_->tiling_data_.max_texture_size(); |
| 269 } | 264 } |
| 270 | 265 |
| 271 void PictureLayerTiling::UpdateTilePriorities( | 266 void PictureLayerTiling::UpdateTilePriorities( |
| 272 WhichTree tree, | 267 WhichTree tree, |
| 273 const gfx::Size& device_viewport, | 268 const gfx::Size& device_viewport, |
| 274 float layer_content_scale_x, | 269 float last_contents_scale, |
| 275 float layer_content_scale_y, | 270 float current_contents_scale, |
|
danakj
2013/01/07 22:35:56
not sure i'm a fan of the name "current". how does
enne (OOO)
2013/01/08 01:08:00
The tiling's contents scale is the scale for the t
| |
| 276 const gfx::Transform& last_screen_transform, | 271 const gfx::Transform& last_screen_transform, |
| 277 const gfx::Transform& current_screen_transform, | 272 const gfx::Transform& current_screen_transform, |
| 278 double time_delta) { | 273 double time_delta) { |
| 279 gfx::Rect content_rect = ContentRect(); | 274 gfx::Rect content_rect = ContentRect(); |
| 280 if (content_rect.IsEmpty()) | 275 if (content_rect.IsEmpty()) |
| 281 return; | 276 return; |
| 282 | 277 |
| 283 gfx::Rect view_rect(gfx::Point(), device_viewport); | 278 gfx::Rect view_rect(gfx::Point(), device_viewport); |
| 284 int right = tiling_data_.TileXIndexFromSrcCoord(content_rect.width() - 1); | 279 int right = tiling_data_.TileXIndexFromSrcCoord(content_rect.width() - 1); |
| 285 int bottom = tiling_data_.TileYIndexFromSrcCoord(content_rect.height() - 1); | 280 int bottom = tiling_data_.TileYIndexFromSrcCoord(content_rect.height() - 1); |
| 286 | 281 |
| 287 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 282 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 288 TileMapKey key = it->first; | 283 TileMapKey key = it->first; |
| 289 TilePriority priority; | 284 TilePriority priority; |
| 285 priority.resolution = resolution_; | |
| 290 if (key.first > right || key.second > bottom) { | 286 if (key.first > right || key.second > bottom) { |
| 291 priority.distance_to_visible_in_pixels = std::numeric_limits<int>::max(); | 287 priority.distance_to_visible_in_pixels = std::numeric_limits<int>::max(); |
| 292 priority.time_to_visible_in_seconds = | 288 priority.time_to_visible_in_seconds = |
| 293 TilePriority::kMaxTimeToVisibleInSeconds; | 289 TilePriority::kMaxTimeToVisibleInSeconds; |
| 294 it->second->set_priority(tree, priority); | 290 it->second->set_priority(tree, priority); |
| 295 continue; | 291 continue; |
| 296 } | 292 } |
| 297 | 293 |
| 298 gfx::Rect tile_bound = tiling_data_.TileBounds(key.first, key.second); | 294 gfx::Rect tile_bound = tiling_data_.TileBounds(key.first, key.second); |
| 299 gfx::RectF layer_content_rect = gfx::ScaleRect( | 295 gfx::RectF current_layer_content_rect = gfx::ScaleRect( |
| 300 tile_bound, | 296 tile_bound, |
| 301 layer_content_scale_x / contents_scale_, | 297 current_contents_scale / contents_scale_, |
| 302 layer_content_scale_y / contents_scale_); | 298 current_contents_scale / contents_scale_); |
| 303 gfx::RectF screen_rect = MathUtil::mapClippedRect( | 299 gfx::RectF screen_rect = MathUtil::mapClippedRect( |
| 304 current_screen_transform, layer_content_rect); | 300 current_screen_transform, current_layer_content_rect); |
|
danakj
2013/01/07 22:35:56
maybe current_screen_rect and last_screen_rect the
enne (OOO)
2013/01/08 01:08:00
Done.
| |
| 301 gfx::RectF last_layer_content_rect = gfx::ScaleRect( | |
| 302 tile_bound, | |
| 303 last_contents_scale / contents_scale_, | |
| 304 last_contents_scale / contents_scale_); | |
| 305 gfx::RectF previous_rect = MathUtil::mapClippedRect( | 305 gfx::RectF previous_rect = MathUtil::mapClippedRect( |
| 306 last_screen_transform, layer_content_rect); | 306 last_screen_transform, last_layer_content_rect); |
| 307 | 307 |
| 308 priority.resolution = HIGH_RESOLUTION; | |
| 309 priority.time_to_visible_in_seconds = | 308 priority.time_to_visible_in_seconds = |
| 310 TilePriority::TimeForBoundsToIntersect( | 309 TilePriority::TimeForBoundsToIntersect( |
| 311 previous_rect, screen_rect, time_delta, view_rect); | 310 previous_rect, screen_rect, time_delta, view_rect); |
| 312 | 311 |
| 313 priority.distance_to_visible_in_pixels = | 312 priority.distance_to_visible_in_pixels = |
| 314 TilePriority::manhattanDistance(screen_rect, view_rect); | 313 TilePriority::manhattanDistance(screen_rect, view_rect); |
| 315 it->second->set_priority(tree, priority); | 314 it->second->set_priority(tree, priority); |
| 316 } | 315 } |
| 317 } | 316 } |
| 318 | 317 |
| 319 } // namespace cc | 318 } // namespace cc |
| OLD | NEW |