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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
11 #include <limits> | 11 #include <limits> |
12 #include <set> | 12 #include <set> |
13 | 13 |
14 #include "base/containers/small_map.h" | 14 #include "base/containers/small_map.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/numerics/safe_conversions.h" | 16 #include "base/numerics/safe_conversions.h" |
17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
18 #include "base/trace_event/trace_event_argument.h" | 18 #include "base/trace_event/trace_event_argument.h" |
19 #include "cc/base/math_util.h" | 19 #include "cc/base/math_util.h" |
20 #include "cc/playback/display_list_raster_source.h" | 20 #include "cc/playback/raster_source.h" |
21 #include "cc/tiles/prioritized_tile.h" | 21 #include "cc/tiles/prioritized_tile.h" |
22 #include "cc/tiles/tile.h" | 22 #include "cc/tiles/tile.h" |
23 #include "cc/tiles/tile_priority.h" | 23 #include "cc/tiles/tile_priority.h" |
24 #include "ui/gfx/geometry/point_conversions.h" | 24 #include "ui/gfx/geometry/point_conversions.h" |
25 #include "ui/gfx/geometry/rect_conversions.h" | 25 #include "ui/gfx/geometry/rect_conversions.h" |
26 #include "ui/gfx/geometry/rect_f.h" | 26 #include "ui/gfx/geometry/rect_f.h" |
27 #include "ui/gfx/geometry/safe_integer_conversions.h" | 27 #include "ui/gfx/geometry/safe_integer_conversions.h" |
28 #include "ui/gfx/geometry/size_conversions.h" | 28 #include "ui/gfx/geometry/size_conversions.h" |
29 | 29 |
30 namespace cc { | 30 namespace cc { |
31 namespace { | 31 namespace { |
32 | 32 |
33 const float kSoonBorderDistanceViewportPercentage = 0.15f; | 33 const float kSoonBorderDistanceViewportPercentage = 0.15f; |
34 const float kMaxSoonBorderDistanceInScreenPixels = 312.f; | 34 const float kMaxSoonBorderDistanceInScreenPixels = 312.f; |
35 | 35 |
36 } // namespace | 36 } // namespace |
37 | 37 |
38 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( | 38 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( |
39 WhichTree tree, | 39 WhichTree tree, |
40 float contents_scale, | 40 float contents_scale, |
41 scoped_refptr<DisplayListRasterSource> raster_source, | 41 scoped_refptr<RasterSource> raster_source, |
42 PictureLayerTilingClient* client, | 42 PictureLayerTilingClient* client, |
43 size_t tiling_interest_area_padding, | 43 size_t tiling_interest_area_padding, |
44 float skewport_target_time_in_seconds, | 44 float skewport_target_time_in_seconds, |
45 int skewport_extrapolation_limit_in_content_pixels) { | 45 int skewport_extrapolation_limit_in_content_pixels) { |
46 return make_scoped_ptr(new PictureLayerTiling( | 46 return make_scoped_ptr(new PictureLayerTiling( |
47 tree, contents_scale, raster_source, client, tiling_interest_area_padding, | 47 tree, contents_scale, raster_source, client, tiling_interest_area_padding, |
48 skewport_target_time_in_seconds, | 48 skewport_target_time_in_seconds, |
49 skewport_extrapolation_limit_in_content_pixels)); | 49 skewport_extrapolation_limit_in_content_pixels)); |
50 } | 50 } |
51 | 51 |
52 PictureLayerTiling::PictureLayerTiling( | 52 PictureLayerTiling::PictureLayerTiling( |
53 WhichTree tree, | 53 WhichTree tree, |
54 float contents_scale, | 54 float contents_scale, |
55 scoped_refptr<DisplayListRasterSource> raster_source, | 55 scoped_refptr<RasterSource> raster_source, |
56 PictureLayerTilingClient* client, | 56 PictureLayerTilingClient* client, |
57 size_t tiling_interest_area_padding, | 57 size_t tiling_interest_area_padding, |
58 float skewport_target_time_in_seconds, | 58 float skewport_target_time_in_seconds, |
59 int skewport_extrapolation_limit_in_content_pixels) | 59 int skewport_extrapolation_limit_in_content_pixels) |
60 : tiling_interest_area_padding_(tiling_interest_area_padding), | 60 : tiling_interest_area_padding_(tiling_interest_area_padding), |
61 skewport_target_time_in_seconds_(skewport_target_time_in_seconds), | 61 skewport_target_time_in_seconds_(skewport_target_time_in_seconds), |
62 skewport_extrapolation_limit_in_content_pixels_( | 62 skewport_extrapolation_limit_in_content_pixels_( |
63 skewport_extrapolation_limit_in_content_pixels), | 63 skewport_extrapolation_limit_in_content_pixels), |
64 contents_scale_(contents_scale), | 64 contents_scale_(contents_scale), |
65 client_(client), | 65 client_(client), |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 201 |
202 SetTilePriorityRects(pending_twin->current_content_to_screen_scale_, | 202 SetTilePriorityRects(pending_twin->current_content_to_screen_scale_, |
203 pending_twin->current_visible_rect_, | 203 pending_twin->current_visible_rect_, |
204 pending_twin->current_skewport_rect_, | 204 pending_twin->current_skewport_rect_, |
205 pending_twin->current_soon_border_rect_, | 205 pending_twin->current_soon_border_rect_, |
206 pending_twin->current_eventually_rect_, | 206 pending_twin->current_eventually_rect_, |
207 pending_twin->current_occlusion_in_layer_space_); | 207 pending_twin->current_occlusion_in_layer_space_); |
208 } | 208 } |
209 | 209 |
210 void PictureLayerTiling::SetRasterSourceAndResize( | 210 void PictureLayerTiling::SetRasterSourceAndResize( |
211 scoped_refptr<DisplayListRasterSource> raster_source) { | 211 scoped_refptr<RasterSource> raster_source) { |
212 DCHECK(!raster_source->IsSolidColor()); | 212 DCHECK(!raster_source->IsSolidColor()); |
213 gfx::Size old_layer_bounds = raster_source_->GetSize(); | 213 gfx::Size old_layer_bounds = raster_source_->GetSize(); |
214 raster_source_ = std::move(raster_source); | 214 raster_source_ = std::move(raster_source); |
215 gfx::Size new_layer_bounds = raster_source_->GetSize(); | 215 gfx::Size new_layer_bounds = raster_source_->GetSize(); |
216 gfx::Size content_bounds = | 216 gfx::Size content_bounds = |
217 gfx::ScaleToCeiledSize(new_layer_bounds, contents_scale_); | 217 gfx::ScaleToCeiledSize(new_layer_bounds, contents_scale_); |
218 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); | 218 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); |
219 | 219 |
220 if (tile_size != tiling_data_.max_texture_size()) { | 220 if (tile_size != tiling_data_.max_texture_size()) { |
221 tiling_data_.SetTilingSize(content_bounds); | 221 tiling_data_.SetTilingSize(content_bounds); |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { | 1029 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { |
1030 size_t amount = 0; | 1030 size_t amount = 0; |
1031 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 1031 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
1032 const Tile* tile = it->second.get(); | 1032 const Tile* tile = it->second.get(); |
1033 amount += tile->GPUMemoryUsageInBytes(); | 1033 amount += tile->GPUMemoryUsageInBytes(); |
1034 } | 1034 } |
1035 return amount; | 1035 return amount; |
1036 } | 1036 } |
1037 | 1037 |
1038 } // namespace cc | 1038 } // namespace cc |
OLD | NEW |