Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: cc/layers/picture_layer_impl.cc

Issue 1357423009: gfx: Make conversions from Size to SizeF be explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sizefconvert-gfx: . Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/painted_scrollbar_layer.cc ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 // smaller than what we would choose otherwise, then it's always better off 973 // smaller than what we would choose otherwise, then it's always better off
974 // for us memory-wise. But otherwise, we don't choose a scale at which this 974 // for us memory-wise. But otherwise, we don't choose a scale at which this
975 // layer's rastered content would become larger than the viewport. 975 // layer's rastered content would become larger than the viewport.
976 if (draw_properties().screen_space_transform_is_animating && 976 if (draw_properties().screen_space_transform_is_animating &&
977 !ShouldAdjustRasterScaleDuringScaleAnimations()) { 977 !ShouldAdjustRasterScaleDuringScaleAnimations()) {
978 bool can_raster_at_maximum_scale = false; 978 bool can_raster_at_maximum_scale = false;
979 bool should_raster_at_starting_scale = false; 979 bool should_raster_at_starting_scale = false;
980 float maximum_scale = draw_properties().maximum_animation_contents_scale; 980 float maximum_scale = draw_properties().maximum_animation_contents_scale;
981 float starting_scale = draw_properties().starting_animation_contents_scale; 981 float starting_scale = draw_properties().starting_animation_contents_scale;
982 if (maximum_scale) { 982 if (maximum_scale) {
983 gfx::Size bounds_at_maximum_scale = gfx::ToCeiledSize( 983 gfx::Size bounds_at_maximum_scale =
984 gfx::ScaleSize(raster_source_->GetSize(), maximum_scale)); 984 gfx::ScaleToCeiledSize(raster_source_->GetSize(), maximum_scale);
985 int64 maximum_area = static_cast<int64>(bounds_at_maximum_scale.width()) * 985 int64 maximum_area = static_cast<int64>(bounds_at_maximum_scale.width()) *
986 static_cast<int64>(bounds_at_maximum_scale.height()); 986 static_cast<int64>(bounds_at_maximum_scale.height());
987 gfx::Size viewport = layer_tree_impl()->device_viewport_size(); 987 gfx::Size viewport = layer_tree_impl()->device_viewport_size();
988 int64 viewport_area = static_cast<int64>(viewport.width()) * 988 int64 viewport_area = static_cast<int64>(viewport.width()) *
989 static_cast<int64>(viewport.height()); 989 static_cast<int64>(viewport.height());
990 if (maximum_area <= viewport_area) 990 if (maximum_area <= viewport_area)
991 can_raster_at_maximum_scale = true; 991 can_raster_at_maximum_scale = true;
992 } 992 }
993 if (starting_scale && starting_scale > maximum_scale) { 993 if (starting_scale && starting_scale > maximum_scale) {
994 gfx::Size bounds_at_starting_scale = gfx::ToCeiledSize( 994 gfx::Size bounds_at_starting_scale =
995 gfx::ScaleSize(raster_source_->GetSize(), starting_scale)); 995 gfx::ScaleToCeiledSize(raster_source_->GetSize(), starting_scale);
996 int64 start_area = static_cast<int64>(bounds_at_starting_scale.width()) * 996 int64 start_area = static_cast<int64>(bounds_at_starting_scale.width()) *
997 static_cast<int64>(bounds_at_starting_scale.height()); 997 static_cast<int64>(bounds_at_starting_scale.height());
998 gfx::Size viewport = layer_tree_impl()->device_viewport_size(); 998 gfx::Size viewport = layer_tree_impl()->device_viewport_size();
999 int64 viewport_area = static_cast<int64>(viewport.width()) * 999 int64 viewport_area = static_cast<int64>(viewport.width()) *
1000 static_cast<int64>(viewport.height()); 1000 static_cast<int64>(viewport.height());
1001 if (start_area <= viewport_area) 1001 if (start_area <= viewport_area)
1002 should_raster_at_starting_scale = true; 1002 should_raster_at_starting_scale = true;
1003 } 1003 }
1004 // Use the computed scales for the raster scale directly, do not try to use 1004 // Use the computed scales for the raster scale directly, do not try to use
1005 // the ideal scale here. The current ideal scale may be way too large in the 1005 // the ideal scale here. The current ideal scale may be way too large in the
1006 // case of an animation with scale, and will be constantly changing. 1006 // case of an animation with scale, and will be constantly changing.
1007 if (should_raster_at_starting_scale) 1007 if (should_raster_at_starting_scale)
1008 raster_contents_scale_ = starting_scale; 1008 raster_contents_scale_ = starting_scale;
1009 else if (can_raster_at_maximum_scale) 1009 else if (can_raster_at_maximum_scale)
1010 raster_contents_scale_ = maximum_scale; 1010 raster_contents_scale_ = maximum_scale;
1011 else 1011 else
1012 raster_contents_scale_ = 1.f * ideal_page_scale_ * ideal_device_scale_; 1012 raster_contents_scale_ = 1.f * ideal_page_scale_ * ideal_device_scale_;
1013 } 1013 }
1014 1014
1015 raster_contents_scale_ = 1015 raster_contents_scale_ =
1016 std::max(raster_contents_scale_, MinimumContentsScale()); 1016 std::max(raster_contents_scale_, MinimumContentsScale());
1017 raster_contents_scale_ = 1017 raster_contents_scale_ =
1018 std::min(raster_contents_scale_, MaximumContentsScale()); 1018 std::min(raster_contents_scale_, MaximumContentsScale());
1019 DCHECK_GE(raster_contents_scale_, MinimumContentsScale()); 1019 DCHECK_GE(raster_contents_scale_, MinimumContentsScale());
1020 DCHECK_LE(raster_contents_scale_, MaximumContentsScale()); 1020 DCHECK_LE(raster_contents_scale_, MaximumContentsScale());
1021 1021
1022 // If this layer would create zero or one tiles at this content scale, 1022 // If this layer would create zero or one tiles at this content scale,
1023 // don't create a low res tiling. 1023 // don't create a low res tiling.
1024 gfx::Size raster_bounds = gfx::ToCeiledSize( 1024 gfx::Size raster_bounds =
1025 gfx::ScaleSize(raster_source_->GetSize(), raster_contents_scale_)); 1025 gfx::ScaleToCeiledSize(raster_source_->GetSize(), raster_contents_scale_);
1026 gfx::Size tile_size = CalculateTileSize(raster_bounds); 1026 gfx::Size tile_size = CalculateTileSize(raster_bounds);
1027 bool tile_covers_bounds = tile_size.width() >= raster_bounds.width() && 1027 bool tile_covers_bounds = tile_size.width() >= raster_bounds.width() &&
1028 tile_size.height() >= raster_bounds.height(); 1028 tile_size.height() >= raster_bounds.height();
1029 if (tile_size.IsEmpty() || tile_covers_bounds) { 1029 if (tile_size.IsEmpty() || tile_covers_bounds) {
1030 low_res_raster_contents_scale_ = raster_contents_scale_; 1030 low_res_raster_contents_scale_ = raster_contents_scale_;
1031 return; 1031 return;
1032 } 1032 }
1033 1033
1034 float low_res_factor = 1034 float low_res_factor =
1035 layer_tree_impl()->settings().low_res_contents_scale_factor; 1035 layer_tree_impl()->settings().low_res_contents_scale_factor;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 1246
1247 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { 1247 bool PictureLayerImpl::IsOnActiveOrPendingTree() const {
1248 return !layer_tree_impl()->IsRecycleTree(); 1248 return !layer_tree_impl()->IsRecycleTree();
1249 } 1249 }
1250 1250
1251 bool PictureLayerImpl::HasValidTilePriorities() const { 1251 bool PictureLayerImpl::HasValidTilePriorities() const {
1252 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); 1252 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember();
1253 } 1253 }
1254 1254
1255 } // namespace cc 1255 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/painted_scrollbar_layer.cc ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698