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 | |
| 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& view_port, | |
| 273 float layer_content_scaleX, | |
| 274 float layer_content_scaleY, | |
| 275 const gfx::Transform& last_screen_transform, | |
| 276 const gfx::Transform& current_screen_transform, | |
| 277 double time_delta) { | |
| 278 gfx::Rect countent_rect = ContentRect(); | |
|
enne (OOO)
2012/12/03 19:57:28
countent => content
qinmin
2012/12/04 00:37:30
Done.
| |
| 279 if (countent_rect.IsEmpty()) | |
| 280 return; | |
| 281 | |
| 282 gfx::Rect view_rect(gfx::Point(), view_port); | |
| 283 int right = tiling_data_.TileXIndexFromSrcCoord(countent_rect.width() - 1); | |
| 284 int bottom = tiling_data_.TileYIndexFromSrcCoord(countent_rect.height() - 1); | |
| 285 for (int j = 0; j <= bottom; ++j) { | |
|
enne (OOO)
2012/12/03 19:57:28
For correctness, do you need to iterate over all t
qinmin
2012/12/04 00:37:30
Done. looping throught the whole hash map to set p
| |
| 286 for (int i = 0; i <= right; ++i) { | |
| 287 gfx::Rect content_rect = tiling_data_.TileBounds(i, j); | |
|
enne (OOO)
2012/12/03 19:57:28
I think your math is wrong here for layer content
enne (OOO)
2012/12/03 22:08:54
Actually, scratch that. I think your math is righ
| |
| 288 gfx::RectF layer_content_rect = gfx::ScaleRect( | |
| 289 content_rect, | |
| 290 layer_content_scaleX / contents_scale_, | |
| 291 layer_content_scaleY / contents_scale_); | |
| 292 gfx::RectF screen_rect = MathUtil::mapClippedRect( | |
| 293 current_screen_transform, layer_content_rect); | |
| 294 gfx::RectF previous_rect = MathUtil::mapClippedRect( | |
| 295 last_screen_transform, layer_content_rect); | |
| 296 | |
| 297 TilePriority priority; | |
| 298 priority.resolution = HIGH_RESOLUTION; | |
| 299 priority.time_to_visible_in_seconds = | |
| 300 TilePriority::TimeForBoundsToIntersect( | |
| 301 previous_rect, screen_rect, time_delta, view_rect); | |
|
enne (OOO)
2012/12/03 19:57:28
Oh, interesting! So rather than caring about all
qinmin
2012/12/04 00:37:30
Yes, this is an efficient way to deal with the sca
| |
| 302 | |
| 303 priority.distance_to_visible_in_pixels = | |
| 304 TilePriority::manhattanDistance(screen_rect, view_rect); | |
| 305 // TODO(qinmin): pass the correct tree to this function. | |
| 306 TileAt(i, j)->set_priority(ACTIVE_TREE, priority); | |
| 307 } | |
| 308 } | |
| 309 } | |
| 310 | |
| 269 } // namespace cc | 311 } // namespace cc |
| OLD | NEW |