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 <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 tilings_(CreatePictureLayerTilingSet()), | 62 tilings_(CreatePictureLayerTilingSet()), |
63 ideal_page_scale_(0.f), | 63 ideal_page_scale_(0.f), |
64 ideal_device_scale_(0.f), | 64 ideal_device_scale_(0.f), |
65 ideal_source_scale_(0.f), | 65 ideal_source_scale_(0.f), |
66 ideal_contents_scale_(0.f), | 66 ideal_contents_scale_(0.f), |
67 raster_page_scale_(0.f), | 67 raster_page_scale_(0.f), |
68 raster_device_scale_(0.f), | 68 raster_device_scale_(0.f), |
69 raster_source_scale_(0.f), | 69 raster_source_scale_(0.f), |
70 raster_contents_scale_(0.f), | 70 raster_contents_scale_(0.f), |
71 low_res_raster_contents_scale_(0.f), | 71 low_res_raster_contents_scale_(0.f), |
72 raster_source_scale_is_fixed_(false), | |
73 was_screen_space_transform_animating_(false), | 72 was_screen_space_transform_animating_(false), |
74 only_used_low_res_last_append_quads_(false), | 73 only_used_low_res_last_append_quads_(false), |
75 is_mask_(is_mask), | 74 is_mask_(is_mask), |
76 nearest_neighbor_(false) { | 75 nearest_neighbor_(false) { |
77 layer_tree_impl()->RegisterPictureLayerImpl(this); | 76 layer_tree_impl()->RegisterPictureLayerImpl(this); |
78 } | 77 } |
79 | 78 |
80 PictureLayerImpl::~PictureLayerImpl() { | 79 PictureLayerImpl::~PictureLayerImpl() { |
81 if (twin_layer_) | 80 if (twin_layer_) |
82 twin_layer_->twin_layer_ = nullptr; | 81 twin_layer_->twin_layer_ = nullptr; |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 if (!is_pinching) { | 882 if (!is_pinching) { |
884 // When not pinching, match the ideal page scale factor. | 883 // When not pinching, match the ideal page scale factor. |
885 if (raster_page_scale_ != ideal_page_scale_) | 884 if (raster_page_scale_ != ideal_page_scale_) |
886 return true; | 885 return true; |
887 } | 886 } |
888 | 887 |
889 // Always match the ideal device scale factor. | 888 // Always match the ideal device scale factor. |
890 if (raster_device_scale_ != ideal_device_scale_) | 889 if (raster_device_scale_ != ideal_device_scale_) |
891 return true; | 890 return true; |
892 | 891 |
893 // When the source scale changes we want to match it, but not when animating | 892 // When the source scale changes we want to match it, but not when animating. |
894 // or when we've fixed the scale in place. | |
895 if (!draw_properties().screen_space_transform_is_animating && | 893 if (!draw_properties().screen_space_transform_is_animating && |
896 !raster_source_scale_is_fixed_ && | |
897 raster_source_scale_ != ideal_source_scale_) | 894 raster_source_scale_ != ideal_source_scale_) |
898 return true; | 895 return true; |
899 | 896 |
900 if (raster_contents_scale_ > MaximumContentsScale()) | 897 if (raster_contents_scale_ > MaximumContentsScale()) |
901 return true; | 898 return true; |
902 if (raster_contents_scale_ < MinimumContentsScale()) | 899 if (raster_contents_scale_ < MinimumContentsScale()) |
903 return true; | 900 return true; |
904 | 901 |
905 return false; | 902 return false; |
906 } | 903 } |
(...skipping 20 matching lines...) Expand all Loading... |
927 bool is_pinching = layer_tree_impl()->PinchGestureActive(); | 924 bool is_pinching = layer_tree_impl()->PinchGestureActive(); |
928 bool is_animating = draw_properties().screen_space_transform_is_animating; | 925 bool is_animating = draw_properties().screen_space_transform_is_animating; |
929 if (!is_pinching && !is_animating) { | 926 if (!is_pinching && !is_animating) { |
930 if (!low_res) | 927 if (!low_res) |
931 low_res = AddTiling(low_res_raster_contents_scale_); | 928 low_res = AddTiling(low_res_raster_contents_scale_); |
932 low_res->set_resolution(LOW_RESOLUTION); | 929 low_res->set_resolution(LOW_RESOLUTION); |
933 } | 930 } |
934 } | 931 } |
935 | 932 |
936 void PictureLayerImpl::RecalculateRasterScales() { | 933 void PictureLayerImpl::RecalculateRasterScales() { |
937 float old_raster_contents_scale = raster_contents_scale_; | 934 const float old_raster_contents_scale = raster_contents_scale_; |
938 float old_raster_page_scale = raster_page_scale_; | 935 const float old_raster_page_scale = raster_page_scale_; |
939 float old_raster_source_scale = raster_source_scale_; | |
940 | 936 |
941 raster_device_scale_ = ideal_device_scale_; | 937 raster_device_scale_ = ideal_device_scale_; |
942 raster_page_scale_ = ideal_page_scale_; | 938 raster_page_scale_ = ideal_page_scale_; |
943 raster_source_scale_ = ideal_source_scale_; | 939 raster_source_scale_ = ideal_source_scale_; |
944 raster_contents_scale_ = ideal_contents_scale_; | 940 raster_contents_scale_ = ideal_contents_scale_; |
945 | 941 |
946 // If we're not animating, or leaving an animation, and the | |
947 // ideal_source_scale_ changes, then things are unpredictable, and we fix | |
948 // the raster_source_scale_ in place. | |
949 if (old_raster_source_scale && | |
950 !draw_properties().screen_space_transform_is_animating && | |
951 !was_screen_space_transform_animating_ && | |
952 old_raster_source_scale != ideal_source_scale_) | |
953 raster_source_scale_is_fixed_ = true; | |
954 | |
955 // TODO(danakj): Adjust raster source scale closer to ideal source scale at | |
956 // a throttled rate. Possibly make use of invalidation_.IsEmpty() on pending | |
957 // tree. This will allow CSS scale changes to get re-rastered at an | |
958 // appropriate rate. (crbug.com/413636) | |
959 if (raster_source_scale_is_fixed_) { | |
960 raster_contents_scale_ /= raster_source_scale_; | |
961 raster_source_scale_ = 1.f; | |
962 } | |
963 | |
964 // During pinch we completely ignore the current ideal scale, and just use | 942 // During pinch we completely ignore the current ideal scale, and just use |
965 // a multiple of the previous scale. | 943 // a multiple of the previous scale. |
966 bool is_pinching = layer_tree_impl()->PinchGestureActive(); | 944 bool is_pinching = layer_tree_impl()->PinchGestureActive(); |
967 if (is_pinching && old_raster_contents_scale) { | 945 if (is_pinching && old_raster_contents_scale) { |
968 // See ShouldAdjustRasterScale: | 946 // See ShouldAdjustRasterScale: |
969 // - When zooming out, preemptively create new tiling at lower resolution. | 947 // - When zooming out, preemptively create new tiling at lower resolution. |
970 // - When zooming in, approximate ideal using multiple of kMaxScaleRatio. | 948 // - When zooming in, approximate ideal using multiple of kMaxScaleRatio. |
971 bool zooming_out = old_raster_page_scale > ideal_page_scale_; | 949 bool zooming_out = old_raster_page_scale > ideal_page_scale_; |
972 float desired_contents_scale = old_raster_contents_scale; | 950 float desired_contents_scale = old_raster_contents_scale; |
973 if (zooming_out) { | 951 if (zooming_out) { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 // up larger than |max_texture_size|. | 1100 // up larger than |max_texture_size|. |
1123 return nextafterf(max_scale, 0.f); | 1101 return nextafterf(max_scale, 0.f); |
1124 } | 1102 } |
1125 | 1103 |
1126 void PictureLayerImpl::ResetRasterScale() { | 1104 void PictureLayerImpl::ResetRasterScale() { |
1127 raster_page_scale_ = 0.f; | 1105 raster_page_scale_ = 0.f; |
1128 raster_device_scale_ = 0.f; | 1106 raster_device_scale_ = 0.f; |
1129 raster_source_scale_ = 0.f; | 1107 raster_source_scale_ = 0.f; |
1130 raster_contents_scale_ = 0.f; | 1108 raster_contents_scale_ = 0.f; |
1131 low_res_raster_contents_scale_ = 0.f; | 1109 low_res_raster_contents_scale_ = 0.f; |
1132 raster_source_scale_is_fixed_ = false; | |
1133 } | 1110 } |
1134 | 1111 |
1135 bool PictureLayerImpl::CanHaveTilings() const { | 1112 bool PictureLayerImpl::CanHaveTilings() const { |
1136 if (raster_source_->IsSolidColor()) | 1113 if (raster_source_->IsSolidColor()) |
1137 return false; | 1114 return false; |
1138 if (!DrawsContent()) | 1115 if (!DrawsContent()) |
1139 return false; | 1116 return false; |
1140 if (!raster_source_->HasRecordings()) | 1117 if (!raster_source_->HasRecordings()) |
1141 return false; | 1118 return false; |
1142 // If the |raster_source_| has a recording it should have non-empty bounds. | 1119 // If the |raster_source_| has a recording it should have non-empty bounds. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 std::vector<PrioritizedTile>* prioritized_tiles) const { | 1183 std::vector<PrioritizedTile>* prioritized_tiles) const { |
1207 if (!tilings_) | 1184 if (!tilings_) |
1208 return; | 1185 return; |
1209 tilings_->GetAllPrioritizedTilesForTracing(prioritized_tiles); | 1186 tilings_->GetAllPrioritizedTilesForTracing(prioritized_tiles); |
1210 } | 1187 } |
1211 | 1188 |
1212 void PictureLayerImpl::AsValueInto( | 1189 void PictureLayerImpl::AsValueInto( |
1213 base::trace_event::TracedValue* state) const { | 1190 base::trace_event::TracedValue* state) const { |
1214 LayerImpl::AsValueInto(state); | 1191 LayerImpl::AsValueInto(state); |
1215 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 1192 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
| 1193 state->SetDouble("raster_contents_scale", raster_contents_scale_); |
1216 state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale()); | 1194 state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale()); |
1217 state->BeginArray("tilings"); | 1195 state->BeginArray("tilings"); |
1218 tilings_->AsValueInto(state); | 1196 tilings_->AsValueInto(state); |
1219 state->EndArray(); | 1197 state->EndArray(); |
1220 | 1198 |
1221 MathUtil::AddToTracedValue("tile_priority_rect", | 1199 MathUtil::AddToTracedValue("tile_priority_rect", |
1222 viewport_rect_for_tile_priority_in_content_space_, | 1200 viewport_rect_for_tile_priority_in_content_space_, |
1223 state); | 1201 state); |
1224 MathUtil::AddToTracedValue("visible_rect", visible_layer_rect(), state); | 1202 MathUtil::AddToTracedValue("visible_rect", visible_layer_rect(), state); |
1225 | 1203 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 | 1240 |
1263 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1241 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
1264 return !layer_tree_impl()->IsRecycleTree(); | 1242 return !layer_tree_impl()->IsRecycleTree(); |
1265 } | 1243 } |
1266 | 1244 |
1267 bool PictureLayerImpl::HasValidTilePriorities() const { | 1245 bool PictureLayerImpl::HasValidTilePriorities() const { |
1268 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1246 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
1269 } | 1247 } |
1270 | 1248 |
1271 } // namespace cc | 1249 } // namespace cc |
OLD | NEW |