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/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 } | 335 } |
336 | 336 |
337 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const { | 337 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const { |
338 return tiling_->tiling_data_.max_texture_size(); | 338 return tiling_->tiling_data_.max_texture_size(); |
339 } | 339 } |
340 | 340 |
341 void PictureLayerTiling::UpdateTilePriorities( | 341 void PictureLayerTiling::UpdateTilePriorities( |
342 WhichTree tree, | 342 WhichTree tree, |
343 gfx::Size device_viewport, | 343 gfx::Size device_viewport, |
344 const gfx::RectF& viewport_in_layer_space, | 344 const gfx::RectF& viewport_in_layer_space, |
345 const gfx::RectF& visible_layer_rect, | |
345 gfx::Size last_layer_bounds, | 346 gfx::Size last_layer_bounds, |
346 gfx::Size current_layer_bounds, | 347 gfx::Size current_layer_bounds, |
347 float last_layer_contents_scale, | 348 float last_layer_contents_scale, |
348 float current_layer_contents_scale, | 349 float current_layer_contents_scale, |
349 const gfx::Transform& last_screen_transform, | 350 const gfx::Transform& last_screen_transform, |
350 const gfx::Transform& current_screen_transform, | 351 const gfx::Transform& current_screen_transform, |
351 int current_source_frame_number, | 352 int current_source_frame_number, |
352 double current_frame_time, | 353 double current_frame_time, |
353 bool store_screen_space_quads_on_tiles, | 354 bool store_screen_space_quads_on_tiles, |
354 size_t max_tiles_for_interest_area) { | 355 size_t max_tiles_for_interest_area) { |
(...skipping 16 matching lines...) Expand all Loading... | |
371 if (!first_update_in_new_impl_frame && !first_update_in_new_source_frame) | 372 if (!first_update_in_new_impl_frame && !first_update_in_new_source_frame) |
372 return; | 373 return; |
373 | 374 |
374 double time_delta = 0; | 375 double time_delta = 0; |
375 if (last_impl_frame_time_ != 0 && last_layer_bounds == current_layer_bounds) | 376 if (last_impl_frame_time_ != 0 && last_layer_bounds == current_layer_bounds) |
376 time_delta = current_frame_time - last_impl_frame_time_; | 377 time_delta = current_frame_time - last_impl_frame_time_; |
377 | 378 |
378 gfx::Rect viewport_in_content_space = | 379 gfx::Rect viewport_in_content_space = |
379 gfx::ToEnclosingRect(gfx::ScaleRect(viewport_in_layer_space, | 380 gfx::ToEnclosingRect(gfx::ScaleRect(viewport_in_layer_space, |
380 contents_scale_)); | 381 contents_scale_)); |
382 gfx::Rect visible_content_rect = | |
383 gfx::ToEnclosingRect(gfx::ScaleRect(visible_layer_rect, | |
384 contents_scale_)); | |
381 | 385 |
382 gfx::Size tile_size = tiling_data_.max_texture_size(); | 386 gfx::Size tile_size = tiling_data_.max_texture_size(); |
383 int64 prioritized_rect_area = | 387 int64 prioritized_rect_area = |
384 max_tiles_for_interest_area * | 388 max_tiles_for_interest_area * |
385 tile_size.width() * tile_size.height(); | 389 tile_size.width() * tile_size.height(); |
386 | 390 |
391 gfx::Rect starting_rect = visible_content_rect.IsEmpty() | |
392 ? viewport_in_content_space | |
393 : visible_content_rect; | |
387 gfx::Rect prioritized_rect = ExpandRectEquallyToAreaBoundedBy( | 394 gfx::Rect prioritized_rect = ExpandRectEquallyToAreaBoundedBy( |
388 viewport_in_content_space, | 395 starting_rect, |
389 prioritized_rect_area, | 396 prioritized_rect_area, |
390 ContentRect()); | 397 ContentRect()); |
391 DCHECK(ContentRect().Contains(prioritized_rect)); | 398 DCHECK(ContentRect().Contains(prioritized_rect)); |
392 | 399 |
393 // Iterate through all of the tiles that were live last frame but will | 400 // Iterate through all of the tiles that were live last frame but will |
394 // not be live this frame, and mark them as being dead. | 401 // not be live this frame, and mark them as being dead. |
395 for (TilingData::DifferenceIterator iter(&tiling_data_, | 402 for (TilingData::DifferenceIterator iter(&tiling_data_, |
396 last_prioritized_rect_, | 403 last_prioritized_rect_, |
397 prioritized_rect); | 404 prioritized_rect); |
398 iter; | 405 iter; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
558 gfx::Rect PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( | 565 gfx::Rect PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
559 gfx::Rect starting_rect, | 566 gfx::Rect starting_rect, |
560 int64 target_area, | 567 int64 target_area, |
561 gfx::Rect bounding_rect) { | 568 gfx::Rect bounding_rect) { |
562 if (starting_rect.IsEmpty()) | 569 if (starting_rect.IsEmpty()) |
563 return starting_rect; | 570 return starting_rect; |
564 | 571 |
565 DCHECK(!bounding_rect.IsEmpty()); | 572 DCHECK(!bounding_rect.IsEmpty()); |
566 DCHECK_GT(target_area, 0); | 573 DCHECK_GT(target_area, 0); |
567 | 574 |
568 // Expand the starting rect to cover target_area. | 575 // Expand the starting rect to cover target_area, if it is smaller than it. |
569 int delta = ComputeExpansionDelta( | 576 int delta = ComputeExpansionDelta( |
570 2, 2, starting_rect.width(), starting_rect.height(), target_area); | 577 2, 2, starting_rect.width(), starting_rect.height(), target_area); |
571 gfx::Rect expanded_starting_rect = starting_rect; | 578 gfx::Rect expanded_starting_rect = starting_rect; |
572 expanded_starting_rect.Inset(-delta, -delta); | 579 if (delta > 0) |
580 expanded_starting_rect.Inset(-delta, -delta); | |
573 | 581 |
574 gfx::Rect rect = IntersectRects(expanded_starting_rect, bounding_rect); | 582 gfx::Rect rect = IntersectRects(expanded_starting_rect, bounding_rect); |
575 if (rect.IsEmpty()) { | 583 if (rect.IsEmpty()) { |
576 // The starting_rect and bounding_rect are far away. | 584 // The starting_rect and bounding_rect are far away. |
577 return rect; | 585 return rect; |
578 } | 586 } |
579 if (rect == expanded_starting_rect) { | |
580 // The expanded starting rect already covers target_area on bounding_rect. | |
581 return rect; | |
582 } | |
Xianzhu
2013/04/16 22:42:52
I think we can still keep this shortcut by adding
danakj
2013/04/17 01:13:34
PictureLayerTilingIteratorTest.TilesExistLargeView
| |
583 | 587 |
584 // Continue to expand rect to let it cover target_area. | 588 // Continue to expand rect to let it cover target_area. |
585 | 589 |
586 // These values will be updated by the loop and uses as the output. | 590 // These values will be updated by the loop and uses as the output. |
587 int origin_x = rect.x(); | 591 int origin_x = rect.x(); |
588 int origin_y = rect.y(); | 592 int origin_y = rect.y(); |
589 int width = rect.width(); | 593 int width = rect.width(); |
590 int height = rect.height(); | 594 int height = rect.height(); |
591 | 595 |
592 // In the beginning we will consider 2 edges in each dimension. | 596 // In the beginning we will consider 2 edges in each dimension. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
651 | 655 |
652 // If our delta is less then our event distance, we're done. | 656 // If our delta is less then our event distance, we're done. |
653 if (delta < event.distance) | 657 if (delta < event.distance) |
654 break; | 658 break; |
655 } | 659 } |
656 | 660 |
657 return gfx::Rect(origin_x, origin_y, width, height); | 661 return gfx::Rect(origin_x, origin_y, width, height); |
658 } | 662 } |
659 | 663 |
660 } // namespace cc | 664 } // namespace cc |
OLD | NEW |