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 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 private: | 53 private: |
54 TreePriority tree_priority_; | 54 TreePriority tree_priority_; |
55 }; | 55 }; |
56 | 56 |
57 } // namespace | 57 } // namespace |
58 | 58 |
59 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( | 59 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( |
60 float contents_scale, | 60 float contents_scale, |
61 const gfx::Size& layer_bounds, | 61 const gfx::Size& layer_bounds, |
62 PictureLayerTilingClient* client) { | 62 PictureLayerTilingClient* client, |
63 return make_scoped_ptr(new PictureLayerTiling(contents_scale, | 63 size_t max_tiles_for_interest_area, |
64 layer_bounds, | 64 float skewport_target_time_in_seconds, |
65 client)); | 65 int skewport_extrapolation_limit_in_content_pixels) { |
| 66 return make_scoped_ptr(new PictureLayerTiling( |
| 67 contents_scale, layer_bounds, client, max_tiles_for_interest_area, |
| 68 skewport_target_time_in_seconds, |
| 69 skewport_extrapolation_limit_in_content_pixels)); |
66 } | 70 } |
67 | 71 |
68 PictureLayerTiling::PictureLayerTiling(float contents_scale, | 72 PictureLayerTiling::PictureLayerTiling( |
69 const gfx::Size& layer_bounds, | 73 float contents_scale, |
70 PictureLayerTilingClient* client) | 74 const gfx::Size& layer_bounds, |
71 : contents_scale_(contents_scale), | 75 PictureLayerTilingClient* client, |
| 76 size_t max_tiles_for_interest_area, |
| 77 float skewport_target_time_in_seconds, |
| 78 int skewport_extrapolation_limit_in_content_pixels) |
| 79 : max_tiles_for_interest_area_(max_tiles_for_interest_area), |
| 80 skewport_target_time_in_seconds_(skewport_target_time_in_seconds), |
| 81 skewport_extrapolation_limit_in_content_pixels_( |
| 82 skewport_extrapolation_limit_in_content_pixels), |
| 83 contents_scale_(contents_scale), |
72 layer_bounds_(layer_bounds), | 84 layer_bounds_(layer_bounds), |
73 resolution_(NON_IDEAL_RESOLUTION), | 85 resolution_(NON_IDEAL_RESOLUTION), |
74 client_(client), | 86 client_(client), |
75 tiling_data_(gfx::Size(), gfx::Size(), kBorderTexels), | 87 tiling_data_(gfx::Size(), gfx::Size(), kBorderTexels), |
76 last_impl_frame_time_in_seconds_(0.0), | 88 last_impl_frame_time_in_seconds_(0.0), |
77 can_require_tiles_for_activation_(false), | 89 can_require_tiles_for_activation_(false), |
78 current_content_to_screen_scale_(0.f), | 90 current_content_to_screen_scale_(0.f), |
79 has_visible_rect_tiles_(false), | 91 has_visible_rect_tiles_(false), |
80 has_skewport_rect_tiles_(false), | 92 has_skewport_rect_tiles_(false), |
81 has_soon_border_rect_tiles_(false), | 93 has_soon_border_rect_tiles_(false), |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 const gfx::Rect& visible_rect_in_content_space) const { | 546 const gfx::Rect& visible_rect_in_content_space) const { |
535 gfx::Rect skewport = visible_rect_in_content_space; | 547 gfx::Rect skewport = visible_rect_in_content_space; |
536 if (last_impl_frame_time_in_seconds_ == 0.0) | 548 if (last_impl_frame_time_in_seconds_ == 0.0) |
537 return skewport; | 549 return skewport; |
538 | 550 |
539 double time_delta = | 551 double time_delta = |
540 current_frame_time_in_seconds - last_impl_frame_time_in_seconds_; | 552 current_frame_time_in_seconds - last_impl_frame_time_in_seconds_; |
541 if (time_delta == 0.0) | 553 if (time_delta == 0.0) |
542 return skewport; | 554 return skewport; |
543 | 555 |
544 float skewport_target_time_in_seconds = | |
545 client_->GetSkewportTargetTimeInSeconds(); | |
546 double extrapolation_multiplier = | 556 double extrapolation_multiplier = |
547 skewport_target_time_in_seconds / time_delta; | 557 skewport_target_time_in_seconds_ / time_delta; |
548 | 558 |
549 int old_x = last_visible_rect_in_content_space_.x(); | 559 int old_x = last_visible_rect_in_content_space_.x(); |
550 int old_y = last_visible_rect_in_content_space_.y(); | 560 int old_y = last_visible_rect_in_content_space_.y(); |
551 int old_right = last_visible_rect_in_content_space_.right(); | 561 int old_right = last_visible_rect_in_content_space_.right(); |
552 int old_bottom = last_visible_rect_in_content_space_.bottom(); | 562 int old_bottom = last_visible_rect_in_content_space_.bottom(); |
553 | 563 |
554 int new_x = visible_rect_in_content_space.x(); | 564 int new_x = visible_rect_in_content_space.x(); |
555 int new_y = visible_rect_in_content_space.y(); | 565 int new_y = visible_rect_in_content_space.y(); |
556 int new_right = visible_rect_in_content_space.right(); | 566 int new_right = visible_rect_in_content_space.right(); |
557 int new_bottom = visible_rect_in_content_space.bottom(); | 567 int new_bottom = visible_rect_in_content_space.bottom(); |
558 | 568 |
559 int skewport_limit = client_->GetSkewportExtrapolationLimitInContentPixels(); | 569 // Compute the maximum skewport based on |
560 | 570 // |skewport_extrapolation_limit_in_content_pixels_|. |
561 // Compute the maximum skewport based on |skewport_limit|. | |
562 gfx::Rect max_skewport = skewport; | 571 gfx::Rect max_skewport = skewport; |
563 max_skewport.Inset( | 572 max_skewport.Inset(-skewport_extrapolation_limit_in_content_pixels_, |
564 -skewport_limit, -skewport_limit, -skewport_limit, -skewport_limit); | 573 -skewport_extrapolation_limit_in_content_pixels_); |
565 | 574 |
566 // Inset the skewport by the needed adjustment. | 575 // Inset the skewport by the needed adjustment. |
567 skewport.Inset(extrapolation_multiplier * (new_x - old_x), | 576 skewport.Inset(extrapolation_multiplier * (new_x - old_x), |
568 extrapolation_multiplier * (new_y - old_y), | 577 extrapolation_multiplier * (new_y - old_y), |
569 extrapolation_multiplier * (old_right - new_right), | 578 extrapolation_multiplier * (old_right - new_right), |
570 extrapolation_multiplier * (old_bottom - new_bottom)); | 579 extrapolation_multiplier * (old_bottom - new_bottom)); |
571 | 580 |
572 // Clip the skewport to |max_skewport|. | 581 // Clip the skewport to |max_skewport|. |
573 skewport.Intersect(max_skewport); | 582 skewport.Intersect(max_skewport); |
574 | 583 |
(...skipping 23 matching lines...) Expand all Loading... |
598 last_visible_rect_in_content_space_ = visible_rect_in_content_space; | 607 last_visible_rect_in_content_space_ = visible_rect_in_content_space; |
599 return; | 608 return; |
600 } | 609 } |
601 | 610 |
602 // Calculate the skewport. | 611 // Calculate the skewport. |
603 gfx::Rect skewport = ComputeSkewport(current_frame_time_in_seconds, | 612 gfx::Rect skewport = ComputeSkewport(current_frame_time_in_seconds, |
604 visible_rect_in_content_space); | 613 visible_rect_in_content_space); |
605 DCHECK(skewport.Contains(visible_rect_in_content_space)); | 614 DCHECK(skewport.Contains(visible_rect_in_content_space)); |
606 | 615 |
607 // Calculate the eventually/live tiles rect. | 616 // Calculate the eventually/live tiles rect. |
608 size_t max_tiles_for_interest_area = client_->GetMaxTilesForInterestArea(); | |
609 | |
610 gfx::Size tile_size = tiling_data_.max_texture_size(); | 617 gfx::Size tile_size = tiling_data_.max_texture_size(); |
611 int64 eventually_rect_area = | 618 int64 eventually_rect_area = |
612 max_tiles_for_interest_area * tile_size.width() * tile_size.height(); | 619 max_tiles_for_interest_area_ * tile_size.width() * tile_size.height(); |
613 | 620 |
614 gfx::Rect eventually_rect = | 621 gfx::Rect eventually_rect = |
615 ExpandRectEquallyToAreaBoundedBy(visible_rect_in_content_space, | 622 ExpandRectEquallyToAreaBoundedBy(visible_rect_in_content_space, |
616 eventually_rect_area, | 623 eventually_rect_area, |
617 gfx::Rect(tiling_size()), | 624 gfx::Rect(tiling_size()), |
618 &expansion_cache_); | 625 &expansion_cache_); |
619 | 626 |
620 DCHECK(eventually_rect.IsEmpty() || | 627 DCHECK(eventually_rect.IsEmpty() || |
621 gfx::Rect(tiling_size()).Contains(eventually_rect)) | 628 gfx::Rect(tiling_size()).Contains(eventually_rect)) |
622 << "tiling_size: " << tiling_size().ToString() | 629 << "tiling_size: " << tiling_size().ToString() |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 } | 1267 } |
1261 current_tile_ = tiling_->TileAt(next_index.first, next_index.second); | 1268 current_tile_ = tiling_->TileAt(next_index.first, next_index.second); |
1262 } | 1269 } |
1263 | 1270 |
1264 if (current_tile_) | 1271 if (current_tile_) |
1265 tiling_->UpdateTileAndTwinPriority(current_tile_); | 1272 tiling_->UpdateTileAndTwinPriority(current_tile_); |
1266 return *this; | 1273 return *this; |
1267 } | 1274 } |
1268 | 1275 |
1269 } // namespace cc | 1276 } // namespace cc |
OLD | NEW |