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

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: for windows 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
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 for (int i = 0; i < 2; ++i) {
enne (OOO) 2013/05/03 07:00:57 This is not right. It's not just for scaling down
danakj 2013/05/03 17:49:20 Okay so let me see if I'm understanding correctly.
76 int width_inflate = 0;
77 int height_inflate = 0;
78 if (tile_invalidation.width() < buffer_pixels() * 2 + 1)
79 width_inflate = buffer_pixels();
80 if (tile_invalidation.height() < buffer_pixels() * 2 + 1)
81 height_inflate = buffer_pixels();
82 if (!width_inflate && !height_inflate)
83 break;
84 tile_invalidation.Inset(-width_inflate, -height_inflate);
85 tile_invalidation.Intersect(tile);
86 }
87
88 DCHECK_GE(tile_invalidation.width(), buffer_pixels() * 2 + 1);
89 DCHECK_GE(tile_invalidation.height(), buffer_pixels() * 2 + 1);
90
81 InvalidateRect(pic_list, tile_invalidation); 91 InvalidateRect(pic_list, tile_invalidation);
92 }
82 } 93 }
83 } 94 }
84 95
85 // Walk through all pictures in the rect of interest and record. 96 // Walk through all pictures in the rect of interest and record.
86 for (TilingData::Iterator iter(&tiling_, interest_rect); iter; ++iter) { 97 for (TilingData::Iterator iter(&tiling_, interest_rect); iter; ++iter) {
87 // Create a picture in this list if it doesn't exist. 98 // Create a picture in this list if it doesn't exist.
88 PictureList& pic_list = picture_list_map_[iter.index()]; 99 PictureList& pic_list = picture_list_map_[iter.index()];
89 if (pic_list.empty()) { 100 if (pic_list.empty()) {
90 // Inflate the base picture with a margin, similar to invalidations, so 101 // Inflate the base picture with a margin, similar to invalidations, so
91 // that when scaled down to at least min_contents_scale, the enclosed 102 // 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 162
152 FullyContainedPredicate pred(picture_rect); 163 FullyContainedPredicate pred(picture_rect);
153 picture_list.erase(std::remove_if(picture_list.begin(), 164 picture_list.erase(std::remove_if(picture_list.begin(),
154 picture_list.end(), 165 picture_list.end(),
155 pred), 166 pred),
156 picture_list.end()); 167 picture_list.end());
157 picture_list.push_back(Picture::Create(picture_rect)); 168 picture_list.push_back(Picture::Create(picture_rect));
158 } 169 }
159 170
160 } // namespace cc 171 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698