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/tiles/picture_layer_tiling.h" | 5 #include "cc/tiles/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 20 matching lines...) Expand all Loading... |
31 const float kSoonBorderDistanceViewportPercentage = 0.15f; | 31 const float kSoonBorderDistanceViewportPercentage = 0.15f; |
32 const float kMaxSoonBorderDistanceInScreenPixels = 312.f; | 32 const float kMaxSoonBorderDistanceInScreenPixels = 312.f; |
33 | 33 |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( | 36 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( |
37 WhichTree tree, | 37 WhichTree tree, |
38 float contents_scale, | 38 float contents_scale, |
39 scoped_refptr<RasterSource> raster_source, | 39 scoped_refptr<RasterSource> raster_source, |
40 PictureLayerTilingClient* client, | 40 PictureLayerTilingClient* client, |
41 float tiling_interest_area_viewport_multiplier, | 41 size_t max_tiles_for_interest_area, |
42 float skewport_target_time_in_seconds, | 42 float skewport_target_time_in_seconds, |
43 int skewport_extrapolation_limit_in_content_pixels) { | 43 int skewport_extrapolation_limit_in_content_pixels) { |
44 return make_scoped_ptr(new PictureLayerTiling( | 44 return make_scoped_ptr(new PictureLayerTiling( |
45 tree, contents_scale, raster_source, client, | 45 tree, contents_scale, raster_source, client, max_tiles_for_interest_area, |
46 tiling_interest_area_viewport_multiplier, skewport_target_time_in_seconds, | 46 skewport_target_time_in_seconds, |
47 skewport_extrapolation_limit_in_content_pixels)); | 47 skewport_extrapolation_limit_in_content_pixels)); |
48 } | 48 } |
49 | 49 |
50 PictureLayerTiling::PictureLayerTiling( | 50 PictureLayerTiling::PictureLayerTiling( |
51 WhichTree tree, | 51 WhichTree tree, |
52 float contents_scale, | 52 float contents_scale, |
53 scoped_refptr<RasterSource> raster_source, | 53 scoped_refptr<RasterSource> raster_source, |
54 PictureLayerTilingClient* client, | 54 PictureLayerTilingClient* client, |
55 float tiling_interest_area_viewport_multiplier, | 55 size_t max_tiles_for_interest_area, |
56 float skewport_target_time_in_seconds, | 56 float skewport_target_time_in_seconds, |
57 int skewport_extrapolation_limit_in_content_pixels) | 57 int skewport_extrapolation_limit_in_content_pixels) |
58 : tiling_interest_area_viewport_multiplier_( | 58 : max_tiles_for_interest_area_(max_tiles_for_interest_area), |
59 tiling_interest_area_viewport_multiplier), | |
60 skewport_target_time_in_seconds_(skewport_target_time_in_seconds), | 59 skewport_target_time_in_seconds_(skewport_target_time_in_seconds), |
61 skewport_extrapolation_limit_in_content_pixels_( | 60 skewport_extrapolation_limit_in_content_pixels_( |
62 skewport_extrapolation_limit_in_content_pixels), | 61 skewport_extrapolation_limit_in_content_pixels), |
63 contents_scale_(contents_scale), | 62 contents_scale_(contents_scale), |
64 client_(client), | 63 client_(client), |
65 tree_(tree), | 64 tree_(tree), |
66 raster_source_(raster_source), | 65 raster_source_(raster_source), |
67 resolution_(NON_IDEAL_RESOLUTION), | 66 resolution_(NON_IDEAL_RESOLUTION), |
68 tiling_data_(gfx::Size(), gfx::Size(), kBorderTexels), | 67 tiling_data_(gfx::Size(), gfx::Size(), kBorderTexels), |
69 can_require_tiles_for_activation_(false), | 68 can_require_tiles_for_activation_(false), |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 current_occlusion_in_layer_space_.HasOcclusion()) { | 602 current_occlusion_in_layer_space_.HasOcclusion()) { |
604 set_all_tiles_done(false); | 603 set_all_tiles_done(false); |
605 } | 604 } |
606 | 605 |
607 if (!NeedsUpdateForFrameAtTimeAndViewport(current_frame_time_in_seconds, | 606 if (!NeedsUpdateForFrameAtTimeAndViewport(current_frame_time_in_seconds, |
608 viewport_in_layer_space)) { | 607 viewport_in_layer_space)) { |
609 // This should never be zero for the purposes of has_ever_been_updated(). | 608 // This should never be zero for the purposes of has_ever_been_updated(). |
610 DCHECK_NE(current_frame_time_in_seconds, 0.0); | 609 DCHECK_NE(current_frame_time_in_seconds, 0.0); |
611 return false; | 610 return false; |
612 } | 611 } |
| 612 |
613 gfx::Rect visible_rect_in_content_space = | 613 gfx::Rect visible_rect_in_content_space = |
614 gfx::ScaleToEnclosingRect(viewport_in_layer_space, contents_scale_); | 614 gfx::ScaleToEnclosingRect(viewport_in_layer_space, contents_scale_); |
615 | 615 |
616 if (tiling_size().IsEmpty()) { | 616 if (tiling_size().IsEmpty()) { |
617 UpdateVisibleRectHistory(current_frame_time_in_seconds, | 617 UpdateVisibleRectHistory(current_frame_time_in_seconds, |
618 visible_rect_in_content_space); | 618 visible_rect_in_content_space); |
619 last_viewport_in_layer_space_ = viewport_in_layer_space; | 619 last_viewport_in_layer_space_ = viewport_in_layer_space; |
620 return false; | 620 return false; |
621 } | 621 } |
622 | 622 |
623 // Calculate the skewport. | 623 // Calculate the skewport. |
624 gfx::Rect skewport = ComputeSkewport(current_frame_time_in_seconds, | 624 gfx::Rect skewport = ComputeSkewport(current_frame_time_in_seconds, |
625 visible_rect_in_content_space); | 625 visible_rect_in_content_space); |
626 DCHECK(skewport.Contains(visible_rect_in_content_space)); | 626 DCHECK(skewport.Contains(visible_rect_in_content_space)); |
627 | 627 |
628 // Calculate the eventually/live tiles rect. | 628 // Calculate the eventually/live tiles rect. |
629 int64 eventually_rect_area = tiling_interest_area_viewport_multiplier_ * | 629 gfx::Size tile_size = tiling_data_.max_texture_size(); |
630 visible_rect_in_content_space.width() * | 630 int64 eventually_rect_area = |
631 visible_rect_in_content_space.height(); | 631 max_tiles_for_interest_area_ * tile_size.width() * tile_size.height(); |
632 | 632 |
633 gfx::Rect eventually_rect = | 633 gfx::Rect eventually_rect = |
634 ExpandRectEquallyToAreaBoundedBy(visible_rect_in_content_space, | 634 ExpandRectEquallyToAreaBoundedBy(visible_rect_in_content_space, |
635 eventually_rect_area, | 635 eventually_rect_area, |
636 gfx::Rect(tiling_size()), | 636 gfx::Rect(tiling_size()), |
637 &expansion_cache_); | 637 &expansion_cache_); |
638 | 638 |
639 DCHECK(eventually_rect.IsEmpty() || | 639 DCHECK(eventually_rect.IsEmpty() || |
640 gfx::Rect(tiling_size()).Contains(eventually_rect)) | 640 gfx::Rect(tiling_size()).Contains(eventually_rect)) |
641 << "tiling_size: " << tiling_size().ToString() | 641 << "tiling_size: " << tiling_size().ToString() |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 break; | 1112 break; |
1113 } | 1113 } |
1114 | 1114 |
1115 gfx::Rect result(origin_x, origin_y, width, height); | 1115 gfx::Rect result(origin_x, origin_y, width, height); |
1116 if (cache) | 1116 if (cache) |
1117 cache->previous_result = result; | 1117 cache->previous_result = result; |
1118 return result; | 1118 return result; |
1119 } | 1119 } |
1120 | 1120 |
1121 } // namespace cc | 1121 } // namespace cc |
OLD | NEW |