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

Side by Side Diff: cc/picture_layer_tiling.cc

Issue 12289021: cc: Only register live tiles with the TileManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comments, fix 80+char line 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 | « cc/picture_layer_tiling.h ('k') | cc/picture_layer_tiling_set_unittest.cc » ('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 "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "cc/math_util.h" 8 #include "cc/math_util.h"
9 #include "ui/gfx/point_conversions.h" 9 #include "ui/gfx/point_conversions.h"
10 #include "ui/gfx/rect_conversions.h" 10 #include "ui/gfx/rect_conversions.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 ++iter) { 410 ++iter) {
411 TileMap::iterator find = tiles_.find(iter.index()); 411 TileMap::iterator find = tiles_.find(iter.index());
412 if (find == tiles_.end()) 412 if (find == tiles_.end())
413 continue; 413 continue;
414 414
415 TilePriority priority; 415 TilePriority priority;
416 DCHECK(!priority.is_live); 416 DCHECK(!priority.is_live);
417 TileHandle* tile_handle = &find->second; 417 TileHandle* tile_handle = &find->second;
418 Tile* tile = tile_handle->tile(); 418 Tile* tile = tile_handle->tile();
419 tile->set_priority(tree, priority); 419 tile->set_priority(tree, priority);
420 tile_handle->UnregisterFromTileManager();
420 } 421 }
421 last_prioritized_rect_ = inflated_rect; 422 last_prioritized_rect_ = inflated_rect;
422 423
423 gfx::Rect view_rect(device_viewport); 424 gfx::Rect view_rect(device_viewport);
424 float current_scale = current_layer_contents_scale / contents_scale_; 425 float current_scale = current_layer_contents_scale / contents_scale_;
425 float last_scale = last_layer_contents_scale / contents_scale_; 426 float last_scale = last_layer_contents_scale / contents_scale_;
426 427
427 // Fast path tile priority calculation when both transforms are translations. 428 // Fast path tile priority calculation when both transforms are translations.
428 if (last_screen_transform.IsIdentityOrTranslation() && 429 if (last_screen_transform.IsIdentityOrTranslation() &&
429 current_screen_transform.IsIdentityOrTranslation()) 430 current_screen_transform.IsIdentityOrTranslation())
430 { 431 {
431 gfx::Vector2dF current_offset( 432 gfx::Vector2dF current_offset(
432 current_screen_transform.matrix().get(0, 3), 433 current_screen_transform.matrix().get(0, 3),
433 current_screen_transform.matrix().get(1, 3)); 434 current_screen_transform.matrix().get(1, 3));
434 gfx::Vector2dF last_offset( 435 gfx::Vector2dF last_offset(
435 last_screen_transform.matrix().get(0, 3), 436 last_screen_transform.matrix().get(0, 3),
436 last_screen_transform.matrix().get(1, 3)); 437 last_screen_transform.matrix().get(1, 3));
437 438
438 for (TilingData::Iterator iter(&tiling_data_, inflated_rect); 439 for (TilingData::Iterator iter(&tiling_data_, inflated_rect);
439 iter; ++iter) { 440 iter; ++iter) {
440 TileMap::iterator find = tiles_.find(iter.index()); 441 TileMap::iterator find = tiles_.find(iter.index());
441 if (find == tiles_.end()) 442 if (find == tiles_.end())
442 continue; 443 continue;
443 TileHandle* tile_handle = &find->second; 444 TileHandle* tile_handle = &find->second;
444 Tile* tile = tile_handle->tile(); 445 Tile* tile = tile_handle->tile();
446 tile_handle->RegisterWithTileManager();
445 447
446 gfx::Rect tile_bounds = 448 gfx::Rect tile_bounds =
447 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); 449 tiling_data_.TileBounds(iter.index_x(), iter.index_y());
448 gfx::RectF current_screen_rect = gfx::ScaleRect( 450 gfx::RectF current_screen_rect = gfx::ScaleRect(
449 tile_bounds, 451 tile_bounds,
450 current_scale, 452 current_scale,
451 current_scale) + current_offset; 453 current_scale) + current_offset;
452 gfx::RectF last_screen_rect = gfx::ScaleRect( 454 gfx::RectF last_screen_rect = gfx::ScaleRect(
453 tile_bounds, 455 tile_bounds,
454 last_scale, 456 last_scale,
(...skipping 14 matching lines...) Expand all
469 tile->set_priority(tree, priority); 471 tile->set_priority(tree, priority);
470 } 472 }
471 } else { 473 } else {
472 for (TilingData::Iterator iter(&tiling_data_, inflated_rect); 474 for (TilingData::Iterator iter(&tiling_data_, inflated_rect);
473 iter; ++iter) { 475 iter; ++iter) {
474 TileMap::iterator find = tiles_.find(iter.index()); 476 TileMap::iterator find = tiles_.find(iter.index());
475 if (find == tiles_.end()) 477 if (find == tiles_.end())
476 continue; 478 continue;
477 TileHandle* tile_handle = &find->second; 479 TileHandle* tile_handle = &find->second;
478 Tile* tile = tile_handle->tile(); 480 Tile* tile = tile_handle->tile();
481 tile_handle->RegisterWithTileManager();
479 482
480 gfx::Rect tile_bounds = 483 gfx::Rect tile_bounds =
481 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); 484 tiling_data_.TileBounds(iter.index_x(), iter.index_y());
482 gfx::RectF current_layer_content_rect = gfx::ScaleRect( 485 gfx::RectF current_layer_content_rect = gfx::ScaleRect(
483 tile_bounds, 486 tile_bounds,
484 current_scale, 487 current_scale,
485 current_scale); 488 current_scale);
486 gfx::RectF current_screen_rect = MathUtil::mapClippedRect( 489 gfx::RectF current_screen_rect = MathUtil::mapClippedRect(
487 current_screen_transform, current_layer_content_rect); 490 current_screen_transform, current_layer_content_rect);
488 gfx::RectF last_layer_content_rect = gfx::ScaleRect( 491 gfx::RectF last_layer_content_rect = gfx::ScaleRect(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 539
537 scoped_ptr<base::Value> PictureLayerTiling::AsValue() const { 540 scoped_ptr<base::Value> PictureLayerTiling::AsValue() const {
538 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 541 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
539 state->SetInteger("num_tiles", tiles_.size()); 542 state->SetInteger("num_tiles", tiles_.size());
540 state->SetDouble("content_scale", contents_scale_); 543 state->SetDouble("content_scale", contents_scale_);
541 state->Set("content_bounds", 544 state->Set("content_bounds",
542 MathUtil::asValue(ContentRect().size()).release()); 545 MathUtil::asValue(ContentRect().size()).release());
543 return state.PassAs<base::Value>(); 546 return state.PassAs<base::Value>();
544 } 547 }
545 548
546 TileHandle::TileHandle(scoped_refptr<Tile> tile) 549 TileHandle::TileHandle(scoped_refptr<Tile> tile) : tile_(tile) {
547 : tile_(tile), 550 }
548 managed_tile_state_(tile_->tile_manager()->RegisterTile(tile_)) { 551
552 void TileHandle::RegisterWithTileManager() {
553 if (managed_tile_state_.get())
554 return;
555 managed_tile_state_ = tile_->tile_manager()->RegisterTile(tile_);
556 }
557
558 void TileHandle::UnregisterFromTileManager() {
559 managed_tile_state_ = NULL;
549 } 560 }
550 561
551 } // namespace cc 562 } // namespace cc
OLDNEW
« no previous file with comments | « cc/picture_layer_tiling.h ('k') | cc/picture_layer_tiling_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698