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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 geometry_rect.Intersect(scaled_recorded_viewport); | 190 geometry_rect.Intersect(scaled_recorded_viewport); |
191 opaque_rect.Intersect(scaled_recorded_viewport); | 191 opaque_rect.Intersect(scaled_recorded_viewport); |
192 visible_geometry_rect.Intersect(scaled_recorded_viewport); | 192 visible_geometry_rect.Intersect(scaled_recorded_viewport); |
193 | 193 |
194 if (visible_geometry_rect.IsEmpty()) | 194 if (visible_geometry_rect.IsEmpty()) |
195 return; | 195 return; |
196 | 196 |
197 DCHECK(raster_source_->HasRecordings()); | 197 DCHECK(raster_source_->HasRecordings()); |
198 gfx::Rect quad_content_rect = shared_quad_state->visible_quad_layer_rect; | 198 gfx::Rect quad_content_rect = shared_quad_state->visible_quad_layer_rect; |
199 gfx::Size texture_size = quad_content_rect.size(); | 199 gfx::Size texture_size = quad_content_rect.size(); |
200 gfx::RectF texture_rect = gfx::RectF(texture_size); | 200 gfx::RectF texture_rect = gfx::RectF(gfx::SizeF(texture_size)); |
201 | 201 |
202 PictureDrawQuad* quad = | 202 PictureDrawQuad* quad = |
203 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); | 203 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); |
204 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, | 204 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, |
205 visible_geometry_rect, texture_rect, texture_size, | 205 visible_geometry_rect, texture_rect, texture_size, |
206 nearest_neighbor_, RGBA_8888, quad_content_rect, | 206 nearest_neighbor_, RGBA_8888, quad_content_rect, |
207 max_contents_scale, raster_source_); | 207 max_contents_scale, raster_source_); |
208 ValidateQuadResources(quad); | 208 ValidateQuadResources(quad); |
209 return; | 209 return; |
210 } | 210 } |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 // smaller than what we would choose otherwise, then it's always better off | 970 // smaller than what we would choose otherwise, then it's always better off |
971 // for us memory-wise. But otherwise, we don't choose a scale at which this | 971 // for us memory-wise. But otherwise, we don't choose a scale at which this |
972 // layer's rastered content would become larger than the viewport. | 972 // layer's rastered content would become larger than the viewport. |
973 if (draw_properties().screen_space_transform_is_animating && | 973 if (draw_properties().screen_space_transform_is_animating && |
974 !ShouldAdjustRasterScaleDuringScaleAnimations()) { | 974 !ShouldAdjustRasterScaleDuringScaleAnimations()) { |
975 bool can_raster_at_maximum_scale = false; | 975 bool can_raster_at_maximum_scale = false; |
976 bool should_raster_at_starting_scale = false; | 976 bool should_raster_at_starting_scale = false; |
977 float maximum_scale = draw_properties().maximum_animation_contents_scale; | 977 float maximum_scale = draw_properties().maximum_animation_contents_scale; |
978 float starting_scale = draw_properties().starting_animation_contents_scale; | 978 float starting_scale = draw_properties().starting_animation_contents_scale; |
979 if (maximum_scale) { | 979 if (maximum_scale) { |
980 gfx::Size bounds_at_maximum_scale = gfx::ToCeiledSize( | 980 gfx::Size bounds_at_maximum_scale = |
981 gfx::ScaleSize(raster_source_->GetSize(), maximum_scale)); | 981 gfx::ScaleToCeiledSize(raster_source_->GetSize(), maximum_scale); |
982 int64 maximum_area = static_cast<int64>(bounds_at_maximum_scale.width()) * | 982 int64 maximum_area = static_cast<int64>(bounds_at_maximum_scale.width()) * |
983 static_cast<int64>(bounds_at_maximum_scale.height()); | 983 static_cast<int64>(bounds_at_maximum_scale.height()); |
984 gfx::Size viewport = layer_tree_impl()->device_viewport_size(); | 984 gfx::Size viewport = layer_tree_impl()->device_viewport_size(); |
985 int64 viewport_area = static_cast<int64>(viewport.width()) * | 985 int64 viewport_area = static_cast<int64>(viewport.width()) * |
986 static_cast<int64>(viewport.height()); | 986 static_cast<int64>(viewport.height()); |
987 if (maximum_area <= viewport_area) | 987 if (maximum_area <= viewport_area) |
988 can_raster_at_maximum_scale = true; | 988 can_raster_at_maximum_scale = true; |
989 } | 989 } |
990 if (starting_scale && starting_scale > maximum_scale) { | 990 if (starting_scale && starting_scale > maximum_scale) { |
991 gfx::Size bounds_at_starting_scale = gfx::ToCeiledSize( | 991 gfx::Size bounds_at_starting_scale = |
992 gfx::ScaleSize(raster_source_->GetSize(), starting_scale)); | 992 gfx::ScaleToCeiledSize(raster_source_->GetSize(), starting_scale); |
993 int64 start_area = static_cast<int64>(bounds_at_starting_scale.width()) * | 993 int64 start_area = static_cast<int64>(bounds_at_starting_scale.width()) * |
994 static_cast<int64>(bounds_at_starting_scale.height()); | 994 static_cast<int64>(bounds_at_starting_scale.height()); |
995 gfx::Size viewport = layer_tree_impl()->device_viewport_size(); | 995 gfx::Size viewport = layer_tree_impl()->device_viewport_size(); |
996 int64 viewport_area = static_cast<int64>(viewport.width()) * | 996 int64 viewport_area = static_cast<int64>(viewport.width()) * |
997 static_cast<int64>(viewport.height()); | 997 static_cast<int64>(viewport.height()); |
998 if (start_area <= viewport_area) | 998 if (start_area <= viewport_area) |
999 should_raster_at_starting_scale = true; | 999 should_raster_at_starting_scale = true; |
1000 } | 1000 } |
1001 // Use the computed scales for the raster scale directly, do not try to use | 1001 // Use the computed scales for the raster scale directly, do not try to use |
1002 // the ideal scale here. The current ideal scale may be way too large in the | 1002 // the ideal scale here. The current ideal scale may be way too large in the |
1003 // case of an animation with scale, and will be constantly changing. | 1003 // case of an animation with scale, and will be constantly changing. |
1004 if (should_raster_at_starting_scale) | 1004 if (should_raster_at_starting_scale) |
1005 raster_contents_scale_ = starting_scale; | 1005 raster_contents_scale_ = starting_scale; |
1006 else if (can_raster_at_maximum_scale) | 1006 else if (can_raster_at_maximum_scale) |
1007 raster_contents_scale_ = maximum_scale; | 1007 raster_contents_scale_ = maximum_scale; |
1008 else | 1008 else |
1009 raster_contents_scale_ = 1.f * ideal_page_scale_ * ideal_device_scale_; | 1009 raster_contents_scale_ = 1.f * ideal_page_scale_ * ideal_device_scale_; |
1010 } | 1010 } |
1011 | 1011 |
1012 raster_contents_scale_ = | 1012 raster_contents_scale_ = |
1013 std::max(raster_contents_scale_, MinimumContentsScale()); | 1013 std::max(raster_contents_scale_, MinimumContentsScale()); |
1014 raster_contents_scale_ = | 1014 raster_contents_scale_ = |
1015 std::min(raster_contents_scale_, MaximumContentsScale()); | 1015 std::min(raster_contents_scale_, MaximumContentsScale()); |
1016 DCHECK_GE(raster_contents_scale_, MinimumContentsScale()); | 1016 DCHECK_GE(raster_contents_scale_, MinimumContentsScale()); |
1017 DCHECK_LE(raster_contents_scale_, MaximumContentsScale()); | 1017 DCHECK_LE(raster_contents_scale_, MaximumContentsScale()); |
1018 | 1018 |
1019 // If this layer would create zero or one tiles at this content scale, | 1019 // If this layer would create zero or one tiles at this content scale, |
1020 // don't create a low res tiling. | 1020 // don't create a low res tiling. |
1021 gfx::Size raster_bounds = gfx::ToCeiledSize( | 1021 gfx::Size raster_bounds = |
1022 gfx::ScaleSize(raster_source_->GetSize(), raster_contents_scale_)); | 1022 gfx::ScaleToCeiledSize(raster_source_->GetSize(), raster_contents_scale_); |
1023 gfx::Size tile_size = CalculateTileSize(raster_bounds); | 1023 gfx::Size tile_size = CalculateTileSize(raster_bounds); |
1024 bool tile_covers_bounds = tile_size.width() >= raster_bounds.width() && | 1024 bool tile_covers_bounds = tile_size.width() >= raster_bounds.width() && |
1025 tile_size.height() >= raster_bounds.height(); | 1025 tile_size.height() >= raster_bounds.height(); |
1026 if (tile_size.IsEmpty() || tile_covers_bounds) { | 1026 if (tile_size.IsEmpty() || tile_covers_bounds) { |
1027 low_res_raster_contents_scale_ = raster_contents_scale_; | 1027 low_res_raster_contents_scale_ = raster_contents_scale_; |
1028 return; | 1028 return; |
1029 } | 1029 } |
1030 | 1030 |
1031 float low_res_factor = | 1031 float low_res_factor = |
1032 layer_tree_impl()->settings().low_res_contents_scale_factor; | 1032 layer_tree_impl()->settings().low_res_contents_scale_factor; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 | 1243 |
1244 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1244 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
1245 return !layer_tree_impl()->IsRecycleTree(); | 1245 return !layer_tree_impl()->IsRecycleTree(); |
1246 } | 1246 } |
1247 | 1247 |
1248 bool PictureLayerImpl::HasValidTilePriorities() const { | 1248 bool PictureLayerImpl::HasValidTilePriorities() const { |
1249 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1249 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
1250 } | 1250 } |
1251 | 1251 |
1252 } // namespace cc | 1252 } // namespace cc |
OLD | NEW |