| 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> |
| 11 | 11 |
| 12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
| 13 #include "base/containers/small_map.h" | 13 #include "base/containers/small_map.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/numerics/safe_conversions.h" | 15 #include "base/numerics/safe_conversions.h" |
| 16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 17 #include "base/trace_event/trace_event_argument.h" | 17 #include "base/trace_event/trace_event_argument.h" |
| 18 #include "cc/base/math_util.h" | 18 #include "cc/base/math_util.h" |
| 19 #include "cc/playback/raster_source.h" | 19 #include "cc/playback/display_list_raster_source.h" |
| 20 #include "cc/tiles/prioritized_tile.h" | 20 #include "cc/tiles/prioritized_tile.h" |
| 21 #include "cc/tiles/tile.h" | 21 #include "cc/tiles/tile.h" |
| 22 #include "cc/tiles/tile_priority.h" | 22 #include "cc/tiles/tile_priority.h" |
| 23 #include "ui/gfx/geometry/point_conversions.h" | 23 #include "ui/gfx/geometry/point_conversions.h" |
| 24 #include "ui/gfx/geometry/rect_conversions.h" | 24 #include "ui/gfx/geometry/rect_conversions.h" |
| 25 #include "ui/gfx/geometry/safe_integer_conversions.h" | 25 #include "ui/gfx/geometry/safe_integer_conversions.h" |
| 26 #include "ui/gfx/geometry/size_conversions.h" | 26 #include "ui/gfx/geometry/size_conversions.h" |
| 27 | 27 |
| 28 namespace cc { | 28 namespace cc { |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 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<DisplayListRasterSource> raster_source, |
| 40 PictureLayerTilingClient* client, | 40 PictureLayerTilingClient* client, |
| 41 size_t tiling_interest_area_padding, | 41 size_t tiling_interest_area_padding, |
| 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, tiling_interest_area_padding, | 45 tree, contents_scale, raster_source, client, tiling_interest_area_padding, |
| 46 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<DisplayListRasterSource> raster_source, |
| 54 PictureLayerTilingClient* client, | 54 PictureLayerTilingClient* client, |
| 55 size_t tiling_interest_area_padding, | 55 size_t tiling_interest_area_padding, |
| 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_padding_(tiling_interest_area_padding), | 58 : tiling_interest_area_padding_(tiling_interest_area_padding), |
| 59 skewport_target_time_in_seconds_(skewport_target_time_in_seconds), | 59 skewport_target_time_in_seconds_(skewport_target_time_in_seconds), |
| 60 skewport_extrapolation_limit_in_content_pixels_( | 60 skewport_extrapolation_limit_in_content_pixels_( |
| 61 skewport_extrapolation_limit_in_content_pixels), | 61 skewport_extrapolation_limit_in_content_pixels), |
| 62 contents_scale_(contents_scale), | 62 contents_scale_(contents_scale), |
| 63 client_(client), | 63 client_(client), |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 198 |
| 199 SetTilePriorityRects(pending_twin->current_content_to_screen_scale_, | 199 SetTilePriorityRects(pending_twin->current_content_to_screen_scale_, |
| 200 pending_twin->current_visible_rect_, | 200 pending_twin->current_visible_rect_, |
| 201 pending_twin->current_skewport_rect_, | 201 pending_twin->current_skewport_rect_, |
| 202 pending_twin->current_soon_border_rect_, | 202 pending_twin->current_soon_border_rect_, |
| 203 pending_twin->current_eventually_rect_, | 203 pending_twin->current_eventually_rect_, |
| 204 pending_twin->current_occlusion_in_layer_space_); | 204 pending_twin->current_occlusion_in_layer_space_); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void PictureLayerTiling::SetRasterSourceAndResize( | 207 void PictureLayerTiling::SetRasterSourceAndResize( |
| 208 scoped_refptr<RasterSource> raster_source) { | 208 scoped_refptr<DisplayListRasterSource> raster_source) { |
| 209 DCHECK(!raster_source->IsSolidColor()); | 209 DCHECK(!raster_source->IsSolidColor()); |
| 210 gfx::Size old_layer_bounds = raster_source_->GetSize(); | 210 gfx::Size old_layer_bounds = raster_source_->GetSize(); |
| 211 raster_source_.swap(raster_source); | 211 raster_source_.swap(raster_source); |
| 212 gfx::Size new_layer_bounds = raster_source_->GetSize(); | 212 gfx::Size new_layer_bounds = raster_source_->GetSize(); |
| 213 gfx::Size content_bounds = | 213 gfx::Size content_bounds = |
| 214 gfx::ScaleToCeiledSize(new_layer_bounds, contents_scale_); | 214 gfx::ScaleToCeiledSize(new_layer_bounds, contents_scale_); |
| 215 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); | 215 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); |
| 216 | 216 |
| 217 if (tile_size != tiling_data_.max_texture_size()) { | 217 if (tile_size != tiling_data_.max_texture_size()) { |
| 218 tiling_data_.SetTilingSize(content_bounds); | 218 tiling_data_.SetTilingSize(content_bounds); |
| (...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { | 1005 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { |
| 1006 size_t amount = 0; | 1006 size_t amount = 0; |
| 1007 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 1007 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 1008 const Tile* tile = it->second; | 1008 const Tile* tile = it->second; |
| 1009 amount += tile->GPUMemoryUsageInBytes(); | 1009 amount += tile->GPUMemoryUsageInBytes(); |
| 1010 } | 1010 } |
| 1011 return amount; | 1011 return amount; |
| 1012 } | 1012 } |
| 1013 | 1013 |
| 1014 } // namespace cc | 1014 } // namespace cc |
| OLD | NEW |