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/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 if (!high_res) { | 938 if (!high_res) { |
939 high_res = AddTiling(raster_contents_scale_); | 939 high_res = AddTiling(raster_contents_scale_); |
940 if (raster_contents_scale_ == low_res_raster_contents_scale_) | 940 if (raster_contents_scale_ == low_res_raster_contents_scale_) |
941 low_res = high_res; | 941 low_res = high_res; |
942 } | 942 } |
943 | 943 |
944 // Only create new low res tilings when the transform is static. This | 944 // Only create new low res tilings when the transform is static. This |
945 // prevents wastefully creating a paired low res tiling for every new high res | 945 // prevents wastefully creating a paired low res tiling for every new high res |
946 // tiling during a pinch or a CSS animation. | 946 // tiling during a pinch or a CSS animation. |
947 bool is_pinching = layer_tree_impl()->PinchGestureActive(); | 947 bool is_pinching = layer_tree_impl()->PinchGestureActive(); |
948 if (!is_pinching && !animating_transform_to_screen && !low_res && | 948 if (ShouldHaveLowResTiling() && !is_pinching && |
949 low_res != high_res) | 949 !animating_transform_to_screen && |
| 950 !low_res && low_res != high_res) |
950 low_res = AddTiling(low_res_raster_contents_scale_); | 951 low_res = AddTiling(low_res_raster_contents_scale_); |
951 | 952 |
952 // Set low-res if we have one. | 953 // Set low-res if we have one. |
953 if (!low_res) | 954 if (!low_res) |
954 low_res = previous_low_res; | 955 low_res = previous_low_res; |
955 if (low_res && low_res != high_res) | 956 if (low_res && low_res != high_res) |
956 low_res->set_resolution(LOW_RESOLUTION); | 957 low_res->set_resolution(LOW_RESOLUTION); |
957 | 958 |
958 // Make sure we always have one high-res (even if high == low). | 959 // Make sure we always have one high-res (even if high == low). |
959 high_res->set_resolution(HIGH_RESOLUTION); | 960 high_res->set_resolution(HIGH_RESOLUTION); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 std::vector<PictureLayerTiling*> to_remove; | 1086 std::vector<PictureLayerTiling*> to_remove; |
1086 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 1087 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
1087 PictureLayerTiling* tiling = tilings_->tiling_at(i); | 1088 PictureLayerTiling* tiling = tilings_->tiling_at(i); |
1088 | 1089 |
1089 // Keep multiple high resolution tilings even if not used to help | 1090 // Keep multiple high resolution tilings even if not used to help |
1090 // activate earlier at non-ideal resolutions. | 1091 // activate earlier at non-ideal resolutions. |
1091 if (tiling->contents_scale() >= min_acceptable_high_res_scale && | 1092 if (tiling->contents_scale() >= min_acceptable_high_res_scale && |
1092 tiling->contents_scale() <= max_acceptable_high_res_scale) | 1093 tiling->contents_scale() <= max_acceptable_high_res_scale) |
1093 continue; | 1094 continue; |
1094 | 1095 |
1095 // Low resolution can't activate, so only keep one around. | 1096 // Keep low resolution tilings, if the layer should have them. |
1096 if (tiling->resolution() == LOW_RESOLUTION) | 1097 if (tiling->resolution() == LOW_RESOLUTION && ShouldHaveLowResTiling()) |
1097 continue; | 1098 continue; |
1098 | 1099 |
1099 // Don't remove tilings that are being used (and thus would cause a flash.) | 1100 // Don't remove tilings that are being used (and thus would cause a flash.) |
1100 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) != | 1101 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) != |
1101 used_tilings.end()) | 1102 used_tilings.end()) |
1102 continue; | 1103 continue; |
1103 | 1104 |
1104 to_remove.push_back(tiling); | 1105 to_remove.push_back(tiling); |
1105 } | 1106 } |
1106 | 1107 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { | 1231 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { |
1231 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); | 1232 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); |
1232 return tilings_->GPUMemoryUsageInBytes(); | 1233 return tilings_->GPUMemoryUsageInBytes(); |
1233 } | 1234 } |
1234 | 1235 |
1235 void PictureLayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { | 1236 void PictureLayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { |
1236 benchmark->RunOnLayer(this); | 1237 benchmark->RunOnLayer(this); |
1237 } | 1238 } |
1238 | 1239 |
1239 } // namespace cc | 1240 } // namespace cc |
OLD | NEW |