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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/debug/trace_event_argument.h" | 10 #include "base/debug/trace_event_argument.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 PictureLayerImpl* pending_layer) | 53 PictureLayerImpl* pending_layer) |
54 : active(active_layer), pending(pending_layer) { | 54 : active(active_layer), pending(pending_layer) { |
55 } | 55 } |
56 | 56 |
57 PictureLayerImpl::Pair::~Pair() { | 57 PictureLayerImpl::Pair::~Pair() { |
58 } | 58 } |
59 | 59 |
60 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) | 60 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) |
61 : LayerImpl(tree_impl, id), | 61 : LayerImpl(tree_impl, id), |
62 twin_layer_(NULL), | 62 twin_layer_(NULL), |
63 recycled_twin_layer_(NULL), | |
63 pile_(PicturePileImpl::Create()), | 64 pile_(PicturePileImpl::Create()), |
64 is_mask_(false), | 65 is_mask_(false), |
65 ideal_page_scale_(0.f), | 66 ideal_page_scale_(0.f), |
66 ideal_device_scale_(0.f), | 67 ideal_device_scale_(0.f), |
67 ideal_source_scale_(0.f), | 68 ideal_source_scale_(0.f), |
68 ideal_contents_scale_(0.f), | 69 ideal_contents_scale_(0.f), |
69 raster_page_scale_(0.f), | 70 raster_page_scale_(0.f), |
70 raster_device_scale_(0.f), | 71 raster_device_scale_(0.f), |
71 raster_source_scale_(0.f), | 72 raster_source_scale_(0.f), |
72 raster_contents_scale_(0.f), | 73 raster_contents_scale_(0.f), |
(...skipping 29 matching lines...) Expand all Loading... | |
102 // there are now tiles in this layer's tilings that were unref'd and replaced | 103 // there are now tiles in this layer's tilings that were unref'd and replaced |
103 // with new tiles (due to invalidation). This resets all active priorities on | 104 // with new tiles (due to invalidation). This resets all active priorities on |
104 // the to-be-recycled tiling to ensure replaced tiles don't linger and take | 105 // the to-be-recycled tiling to ensure replaced tiles don't linger and take |
105 // memory (due to a stale 'active' priority). | 106 // memory (due to a stale 'active' priority). |
106 if (layer_impl->tilings_) | 107 if (layer_impl->tilings_) |
107 layer_impl->tilings_->DidBecomeRecycled(); | 108 layer_impl->tilings_->DidBecomeRecycled(); |
108 | 109 |
109 LayerImpl::PushPropertiesTo(base_layer); | 110 LayerImpl::PushPropertiesTo(base_layer); |
110 | 111 |
111 // When the pending tree pushes to the active tree, the pending twin | 112 // When the pending tree pushes to the active tree, the pending twin |
112 // disappears. | 113 // becomes recycled. |
113 layer_impl->twin_layer_ = NULL; | 114 layer_impl->twin_layer_ = NULL; |
115 layer_impl->recycled_twin_layer_ = this; | |
116 DCHECK(!recycled_twin_layer_); | |
114 twin_layer_ = NULL; | 117 twin_layer_ = NULL; |
115 | 118 |
116 layer_impl->SetIsMask(is_mask_); | 119 layer_impl->SetIsMask(is_mask_); |
117 layer_impl->pile_ = pile_; | 120 layer_impl->pile_ = pile_; |
118 | 121 |
119 // Tilings would be expensive to push, so we swap. | 122 // Tilings would be expensive to push, so we swap. |
120 layer_impl->tilings_.swap(tilings_); | 123 layer_impl->tilings_.swap(tilings_); |
121 | 124 |
122 // Remove invalidated tiles from what will become a recycle tree. | 125 // Remove invalidated tiles from what will become a recycle tree. |
123 if (tilings_) | 126 if (tilings_) |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
603 const PictureLayerTiling* tiling) const { | 606 const PictureLayerTiling* tiling) const { |
604 if (!twin_layer_) | 607 if (!twin_layer_) |
605 return NULL; | 608 return NULL; |
606 for (size_t i = 0; i < twin_layer_->tilings_->num_tilings(); ++i) | 609 for (size_t i = 0; i < twin_layer_->tilings_->num_tilings(); ++i) |
607 if (twin_layer_->tilings_->tiling_at(i)->contents_scale() == | 610 if (twin_layer_->tilings_->tiling_at(i)->contents_scale() == |
608 tiling->contents_scale()) | 611 tiling->contents_scale()) |
609 return twin_layer_->tilings_->tiling_at(i); | 612 return twin_layer_->tilings_->tiling_at(i); |
610 return NULL; | 613 return NULL; |
611 } | 614 } |
612 | 615 |
616 PictureLayerTiling* PictureLayerImpl::GetRecycledTwinTiling( | |
617 const PictureLayerTiling* tiling) const { | |
618 if (!recycled_twin_layer_ || !recycled_twin_layer_->tilings_) | |
619 return NULL; | |
620 for (size_t i = 0; i < recycled_twin_layer_->tilings_->num_tilings(); ++i) { | |
enne (OOO)
2014/08/22 21:36:09
I think you're looking for recycled_twin_layer_->t
vmpstr
2014/08/22 22:47:30
Ah, that's easier.
| |
621 if (recycled_twin_layer_->tilings_->tiling_at(i)->contents_scale() == | |
622 tiling->contents_scale()) { | |
623 return recycled_twin_layer_->tilings_->tiling_at(i); | |
624 } | |
625 } | |
626 return NULL; | |
627 } | |
628 | |
613 size_t PictureLayerImpl::GetMaxTilesForInterestArea() const { | 629 size_t PictureLayerImpl::GetMaxTilesForInterestArea() const { |
614 return layer_tree_impl()->settings().max_tiles_for_interest_area; | 630 return layer_tree_impl()->settings().max_tiles_for_interest_area; |
615 } | 631 } |
616 | 632 |
617 float PictureLayerImpl::GetSkewportTargetTimeInSeconds() const { | 633 float PictureLayerImpl::GetSkewportTargetTimeInSeconds() const { |
618 float skewport_target_time_in_frames = | 634 float skewport_target_time_in_frames = |
619 layer_tree_impl()->use_gpu_rasterization() | 635 layer_tree_impl()->use_gpu_rasterization() |
620 ? kGpuSkewportTargetTimeInFrames | 636 ? kGpuSkewportTargetTimeInFrames |
621 : kCpuSkewportTargetTimeInFrames; | 637 : kCpuSkewportTargetTimeInFrames; |
622 return skewport_target_time_in_frames * | 638 return skewport_target_time_in_frames * |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
939 | 955 |
940 if (!tilings_) | 956 if (!tilings_) |
941 tilings_.reset(new PictureLayerTilingSet(this, bounds())); | 957 tilings_.reset(new PictureLayerTilingSet(this, bounds())); |
942 | 958 |
943 DCHECK(!twin_layer_); | 959 DCHECK(!twin_layer_); |
944 twin_layer_ = static_cast<PictureLayerImpl*>( | 960 twin_layer_ = static_cast<PictureLayerImpl*>( |
945 layer_tree_impl()->FindActiveTreeLayerById(id())); | 961 layer_tree_impl()->FindActiveTreeLayerById(id())); |
946 if (twin_layer_) { | 962 if (twin_layer_) { |
947 DCHECK(!twin_layer_->twin_layer_); | 963 DCHECK(!twin_layer_->twin_layer_); |
948 twin_layer_->twin_layer_ = this; | 964 twin_layer_->twin_layer_ = this; |
965 DCHECK(!twin_layer_->recycled_twin_layer_ || | |
966 twin_layer_->recycled_twin_layer_ == this); | |
967 twin_layer_->recycled_twin_layer_ = NULL; | |
949 // If the twin has never been pushed to, do not sync from it. | 968 // If the twin has never been pushed to, do not sync from it. |
950 // This can happen if this function is called during activation. | 969 // This can happen if this function is called during activation. |
951 if (!twin_layer_->needs_post_commit_initialization_) | 970 if (!twin_layer_->needs_post_commit_initialization_) |
952 SyncFromActiveLayer(twin_layer_); | 971 SyncFromActiveLayer(twin_layer_); |
953 } | 972 } |
954 | 973 |
955 needs_post_commit_initialization_ = false; | 974 needs_post_commit_initialization_ = false; |
956 } | 975 } |
957 | 976 |
958 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { | 977 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1243 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) != | 1262 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) != |
1244 used_tilings.end()) | 1263 used_tilings.end()) |
1245 continue; | 1264 continue; |
1246 | 1265 |
1247 to_remove.push_back(tiling); | 1266 to_remove.push_back(tiling); |
1248 } | 1267 } |
1249 | 1268 |
1250 if (to_remove.empty()) | 1269 if (to_remove.empty()) |
1251 return; | 1270 return; |
1252 | 1271 |
1253 PictureLayerImpl* recycled_twin = static_cast<PictureLayerImpl*>( | |
1254 layer_tree_impl()->FindRecycleTreeLayerById(id())); | |
1255 // Remove tilings on this tree and the twin tree. | 1272 // Remove tilings on this tree and the twin tree. |
1256 for (size_t i = 0; i < to_remove.size(); ++i) { | 1273 for (size_t i = 0; i < to_remove.size(); ++i) { |
1257 const PictureLayerTiling* twin_tiling = GetTwinTiling(to_remove[i]); | 1274 const PictureLayerTiling* twin_tiling = GetTwinTiling(to_remove[i]); |
1258 // Only remove tilings from the twin layer if they have | 1275 // Only remove tilings from the twin layer if they have |
1259 // NON_IDEAL_RESOLUTION. | 1276 // NON_IDEAL_RESOLUTION. |
1260 if (twin_tiling && twin_tiling->resolution() == NON_IDEAL_RESOLUTION) | 1277 if (twin_tiling && twin_tiling->resolution() == NON_IDEAL_RESOLUTION) |
1261 twin->RemoveTiling(to_remove[i]->contents_scale()); | 1278 twin->RemoveTiling(to_remove[i]->contents_scale()); |
1262 // Remove the tiling from the recycle tree. Note that we ignore resolution, | 1279 // Remove the tiling from the recycle tree. Note that we ignore resolution, |
1263 // since we don't need to maintain high/low res on the recycle tree. | 1280 // since we don't need to maintain high/low res on the recycle tree. |
1264 if (recycled_twin) | 1281 if (recycled_twin_layer_) |
1265 recycled_twin->RemoveTiling(to_remove[i]->contents_scale()); | 1282 recycled_twin_layer_->RemoveTiling(to_remove[i]->contents_scale()); |
1266 // TODO(enne): temporary sanity CHECK for http://crbug.com/358350 | 1283 // TODO(enne): temporary sanity CHECK for http://crbug.com/358350 |
1267 CHECK_NE(HIGH_RESOLUTION, to_remove[i]->resolution()); | 1284 CHECK_NE(HIGH_RESOLUTION, to_remove[i]->resolution()); |
1268 tilings_->Remove(to_remove[i]); | 1285 tilings_->Remove(to_remove[i]); |
1269 } | 1286 } |
1270 | 1287 |
1271 DCHECK_GT(tilings_->num_tilings(), 0u); | 1288 DCHECK_GT(tilings_->num_tilings(), 0u); |
1272 SanityCheckTilingState(); | 1289 SanityCheckTilingState(); |
1273 } | 1290 } |
1274 | 1291 |
1275 float PictureLayerImpl::MinimumContentsScale() const { | 1292 float PictureLayerImpl::MinimumContentsScale() const { |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1748 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1765 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
1749 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1766 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
1750 return tiling_range.end - 1 - current_tiling_range_offset; | 1767 return tiling_range.end - 1 - current_tiling_range_offset; |
1751 } | 1768 } |
1752 } | 1769 } |
1753 NOTREACHED(); | 1770 NOTREACHED(); |
1754 return 0; | 1771 return 0; |
1755 } | 1772 } |
1756 | 1773 |
1757 } // namespace cc | 1774 } // namespace cc |
OLD | NEW |