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

Side by Side Diff: cc/resources/picture_pile.cc

Issue 14874004: cc: Inflate invalidation in each picture list (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review+tests Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « cc/resources/picture_pile.h ('k') | cc/resources/picture_pile_impl.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/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
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 tile_invalidation.Intersect(tile);
77
78 // Make sure that the invalidation is at least large enough to cover a
79 // single rastered pixel when scaled down by any scale no smaller than
80 // the minimum contents scale. This means ensuring the resulting rect
81 // is at least (2 * buffer_pixels() + 1) large in each dimension.
82 //
83 // Because we already inflated by buffer_pixels() in each direction,
84 // and the |tile| is larger than our required minimum size, the
85 // intersection will only drop at most buffer_pixels() from the
86 // invalidation rect in each dimension. Inflating and intersecting once
87 // more will give us the minimum size required.
88 if (tile_invalidation.width() < buffer_pixels() * 2 + 1)
enne (OOO) 2013/05/05 01:26:47 Sorry, but no? It's not about total width. It's
danakj 2013/05/06 14:40:06 Hm, I am not sure if I agree, so let's make some p
89 tile_invalidation.Inset(-buffer_pixels(), 0);
90 if (tile_invalidation.height() < buffer_pixels() * 2 + 1)
91 tile_invalidation.Inset(0, -buffer_pixels());
92 tile_invalidation.Intersect(tile);
93
94 DCHECK_GE(tile_invalidation.width(), buffer_pixels() * 2 + 1);
95 DCHECK_GE(tile_invalidation.height(), buffer_pixels() * 2 + 1);
96
81 InvalidateRect(pic_list, tile_invalidation); 97 InvalidateRect(pic_list, tile_invalidation);
98 }
82 } 99 }
83 } 100 }
84 101
85 // Walk through all pictures in the rect of interest and record. 102 // Walk through all pictures in the rect of interest and record.
86 for (TilingData::Iterator iter(&tiling_, interest_rect); iter; ++iter) { 103 for (TilingData::Iterator iter(&tiling_, interest_rect); iter; ++iter) {
87 // Create a picture in this list if it doesn't exist. 104 // Create a picture in this list if it doesn't exist.
88 PictureList& pic_list = picture_list_map_[iter.index()]; 105 PictureList& pic_list = picture_list_map_[iter.index()];
89 if (pic_list.empty()) { 106 if (pic_list.empty()) {
90 // Inflate the base picture with a margin, similar to invalidations, so 107 // Inflate the base picture with a margin, similar to invalidations, so
91 // that when scaled down to at least min_contents_scale, the enclosed 108 // that when scaled down to at least min_contents_scale, the enclosed
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 168
152 FullyContainedPredicate pred(picture_rect); 169 FullyContainedPredicate pred(picture_rect);
153 picture_list.erase(std::remove_if(picture_list.begin(), 170 picture_list.erase(std::remove_if(picture_list.begin(),
154 picture_list.end(), 171 picture_list.end(),
155 pred), 172 pred),
156 picture_list.end()); 173 picture_list.end());
157 picture_list.push_back(Picture::Create(picture_rect)); 174 picture_list.push_back(Picture::Create(picture_rect));
158 } 175 }
159 176
160 } // namespace cc 177 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_pile.h ('k') | cc/resources/picture_pile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698