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

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

Issue 294163009: cc: Expand invalidation to full tile when recording is missing for the tile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pictureslow: complicated. Created 6 years, 6 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 <limits> 8 #include <limits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 } // namespace 140 } // namespace
141 141
142 namespace cc { 142 namespace cc {
143 143
144 PicturePile::PicturePile() : is_suitable_for_gpu_rasterization_(true) {} 144 PicturePile::PicturePile() : is_suitable_for_gpu_rasterization_(true) {}
145 145
146 PicturePile::~PicturePile() { 146 PicturePile::~PicturePile() {
147 } 147 }
148 148
149 bool PicturePile::Update(ContentLayerClient* painter, 149 bool PicturePile::UpdateAndExpandInvalidation(
150 SkColor background_color, 150 ContentLayerClient* painter,
151 bool contents_opaque, 151 Region* invalidation,
152 bool contents_fill_bounds_completely, 152 SkColor background_color,
153 const Region& invalidation, 153 bool contents_opaque,
154 const gfx::Rect& visible_layer_rect, 154 bool contents_fill_bounds_completely,
155 int frame_number, 155 const gfx::Rect& visible_layer_rect,
156 Picture::RecordingMode recording_mode, 156 int frame_number,
157 RenderingStatsInstrumentation* stats_instrumentation) { 157 Picture::RecordingMode recording_mode,
158 RenderingStatsInstrumentation* stats_instrumentation) {
158 background_color_ = background_color; 159 background_color_ = background_color;
159 contents_opaque_ = contents_opaque; 160 contents_opaque_ = contents_opaque;
160 contents_fill_bounds_completely_ = contents_fill_bounds_completely; 161 contents_fill_bounds_completely_ = contents_fill_bounds_completely;
161 162
162 gfx::Rect interest_rect = visible_layer_rect; 163 gfx::Rect interest_rect = visible_layer_rect;
163 interest_rect.Inset( 164 interest_rect.Inset(
164 -kPixelDistanceToRecord, 165 -kPixelDistanceToRecord,
165 -kPixelDistanceToRecord, 166 -kPixelDistanceToRecord,
166 -kPixelDistanceToRecord, 167 -kPixelDistanceToRecord,
167 -kPixelDistanceToRecord); 168 -kPixelDistanceToRecord);
168 recorded_viewport_ = interest_rect; 169 recorded_viewport_ = interest_rect;
169 recorded_viewport_.Intersect(tiling_rect()); 170 recorded_viewport_.Intersect(tiling_rect());
170 171
171 bool invalidated = false; 172 bool invalidated = false;
172 for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { 173 for (Region::Iterator i(*invalidation); i.has_rect(); i.next()) {
173 gfx::Rect invalidation = i.rect(); 174 gfx::Rect invalid_rect = i.rect();
174 // Split this inflated invalidation across tile boundaries and apply it 175 // Split this inflated invalidation across tile boundaries and apply it
175 // to all tiles that it touches. 176 // to all tiles that it touches.
176 bool include_borders = true; 177 bool include_borders = true;
177 for (TilingData::Iterator iter(&tiling_, invalidation, include_borders); 178 for (TilingData::Iterator iter(&tiling_, invalid_rect, include_borders);
178 iter; 179 iter;
179 ++iter) { 180 ++iter) {
180 const PictureMapKey& key = iter.index(); 181 const PictureMapKey& key = iter.index();
181 182
182 PictureMap::iterator picture_it = picture_map_.find(key); 183 PictureMap::iterator picture_it = picture_map_.find(key);
183 if (picture_it == picture_map_.end()) 184 if (picture_it == picture_map_.end())
184 continue; 185 continue;
185 186
186 // Inform the grid cell that it has been invalidated in this frame. 187 // Inform the grid cell that it has been invalidated in this frame.
187 invalidated = picture_it->second.Invalidate(frame_number) || invalidated; 188 invalidated = picture_it->second.Invalidate(frame_number) || invalidated;
188 } 189 }
189 } 190 }
190 191
192 // Expand invalidation that is outside tiles that intersect the interest rect.
193 // These tiles are no longer valid so should be considerered fully invalid, so
194 // we can know to not keep around raster tiles that intersect with these
195 // recording tiles.
196 gfx::Rect interest_rect_over_tiles =
197 tiling_.ExpandRectToTileBounds(interest_rect);
198 Region invalidation_outside_interest_rect_tiles =
199 SubtractRegions(*invalidation, interest_rect_over_tiles);
enne (OOO) 2014/06/17 00:02:54 Region ops like this make me sad, but this is prob
danakj 2014/06/17 18:51:34 For now I used Rect::Subtract instead, which may i
200 for (Region::Iterator i(invalidation_outside_interest_rect_tiles);
201 i.has_rect();
202 i.next()) {
203 gfx::Rect invalid_rect = i.rect();
204 invalidation->Union(tiling_.ExpandRectToTileBounds(invalid_rect));
205 }
206
191 // Make a list of all invalid tiles; we will attempt to 207 // Make a list of all invalid tiles; we will attempt to
192 // cluster these into multiple invalidation regions. 208 // cluster these into multiple invalidation regions.
193 std::vector<gfx::Rect> invalid_tiles; 209 std::vector<gfx::Rect> invalid_tiles;
194 bool include_borders = true; 210 bool include_borders = true;
195 for (TilingData::Iterator it(&tiling_, interest_rect, include_borders); it; 211 for (TilingData::Iterator it(&tiling_, interest_rect, include_borders); it;
196 ++it) { 212 ++it) {
197 const PictureMapKey& key = it.index(); 213 const PictureMapKey& key = it.index();
198 PictureInfo& info = picture_map_[key]; 214 PictureInfo& info = picture_map_[key];
199 215
200 gfx::Rect rect = PaddedRect(key); 216 gfx::Rect rect = PaddedRect(key);
201 int distance_to_visible = 217 int distance_to_visible =
202 rect.ManhattanInternalDistance(visible_layer_rect); 218 rect.ManhattanInternalDistance(visible_layer_rect);
203 219
204 if (info.NeedsRecording(frame_number, distance_to_visible)) { 220 if (info.NeedsRecording(frame_number, distance_to_visible)) {
205 gfx::Rect tile = tiling_.TileBounds(key.first, key.second); 221 gfx::Rect tile = tiling_.TileBounds(key.first, key.second);
206 invalid_tiles.push_back(tile); 222 invalid_tiles.push_back(tile);
207 } else if (!info.GetPicture() && recorded_viewport_.Intersects(rect)) { 223 } else if (!info.GetPicture()) {
208 // Recorded viewport is just an optimization for a fully recorded 224 if (recorded_viewport_.Intersects(rect)) {
209 // interest rect. In this case, a tile in that rect has declined 225 // Recorded viewport is just an optimization for a fully recorded
210 // to be recorded (probably due to frequent invalidations). 226 // interest rect. In this case, a tile in that rect has declined
211 // TODO(enne): Shrink the recorded_viewport_ rather than clearing. 227 // to be recorded (probably due to frequent invalidations).
212 recorded_viewport_ = gfx::Rect(); 228 // TODO(enne): Shrink the recorded_viewport_ rather than clearing.
229 recorded_viewport_ = gfx::Rect();
230 }
231
232 // If a tile in the interest rect is not recorded, the entire tile needs
233 // to be considered invalid, so that we know not to keep around raster
234 // tiles that intersect this recording tile.
235 invalidation->Union(tiling_.TileBounds(it.index_x(), it.index_y()));
213 } 236 }
214 } 237 }
215 238
216 std::vector<gfx::Rect> record_rects; 239 std::vector<gfx::Rect> record_rects;
217 ClusterTiles(invalid_tiles, &record_rects); 240 ClusterTiles(invalid_tiles, &record_rects);
218 241
219 if (record_rects.empty()) 242 if (record_rects.empty())
220 return invalidated; 243 return invalidated;
221 244
222 for (std::vector<gfx::Rect>::iterator it = record_rects.begin(); 245 for (std::vector<gfx::Rect>::iterator it = record_rects.begin();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 } 300 }
278 DCHECK(found_tile_for_recorded_picture); 301 DCHECK(found_tile_for_recorded_picture);
279 } 302 }
280 303
281 has_any_recordings_ = true; 304 has_any_recordings_ = true;
282 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); 305 DCHECK(CanRasterSlowTileCheck(recorded_viewport_));
283 return true; 306 return true;
284 } 307 }
285 308
286 } // namespace cc 309 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698