| 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 | 10 |
| 11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
| 12 #include "cc/base/math_util.h" | 12 #include "cc/base/math_util.h" |
| 13 #include "ui/gfx/point_conversions.h" | 13 #include "ui/gfx/point_conversions.h" |
| 14 #include "ui/gfx/rect_conversions.h" | 14 #include "ui/gfx/rect_conversions.h" |
| 15 #include "ui/gfx/safe_integer_conversions.h" | 15 #include "ui/gfx/safe_integer_conversions.h" |
| 16 #include "ui/gfx/size_conversions.h" | 16 #include "ui/gfx/size_conversions.h" |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 | 19 |
| 20 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( | 20 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( |
| 21 float contents_scale, | 21 float contents_scale, |
| 22 gfx::Size layer_bounds, | 22 const gfx::Size& layer_bounds, |
| 23 PictureLayerTilingClient* client) { | 23 PictureLayerTilingClient* client) { |
| 24 return make_scoped_ptr(new PictureLayerTiling(contents_scale, | 24 return make_scoped_ptr(new PictureLayerTiling(contents_scale, |
| 25 layer_bounds, | 25 layer_bounds, |
| 26 client)); | 26 client)); |
| 27 } | 27 } |
| 28 | 28 |
| 29 PictureLayerTiling::PictureLayerTiling(float contents_scale, | 29 PictureLayerTiling::PictureLayerTiling(float contents_scale, |
| 30 gfx::Size layer_bounds, | 30 const gfx::Size& layer_bounds, |
| 31 PictureLayerTilingClient* client) | 31 PictureLayerTilingClient* client) |
| 32 : contents_scale_(contents_scale), | 32 : contents_scale_(contents_scale), |
| 33 layer_bounds_(layer_bounds), | 33 layer_bounds_(layer_bounds), |
| 34 resolution_(NON_IDEAL_RESOLUTION), | 34 resolution_(NON_IDEAL_RESOLUTION), |
| 35 client_(client), | 35 client_(client), |
| 36 tiling_data_(gfx::Size(), gfx::Size(), true), | 36 tiling_data_(gfx::Size(), gfx::Size(), true), |
| 37 last_impl_frame_time_in_seconds_(0.0) { | 37 last_impl_frame_time_in_seconds_(0.0) { |
| 38 gfx::Size content_bounds = | 38 gfx::Size content_bounds = |
| 39 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)); | 39 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)); |
| 40 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); | 40 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 for (TilingData::Iterator iter(&tiling_data_, live_tiles_rect_); iter; | 118 for (TilingData::Iterator iter(&tiling_data_, live_tiles_rect_); iter; |
| 119 ++iter) { | 119 ++iter) { |
| 120 TileMapKey key = iter.index(); | 120 TileMapKey key = iter.index(); |
| 121 TileMap::iterator find = tiles_.find(key); | 121 TileMap::iterator find = tiles_.find(key); |
| 122 if (find != tiles_.end()) | 122 if (find != tiles_.end()) |
| 123 continue; | 123 continue; |
| 124 CreateTile(key.first, key.second, twin_tiling); | 124 CreateTile(key.first, key.second, twin_tiling); |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 void PictureLayerTiling::SetLayerBounds(gfx::Size layer_bounds) { | 128 void PictureLayerTiling::SetLayerBounds(const gfx::Size& layer_bounds) { |
| 129 if (layer_bounds_ == layer_bounds) | 129 if (layer_bounds_ == layer_bounds) |
| 130 return; | 130 return; |
| 131 | 131 |
| 132 DCHECK(!layer_bounds.IsEmpty()); | 132 DCHECK(!layer_bounds.IsEmpty()); |
| 133 | 133 |
| 134 gfx::Size old_layer_bounds = layer_bounds_; | 134 gfx::Size old_layer_bounds = layer_bounds_; |
| 135 layer_bounds_ = layer_bounds; | 135 layer_bounds_ = layer_bounds; |
| 136 gfx::Size old_content_bounds = tiling_data_.total_size(); | 136 gfx::Size old_content_bounds = tiling_data_.total_size(); |
| 137 gfx::Size content_bounds = | 137 gfx::Size content_bounds = |
| 138 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds_, contents_scale_)); | 138 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds_, contents_scale_)); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 return tiling_->tiling_data_.max_texture_size(); | 334 return tiling_->tiling_data_.max_texture_size(); |
| 335 } | 335 } |
| 336 | 336 |
| 337 void PictureLayerTiling::Reset() { | 337 void PictureLayerTiling::Reset() { |
| 338 live_tiles_rect_ = gfx::Rect(); | 338 live_tiles_rect_ = gfx::Rect(); |
| 339 tiles_.clear(); | 339 tiles_.clear(); |
| 340 } | 340 } |
| 341 | 341 |
| 342 void PictureLayerTiling::UpdateTilePriorities( | 342 void PictureLayerTiling::UpdateTilePriorities( |
| 343 WhichTree tree, | 343 WhichTree tree, |
| 344 gfx::Size device_viewport, | 344 const gfx::Size& device_viewport, |
| 345 const gfx::Rect& viewport_in_layer_space, | 345 const gfx::Rect& viewport_in_layer_space, |
| 346 const gfx::Rect& visible_layer_rect, | 346 const gfx::Rect& visible_layer_rect, |
| 347 gfx::Size last_layer_bounds, | 347 const gfx::Size& last_layer_bounds, |
| 348 gfx::Size current_layer_bounds, | 348 const gfx::Size& current_layer_bounds, |
| 349 float last_layer_contents_scale, | 349 float last_layer_contents_scale, |
| 350 float current_layer_contents_scale, | 350 float current_layer_contents_scale, |
| 351 const gfx::Transform& last_screen_transform, | 351 const gfx::Transform& last_screen_transform, |
| 352 const gfx::Transform& current_screen_transform, | 352 const gfx::Transform& current_screen_transform, |
| 353 double current_frame_time_in_seconds, | 353 double current_frame_time_in_seconds, |
| 354 size_t max_tiles_for_interest_area) { | 354 size_t max_tiles_for_interest_area) { |
| 355 if (!NeedsUpdateForFrameAtTime(current_frame_time_in_seconds)) { | 355 if (!NeedsUpdateForFrameAtTime(current_frame_time_in_seconds)) { |
| 356 // This should never be zero for the purposes of has_ever_been_updated(). | 356 // This should never be zero for the purposes of has_ever_been_updated(). |
| 357 DCHECK_NE(current_frame_time_in_seconds, 0.0); | 357 DCHECK_NE(current_frame_time_in_seconds, 0.0); |
| 358 return; | 358 return; |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 break; | 786 break; |
| 787 } | 787 } |
| 788 | 788 |
| 789 gfx::Rect result(origin_x, origin_y, width, height); | 789 gfx::Rect result(origin_x, origin_y, width, height); |
| 790 if (cache) | 790 if (cache) |
| 791 cache->previous_result = result; | 791 cache->previous_result = result; |
| 792 return result; | 792 return result; |
| 793 } | 793 } |
| 794 | 794 |
| 795 } // namespace cc | 795 } // namespace cc |
| OLD | NEW |