| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 ideal_source_scale_(0.f), | 70 ideal_source_scale_(0.f), |
| 71 ideal_contents_scale_(0.f), | 71 ideal_contents_scale_(0.f), |
| 72 raster_page_scale_(0.f), | 72 raster_page_scale_(0.f), |
| 73 raster_device_scale_(0.f), | 73 raster_device_scale_(0.f), |
| 74 raster_source_scale_(0.f), | 74 raster_source_scale_(0.f), |
| 75 raster_contents_scale_(0.f), | 75 raster_contents_scale_(0.f), |
| 76 low_res_raster_contents_scale_(0.f), | 76 low_res_raster_contents_scale_(0.f), |
| 77 was_screen_space_transform_animating_(false), | 77 was_screen_space_transform_animating_(false), |
| 78 only_used_low_res_last_append_quads_(false), | 78 only_used_low_res_last_append_quads_(false), |
| 79 is_mask_(is_mask), | 79 is_mask_(is_mask), |
| 80 nearest_neighbor_(false) { | 80 nearest_neighbor_(false), |
| 81 is_directly_composited_image_(false) { |
| 81 layer_tree_impl()->RegisterPictureLayerImpl(this); | 82 layer_tree_impl()->RegisterPictureLayerImpl(this); |
| 82 } | 83 } |
| 83 | 84 |
| 84 PictureLayerImpl::~PictureLayerImpl() { | 85 PictureLayerImpl::~PictureLayerImpl() { |
| 85 if (twin_layer_) | 86 if (twin_layer_) |
| 86 twin_layer_->twin_layer_ = nullptr; | 87 twin_layer_->twin_layer_ = nullptr; |
| 87 layer_tree_impl()->UnregisterPictureLayerImpl(this); | 88 layer_tree_impl()->UnregisterPictureLayerImpl(this); |
| 88 } | 89 } |
| 89 | 90 |
| 90 const char* PictureLayerImpl::LayerTypeAsString() const { | 91 const char* PictureLayerImpl::LayerTypeAsString() const { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 128 |
| 128 // After syncing a solid color layer, the active layer has no tilings. | 129 // After syncing a solid color layer, the active layer has no tilings. |
| 129 DCHECK(!raster_source_->IsSolidColor() || | 130 DCHECK(!raster_source_->IsSolidColor() || |
| 130 layer_impl->tilings_->num_tilings() == 0); | 131 layer_impl->tilings_->num_tilings() == 0); |
| 131 | 132 |
| 132 layer_impl->raster_page_scale_ = raster_page_scale_; | 133 layer_impl->raster_page_scale_ = raster_page_scale_; |
| 133 layer_impl->raster_device_scale_ = raster_device_scale_; | 134 layer_impl->raster_device_scale_ = raster_device_scale_; |
| 134 layer_impl->raster_source_scale_ = raster_source_scale_; | 135 layer_impl->raster_source_scale_ = raster_source_scale_; |
| 135 layer_impl->raster_contents_scale_ = raster_contents_scale_; | 136 layer_impl->raster_contents_scale_ = raster_contents_scale_; |
| 136 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_; | 137 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_; |
| 138 layer_impl->is_directly_composited_image_ = is_directly_composited_image_; |
| 137 | 139 |
| 138 layer_impl->SanityCheckTilingState(); | 140 layer_impl->SanityCheckTilingState(); |
| 139 | 141 |
| 140 // We always need to push properties. | 142 // We always need to push properties. |
| 141 // See http://crbug.com/303943 | 143 // See http://crbug.com/303943 |
| 142 // TODO(danakj): Stop always pushing properties since we don't swap tilings. | 144 // TODO(danakj): Stop always pushing properties since we don't swap tilings. |
| 143 layer_tree_impl()->AddLayerShouldPushProperties(this); | 145 layer_tree_impl()->AddLayerShouldPushProperties(this); |
| 144 } | 146 } |
| 145 | 147 |
| 146 void PictureLayerImpl::AppendQuads(RenderPass* render_pass, | 148 void PictureLayerImpl::AppendQuads(RenderPass* render_pass, |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 if (layer_tree_impl()->IsPendingTree()) { | 867 if (layer_tree_impl()->IsPendingTree()) { |
| 866 // On the pending tree, drop any tilings that are non-ideal since we don't | 868 // On the pending tree, drop any tilings that are non-ideal since we don't |
| 867 // need them to activate anyway. | 869 // need them to activate anyway. |
| 868 tilings_->RemoveNonIdealTilings(); | 870 tilings_->RemoveNonIdealTilings(); |
| 869 } | 871 } |
| 870 | 872 |
| 871 SanityCheckTilingState(); | 873 SanityCheckTilingState(); |
| 872 } | 874 } |
| 873 | 875 |
| 874 bool PictureLayerImpl::ShouldAdjustRasterScale() const { | 876 bool PictureLayerImpl::ShouldAdjustRasterScale() const { |
| 877 // TODO(vmpstr): We might want to adjust the raster scale once in a while. |
| 878 if (is_directly_composited_image_) |
| 879 return false; |
| 880 |
| 875 if (was_screen_space_transform_animating_ != | 881 if (was_screen_space_transform_animating_ != |
| 876 draw_properties().screen_space_transform_is_animating) | 882 draw_properties().screen_space_transform_is_animating) |
| 877 return true; | 883 return true; |
| 878 | 884 |
| 879 if (draw_properties().screen_space_transform_is_animating && | 885 if (draw_properties().screen_space_transform_is_animating && |
| 880 raster_contents_scale_ != ideal_contents_scale_ && | 886 raster_contents_scale_ != ideal_contents_scale_ && |
| 881 ShouldAdjustRasterScaleDuringScaleAnimations()) | 887 ShouldAdjustRasterScaleDuringScaleAnimations()) |
| 882 return true; | 888 return true; |
| 883 | 889 |
| 884 bool is_pinching = layer_tree_impl()->PinchGestureActive(); | 890 bool is_pinching = layer_tree_impl()->PinchGestureActive(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 bool is_pinching = layer_tree_impl()->PinchGestureActive(); | 949 bool is_pinching = layer_tree_impl()->PinchGestureActive(); |
| 944 bool is_animating = draw_properties().screen_space_transform_is_animating; | 950 bool is_animating = draw_properties().screen_space_transform_is_animating; |
| 945 if (!is_pinching && !is_animating) { | 951 if (!is_pinching && !is_animating) { |
| 946 if (!low_res) | 952 if (!low_res) |
| 947 low_res = AddTiling(low_res_raster_contents_scale_); | 953 low_res = AddTiling(low_res_raster_contents_scale_); |
| 948 low_res->set_resolution(LOW_RESOLUTION); | 954 low_res->set_resolution(LOW_RESOLUTION); |
| 949 } | 955 } |
| 950 } | 956 } |
| 951 | 957 |
| 952 void PictureLayerImpl::RecalculateRasterScales() { | 958 void PictureLayerImpl::RecalculateRasterScales() { |
| 959 // TODO(vmpstr): We might want to adjust these once in a while. |
| 960 if (is_directly_composited_image_) { |
| 961 raster_page_scale_ = 1.f; |
| 962 raster_device_scale_ = 1.f; |
| 963 raster_source_scale_ = std::max(1.f, MinimumContentsScale()); |
| 964 raster_contents_scale_ = raster_source_scale_; |
| 965 low_res_raster_contents_scale_ = raster_contents_scale_; |
| 966 return; |
| 967 } |
| 968 |
| 953 float old_raster_contents_scale = raster_contents_scale_; | 969 float old_raster_contents_scale = raster_contents_scale_; |
| 954 float old_raster_page_scale = raster_page_scale_; | 970 float old_raster_page_scale = raster_page_scale_; |
| 955 | 971 |
| 956 raster_device_scale_ = ideal_device_scale_; | 972 raster_device_scale_ = ideal_device_scale_; |
| 957 raster_page_scale_ = ideal_page_scale_; | 973 raster_page_scale_ = ideal_page_scale_; |
| 958 raster_source_scale_ = ideal_source_scale_; | 974 raster_source_scale_ = ideal_source_scale_; |
| 959 raster_contents_scale_ = ideal_contents_scale_; | 975 raster_contents_scale_ = ideal_contents_scale_; |
| 960 | 976 |
| 961 // During pinch we completely ignore the current ideal scale, and just use | 977 // During pinch we completely ignore the current ideal scale, and just use |
| 962 // a multiple of the previous scale. | 978 // a multiple of the previous scale. |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 const LayerTreeSettings& settings = layer_tree_impl()->settings(); | 1188 const LayerTreeSettings& settings = layer_tree_impl()->settings(); |
| 1173 return PictureLayerTilingSet::Create( | 1189 return PictureLayerTilingSet::Create( |
| 1174 GetTree(), this, settings.tiling_interest_area_padding, | 1190 GetTree(), this, settings.tiling_interest_area_padding, |
| 1175 layer_tree_impl()->use_gpu_rasterization() | 1191 layer_tree_impl()->use_gpu_rasterization() |
| 1176 ? settings.gpu_rasterization_skewport_target_time_in_seconds | 1192 ? settings.gpu_rasterization_skewport_target_time_in_seconds |
| 1177 : settings.skewport_target_time_in_seconds, | 1193 : settings.skewport_target_time_in_seconds, |
| 1178 settings.skewport_extrapolation_limit_in_screen_pixels); | 1194 settings.skewport_extrapolation_limit_in_screen_pixels); |
| 1179 } | 1195 } |
| 1180 | 1196 |
| 1181 void PictureLayerImpl::UpdateIdealScales() { | 1197 void PictureLayerImpl::UpdateIdealScales() { |
| 1198 // TODO(vmpstr): We might want to adjust these once in a while. |
| 1199 if (is_directly_composited_image_) { |
| 1200 ideal_contents_scale_ = 1.f; |
| 1201 ideal_page_scale_ = 1.f; |
| 1202 ideal_device_scale_ = 1.f; |
| 1203 ideal_source_scale_ = 1.f; |
| 1204 return; |
| 1205 } |
| 1206 |
| 1182 DCHECK(CanHaveTilings()); | 1207 DCHECK(CanHaveTilings()); |
| 1183 | 1208 |
| 1184 float min_contents_scale = MinimumContentsScale(); | 1209 float min_contents_scale = MinimumContentsScale(); |
| 1185 DCHECK_GT(min_contents_scale, 0.f); | 1210 DCHECK_GT(min_contents_scale, 0.f); |
| 1186 | 1211 |
| 1187 ideal_page_scale_ = IsAffectedByPageScale() | 1212 ideal_page_scale_ = IsAffectedByPageScale() |
| 1188 ? layer_tree_impl()->current_page_scale_factor() | 1213 ? layer_tree_impl()->current_page_scale_factor() |
| 1189 : 1.f; | 1214 : 1.f; |
| 1190 ideal_device_scale_ = layer_tree_impl()->device_scale_factor(); | 1215 ideal_device_scale_ = layer_tree_impl()->device_scale_factor(); |
| 1191 ideal_contents_scale_ = std::max(GetIdealContentsScale(), min_contents_scale); | 1216 ideal_contents_scale_ = std::max(GetIdealContentsScale(), min_contents_scale); |
| 1192 ideal_source_scale_ = | 1217 ideal_source_scale_ = |
| 1193 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; | 1218 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; |
| 1194 } | 1219 } |
| 1195 | 1220 |
| 1196 void PictureLayerImpl::GetDebugBorderProperties( | 1221 void PictureLayerImpl::GetDebugBorderProperties( |
| 1197 SkColor* color, | 1222 SkColor* color, |
| 1198 float* width) const { | 1223 float* width) const { |
| 1199 *color = DebugColors::TiledContentLayerBorderColor(); | 1224 if (is_directly_composited_image_) { |
| 1200 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); | 1225 *color = DebugColors::ImageLayerBorderColor(); |
| 1226 *width = DebugColors::ImageLayerBorderWidth(layer_tree_impl()); |
| 1227 } else { |
| 1228 *color = DebugColors::TiledContentLayerBorderColor(); |
| 1229 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); |
| 1230 } |
| 1201 } | 1231 } |
| 1202 | 1232 |
| 1203 void PictureLayerImpl::GetAllPrioritizedTilesForTracing( | 1233 void PictureLayerImpl::GetAllPrioritizedTilesForTracing( |
| 1204 std::vector<PrioritizedTile>* prioritized_tiles) const { | 1234 std::vector<PrioritizedTile>* prioritized_tiles) const { |
| 1205 if (!tilings_) | 1235 if (!tilings_) |
| 1206 return; | 1236 return; |
| 1207 tilings_->GetAllPrioritizedTilesForTracing(prioritized_tiles); | 1237 tilings_->GetAllPrioritizedTilesForTracing(prioritized_tiles); |
| 1208 } | 1238 } |
| 1209 | 1239 |
| 1210 void PictureLayerImpl::AsValueInto( | 1240 void PictureLayerImpl::AsValueInto( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1291 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
| 1262 return !layer_tree_impl()->IsRecycleTree(); | 1292 return !layer_tree_impl()->IsRecycleTree(); |
| 1263 } | 1293 } |
| 1264 | 1294 |
| 1265 bool PictureLayerImpl::HasValidTilePriorities() const { | 1295 bool PictureLayerImpl::HasValidTilePriorities() const { |
| 1266 return IsOnActiveOrPendingTree() && | 1296 return IsOnActiveOrPendingTree() && |
| 1267 is_drawn_render_surface_layer_list_member(); | 1297 is_drawn_render_surface_layer_list_member(); |
| 1268 } | 1298 } |
| 1269 | 1299 |
| 1270 } // namespace cc | 1300 } // namespace cc |
| OLD | NEW |