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/resources/picture_pile.h" | 5 #include "cc/resources/picture_pile.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "cc/base/region.h" | 10 #include "cc/base/region.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 RenderingStats* stats) { | 39 RenderingStats* stats) { |
40 background_color_ = background_color; | 40 background_color_ = background_color; |
41 | 41 |
42 gfx::Rect interest_rect = visible_layer_rect; | 42 gfx::Rect interest_rect = visible_layer_rect; |
43 interest_rect.Inset( | 43 interest_rect.Inset( |
44 -kPixelDistanceToRecord, | 44 -kPixelDistanceToRecord, |
45 -kPixelDistanceToRecord, | 45 -kPixelDistanceToRecord, |
46 -kPixelDistanceToRecord, | 46 -kPixelDistanceToRecord, |
47 -kPixelDistanceToRecord); | 47 -kPixelDistanceToRecord); |
48 for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { | 48 for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { |
49 // Inflate all recordings from invalidations with a margin so that when | 49 gfx::Rect invalidation = i.rect(); |
50 // scaled down to at least min_contents_scale, any final pixel touched by an | |
51 // invalidation can be fully rasterized by this picture. | |
52 gfx::Rect inflated_invalidation = i.rect(); | |
53 inflated_invalidation.Inset( | |
54 -buffer_pixels(), | |
55 -buffer_pixels(), | |
56 -buffer_pixels(), | |
57 -buffer_pixels()); | |
58 // Split this inflated invalidation across tile boundaries and apply it | 50 // Split this inflated invalidation across tile boundaries and apply it |
59 // to all tiles that it touches. | 51 // to all tiles that it touches. |
60 for (TilingData::Iterator iter(&tiling_, inflated_invalidation); | 52 for (TilingData::Iterator iter(&tiling_, invalidation); |
61 iter; ++iter) { | 53 iter; ++iter) { |
62 gfx::Rect tile = | 54 gfx::Rect tile = |
63 tiling_.TileBoundsWithBorder(iter.index_x(), iter.index_y()); | 55 tiling_.TileBoundsWithBorder(iter.index_x(), iter.index_y()); |
64 if (!tile.Intersects(interest_rect)) { | 56 if (!tile.Intersects(interest_rect)) { |
65 // This invalidation touches a tile outside the interest rect, so | 57 // This invalidation touches a tile outside the interest rect, so |
66 // just remove the entire picture list. | 58 // just remove the entire picture list. |
67 picture_list_map_.erase(iter.index()); | 59 picture_list_map_.erase(iter.index()); |
68 continue; | 60 continue; |
69 } | 61 } |
70 | 62 |
71 gfx::Rect tile_invalidation = | 63 gfx::Rect tile_invalidation = gfx::IntersectRects(invalidation, tile); |
72 gfx::IntersectRects(inflated_invalidation, tile); | |
73 if (tile_invalidation.IsEmpty()) | 64 if (tile_invalidation.IsEmpty()) |
74 continue; | 65 continue; |
75 PictureListMap::iterator find = picture_list_map_.find(iter.index()); | 66 PictureListMap::iterator find = picture_list_map_.find(iter.index()); |
76 if (find == picture_list_map_.end()) | 67 if (find == picture_list_map_.end()) |
77 continue; | 68 continue; |
78 PictureList& pic_list = find->second; | 69 PictureList& pic_list = find->second; |
79 // Leave empty pic_lists empty in case there are multiple invalidations. | 70 // Leave empty pic_lists empty in case there are multiple invalidations. |
80 if (!pic_list.empty()) | 71 if (!pic_list.empty()) { |
| 72 // Inflate all recordings from invalidations with a margin so that when |
| 73 // scaled down to at least min_contents_scale, any final pixel touched |
| 74 // by an invalidation can be fully rasterized by this picture. |
| 75 tile_invalidation.Inset(-buffer_pixels(), -buffer_pixels()); |
| 76 |
| 77 DCHECK_GE(tile_invalidation.width(), buffer_pixels() * 2 + 1); |
| 78 DCHECK_GE(tile_invalidation.height(), buffer_pixels() * 2 + 1); |
| 79 |
81 InvalidateRect(pic_list, tile_invalidation); | 80 InvalidateRect(pic_list, tile_invalidation); |
| 81 } |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 // Walk through all pictures in the rect of interest and record. | 85 // Walk through all pictures in the rect of interest and record. |
86 for (TilingData::Iterator iter(&tiling_, interest_rect); iter; ++iter) { | 86 for (TilingData::Iterator iter(&tiling_, interest_rect); iter; ++iter) { |
87 // Create a picture in this list if it doesn't exist. | 87 // Create a picture in this list if it doesn't exist. |
88 PictureList& pic_list = picture_list_map_[iter.index()]; | 88 PictureList& pic_list = picture_list_map_[iter.index()]; |
89 if (pic_list.empty()) { | 89 if (pic_list.empty()) { |
90 // Inflate the base picture with a margin, similar to invalidations, so | 90 // Inflate the base picture with a margin, similar to invalidations, so |
91 // that when scaled down to at least min_contents_scale, the enclosed | 91 // that when scaled down to at least min_contents_scale, the enclosed |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 FullyContainedPredicate pred(picture_rect); | 153 FullyContainedPredicate pred(picture_rect); |
154 picture_list.erase(std::remove_if(picture_list.begin(), | 154 picture_list.erase(std::remove_if(picture_list.begin(), |
155 picture_list.end(), | 155 picture_list.end(), |
156 pred), | 156 pred), |
157 picture_list.end()); | 157 picture_list.end()); |
158 picture_list.push_back(Picture::Create(picture_rect)); | 158 picture_list.push_back(Picture::Create(picture_rect)); |
159 } | 159 } |
160 | 160 |
161 } // namespace cc | 161 } // namespace cc |
OLD | NEW |