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

Side by Side Diff: cc/picture_layer_tiling.cc

Issue 12084031: A host of micro-optimizations and a refactor of TimeForBoundsToIntersect (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months 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 | « no previous file | cc/tile.h » ('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/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
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 float last_layer_contents_scale, 274 float last_layer_contents_scale,
275 float current_layer_contents_scale, 275 float current_layer_contents_scale,
276 const gfx::Transform& last_screen_transform, 276 const gfx::Transform& last_screen_transform,
277 const gfx::Transform& current_screen_transform, 277 const gfx::Transform& current_screen_transform,
278 double time_delta) { 278 double time_delta) {
279 gfx::Rect content_rect = ContentRect(); 279 gfx::Rect content_rect = ContentRect();
280 if (content_rect.IsEmpty()) 280 if (content_rect.IsEmpty())
281 return; 281 return;
282 282
283 gfx::Rect view_rect(gfx::Point(), device_viewport); 283 gfx::Rect view_rect(gfx::Point(), device_viewport);
284 int right = tiling_data_.TileXIndexFromSrcCoord(content_rect.width() - 1); 284 float current_scale = current_layer_contents_scale / contents_scale_;
285 int bottom = tiling_data_.TileYIndexFromSrcCoord(content_rect.height() - 1); 285 float last_scale = last_layer_contents_scale / contents_scale_;
286 286
287 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { 287 if (last_screen_transform.IsIdentityOrTranslation() &&
288 TileMapKey key = it->first; 288 current_screen_transform.IsIdentityOrTranslation())
289 TilePriority priority; 289 {
290 priority.resolution = resolution_; 290 gfx::Vector2dF current_offset(
291 if (key.first > right || key.second > bottom) { 291 current_screen_transform.matrix().get(0, 3),
292 priority.distance_to_visible_in_pixels = std::numeric_limits<int>::max(); 292 current_screen_transform.matrix().get(1, 3));
293 gfx::Vector2dF last_offset(
294 last_screen_transform.matrix().get(0, 3),
295 last_screen_transform.matrix().get(1, 3));
296
297 for (TileMap::const_iterator it = tiles_.begin();
enne (OOO) 2013/01/28 22:55:10 This was already applied in your last UpdateTilePr
298 it != tiles_.end(); ++it) {
299 TileMapKey key = it->first;
300 TilePriority priority;
301 priority.resolution = resolution_;
302
303 gfx::Rect tile_bound = tiling_data_.TileBounds(key.first, key.second);
304 gfx::RectF current_screen_rect = gfx::ScaleRect(
305 tile_bound,
306 current_scale,
307 current_scale) + current_offset;
308 gfx::RectF last_screen_rect = gfx::ScaleRect(
309 tile_bound,
310 last_scale,
311 last_scale) + last_offset;
312
313 priority.distance_to_visible_in_pixels =
314 TilePriority::manhattanDistance(current_screen_rect, view_rect);
315
293 priority.time_to_visible_in_seconds = 316 priority.time_to_visible_in_seconds =
294 TilePriority::kMaxTimeToVisibleInSeconds; 317 TilePriority::TimeForBoundsToIntersect(
318 last_screen_rect, current_screen_rect, time_delta, view_rect);
295 it->second->set_priority(tree, priority); 319 it->second->set_priority(tree, priority);
296 continue;
297 } 320 }
321 }
322 else
323 {
324 for (TileMap::const_iterator it = tiles_.begin();
325 it != tiles_.end(); ++it) {
326 TileMapKey key = it->first;
327 TilePriority priority;
328 priority.resolution = resolution_;
298 329
299 gfx::Rect tile_bound = tiling_data_.TileBounds(key.first, key.second); 330 gfx::Rect tile_bound = tiling_data_.TileBounds(key.first, key.second);
300 gfx::RectF current_layer_content_rect = gfx::ScaleRect( 331 gfx::RectF current_layer_content_rect = gfx::ScaleRect(
301 tile_bound, 332 tile_bound,
302 current_layer_contents_scale / contents_scale_, 333 current_scale,
303 current_layer_contents_scale / contents_scale_); 334 current_scale);
304 gfx::RectF current_screen_rect = MathUtil::mapClippedRect( 335 gfx::RectF current_screen_rect = MathUtil::mapClippedRect(
305 current_screen_transform, current_layer_content_rect); 336 current_screen_transform, current_layer_content_rect);
306 gfx::RectF last_layer_content_rect = gfx::ScaleRect( 337 gfx::RectF last_layer_content_rect = gfx::ScaleRect(
307 tile_bound, 338 tile_bound,
308 last_layer_contents_scale / contents_scale_, 339 last_scale,
309 last_layer_contents_scale / contents_scale_); 340 last_scale);
310 gfx::RectF last_screen_rect = MathUtil::mapClippedRect( 341 gfx::RectF last_screen_rect = MathUtil::mapClippedRect(
311 last_screen_transform, last_layer_content_rect); 342 last_screen_transform, last_layer_content_rect);
312 343
313 priority.time_to_visible_in_seconds = 344 priority.time_to_visible_in_seconds =
314 TilePriority::TimeForBoundsToIntersect( 345 TilePriority::TimeForBoundsToIntersect(
315 last_screen_rect, current_screen_rect, time_delta, view_rect); 346 last_screen_rect, current_screen_rect, time_delta, view_rect);
316 347
317 priority.distance_to_visible_in_pixels = 348 priority.distance_to_visible_in_pixels =
318 TilePriority::manhattanDistance(current_screen_rect, view_rect); 349 TilePriority::manhattanDistance(current_screen_rect, view_rect);
319 it->second->set_priority(tree, priority); 350 it->second->set_priority(tree, priority);
351 }
320 } 352 }
321 } 353 }
322 354
323 void PictureLayerTiling::DidBecomeActive() { 355 void PictureLayerTiling::DidBecomeActive() {
324 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { 356 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
325 it->second->set_priority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); 357 it->second->set_priority(ACTIVE_TREE, it->second->priority(PENDING_TREE));
326 it->second->set_priority(PENDING_TREE, TilePriority()); 358 it->second->set_priority(PENDING_TREE, TilePriority());
327 359
328 // Tile holds a ref onto a picture pile. If the tile never gets invalidated 360 // Tile holds a ref onto a picture pile. If the tile never gets invalidated
329 // and recreated, then that picture pile ref could exist indefinitely. To 361 // and recreated, then that picture pile ref could exist indefinitely. To
330 // prevent this, ask the client to update the pile to its own ref. This 362 // prevent this, ask the client to update the pile to its own ref. This
331 // will cause PicturePileImpls and their clones to get deleted once the 363 // will cause PicturePileImpls and their clones to get deleted once the
332 // corresponding PictureLayerImpl and any in flight raster jobs go out of 364 // corresponding PictureLayerImpl and any in flight raster jobs go out of
333 // scope. 365 // scope.
334 client_->UpdatePile(it->second); 366 client_->UpdatePile(it->second);
335 } 367 }
336 } 368 }
337 369
338 } // namespace cc 370 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/tile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698