| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 const int kMinHeightForGpuRasteredTile = 256; | 49 const int kMinHeightForGpuRasteredTile = 256; |
| 50 | 50 |
| 51 // When making odd-sized tiles, round them up to increase the chances | 51 // When making odd-sized tiles, round them up to increase the chances |
| 52 // of using the same tile size. | 52 // of using the same tile size. |
| 53 const int kTileRoundUp = 64; | 53 const int kTileRoundUp = 64; |
| 54 | 54 |
| 55 // For performance reasons and to support compressed tile textures, tile | 55 // For performance reasons and to support compressed tile textures, tile |
| 56 // width and height should be an even multiple of 4 in size. | 56 // width and height should be an even multiple of 4 in size. |
| 57 const int kTileMinimalAlignment = 4; | 57 const int kTileMinimalAlignment = 4; |
| 58 | 58 |
| 59 // Large contents scale can cause overflow issues. Cap the ideal contents scale |
| 60 // by this constant, since scales larger than this are usually not correct or |
| 61 // their scale doesn't matter as long as it's large. See |
| 62 // Renderer4.IdealContentsScale UMA for distribution of existing contents |
| 63 // scales. |
| 64 const float kMaxIdealContentsScale = 10000.f; |
| 65 |
| 59 // Intersect rects which may have right() and bottom() that overflow integer | 66 // Intersect rects which may have right() and bottom() that overflow integer |
| 60 // boundaries. This code is similar to gfx::Rect::Intersect with the exception | 67 // boundaries. This code is similar to gfx::Rect::Intersect with the exception |
| 61 // that the types are promoted to int64_t when there is a chance of overflow. | 68 // that the types are promoted to int64_t when there is a chance of overflow. |
| 62 gfx::Rect SafeIntersectRects(const gfx::Rect& one, const gfx::Rect& two) { | 69 gfx::Rect SafeIntersectRects(const gfx::Rect& one, const gfx::Rect& two) { |
| 63 if (one.IsEmpty() || two.IsEmpty()) | 70 if (one.IsEmpty() || two.IsEmpty()) |
| 64 return gfx::Rect(); | 71 return gfx::Rect(); |
| 65 | 72 |
| 66 int rx = std::max(one.x(), two.x()); | 73 int rx = std::max(one.x(), two.x()); |
| 67 int ry = std::max(one.y(), two.y()); | 74 int ry = std::max(one.y(), two.y()); |
| 68 int64_t rr = std::min(static_cast<int64_t>(one.x()) + one.width(), | 75 int64_t rr = std::min(static_cast<int64_t>(one.x()) + one.width(), |
| (...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 void PictureLayerImpl::UpdateIdealScales() { | 1247 void PictureLayerImpl::UpdateIdealScales() { |
| 1241 DCHECK(CanHaveTilings()); | 1248 DCHECK(CanHaveTilings()); |
| 1242 | 1249 |
| 1243 float min_contents_scale = MinimumContentsScale(); | 1250 float min_contents_scale = MinimumContentsScale(); |
| 1244 DCHECK_GT(min_contents_scale, 0.f); | 1251 DCHECK_GT(min_contents_scale, 0.f); |
| 1245 | 1252 |
| 1246 ideal_page_scale_ = IsAffectedByPageScale() | 1253 ideal_page_scale_ = IsAffectedByPageScale() |
| 1247 ? layer_tree_impl()->current_page_scale_factor() | 1254 ? layer_tree_impl()->current_page_scale_factor() |
| 1248 : 1.f; | 1255 : 1.f; |
| 1249 ideal_device_scale_ = layer_tree_impl()->device_scale_factor(); | 1256 ideal_device_scale_ = layer_tree_impl()->device_scale_factor(); |
| 1250 ideal_contents_scale_ = std::max(GetIdealContentsScale(), min_contents_scale); | 1257 ideal_contents_scale_ = |
| 1258 std::min(kMaxIdealContentsScale, |
| 1259 std::max(GetIdealContentsScale(), min_contents_scale)); |
| 1251 ideal_source_scale_ = | 1260 ideal_source_scale_ = |
| 1252 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; | 1261 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; |
| 1253 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.IdealContentsScale", | 1262 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.IdealContentsScale", |
| 1254 ideal_contents_scale_, 0, 10000, 50); | 1263 ideal_contents_scale_, 0, 10000, 50); |
| 1255 } | 1264 } |
| 1256 | 1265 |
| 1257 void PictureLayerImpl::GetDebugBorderProperties( | 1266 void PictureLayerImpl::GetDebugBorderProperties( |
| 1258 SkColor* color, | 1267 SkColor* color, |
| 1259 float* width) const { | 1268 float* width) const { |
| 1260 if (is_directly_composited_image_) { | 1269 if (is_directly_composited_image_) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1327 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1336 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
| 1328 return !layer_tree_impl()->IsRecycleTree(); | 1337 return !layer_tree_impl()->IsRecycleTree(); |
| 1329 } | 1338 } |
| 1330 | 1339 |
| 1331 bool PictureLayerImpl::HasValidTilePriorities() const { | 1340 bool PictureLayerImpl::HasValidTilePriorities() const { |
| 1332 return IsOnActiveOrPendingTree() && | 1341 return IsOnActiveOrPendingTree() && |
| 1333 is_drawn_render_surface_layer_list_member(); | 1342 is_drawn_render_surface_layer_list_member(); |
| 1334 } | 1343 } |
| 1335 | 1344 |
| 1336 } // namespace cc | 1345 } // namespace cc |
| OLD | NEW |