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

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

Issue 2234183002: cc: Change visible rect in content space calculation to not overflow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | no next file » | 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 <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
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 // Intersect rects which may have right() and bottom() that overflow integer
60 // 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.
62 gfx::Rect SafeIntersectRects(const gfx::Rect& one, const gfx::Rect& two) {
63 if (one.IsEmpty() || two.IsEmpty())
64 return gfx::Rect();
65
66 int rx = std::max(one.x(), two.x());
67 int ry = std::max(one.y(), two.y());
68 int64_t rr = std::min(static_cast<int64_t>(one.x()) + one.width(),
69 static_cast<int64_t>(two.x()) + two.width());
70 int64_t rb = std::min(static_cast<int64_t>(one.y()) + one.height(),
71 static_cast<int64_t>(two.y()) + two.height());
72 if (rx > rr || ry > rb)
73 return gfx::Rect();
74 return gfx::Rect(rx, ry, static_cast<int>(rr - rx),
75 static_cast<int>(rb - ry));
76 }
77
59 } // namespace 78 } // namespace
60 79
61 namespace cc { 80 namespace cc {
62 81
63 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, 82 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl,
64 int id, 83 int id,
65 bool is_mask) 84 bool is_mask)
66 : LayerImpl(tree_impl, id), 85 : LayerImpl(tree_impl, id),
67 twin_layer_(nullptr), 86 twin_layer_(nullptr),
68 tilings_(CreatePictureLayerTilingSet()), 87 tilings_(CreatePictureLayerTilingSet()),
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 // viewport since it can be very large due to screen_space_transforms. As 527 // viewport since it can be very large due to screen_space_transforms. As
509 // a heuristic, we clip to bounds padded by skewport_extrapolation_limit * 528 // a heuristic, we clip to bounds padded by skewport_extrapolation_limit *
510 // maximum tiling scale, since this should allow sufficient room for 529 // maximum tiling scale, since this should allow sufficient room for
511 // skewport calculations. 530 // skewport calculations.
512 gfx::Rect padded_bounds(bounds()); 531 gfx::Rect padded_bounds(bounds());
513 int padding_amount = layer_tree_impl() 532 int padding_amount = layer_tree_impl()
514 ->settings() 533 ->settings()
515 .skewport_extrapolation_limit_in_screen_pixels * 534 .skewport_extrapolation_limit_in_screen_pixels *
516 MaximumTilingContentsScale(); 535 MaximumTilingContentsScale();
517 padded_bounds.Inset(-padding_amount, -padding_amount); 536 padded_bounds.Inset(-padding_amount, -padding_amount);
518 visible_rect_in_content_space.Intersect(padded_bounds); 537 visible_rect_in_content_space =
538 SafeIntersectRects(visible_rect_in_content_space, padded_bounds);
519 } 539 }
520 } 540 }
521 viewport_rect_for_tile_priority_in_content_space_ = 541 viewport_rect_for_tile_priority_in_content_space_ =
522 visible_rect_in_content_space; 542 visible_rect_in_content_space;
523 } 543 }
524 544
525 PictureLayerImpl* PictureLayerImpl::GetPendingOrActiveTwinLayer() const { 545 PictureLayerImpl* PictureLayerImpl::GetPendingOrActiveTwinLayer() const {
526 if (!twin_layer_ || !twin_layer_->IsOnActiveOrPendingTree()) 546 if (!twin_layer_ || !twin_layer_->IsOnActiveOrPendingTree())
527 return nullptr; 547 return nullptr;
528 return twin_layer_; 548 return twin_layer_;
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { 1327 bool PictureLayerImpl::IsOnActiveOrPendingTree() const {
1308 return !layer_tree_impl()->IsRecycleTree(); 1328 return !layer_tree_impl()->IsRecycleTree();
1309 } 1329 }
1310 1330
1311 bool PictureLayerImpl::HasValidTilePriorities() const { 1331 bool PictureLayerImpl::HasValidTilePriorities() const {
1312 return IsOnActiveOrPendingTree() && 1332 return IsOnActiveOrPendingTree() &&
1313 is_drawn_render_surface_layer_list_member(); 1333 is_drawn_render_surface_layer_list_member();
1314 } 1334 }
1315 1335
1316 } // namespace cc 1336 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698