| 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 <limits> | 8 #include <limits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 -kPixelDistanceToRecord, | 163 -kPixelDistanceToRecord, |
| 164 -kPixelDistanceToRecord, | 164 -kPixelDistanceToRecord, |
| 165 -kPixelDistanceToRecord, | 165 -kPixelDistanceToRecord, |
| 166 -kPixelDistanceToRecord); | 166 -kPixelDistanceToRecord); |
| 167 | 167 |
| 168 bool invalidated = false; | 168 bool invalidated = false; |
| 169 for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { | 169 for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { |
| 170 gfx::Rect invalidation = i.rect(); | 170 gfx::Rect invalidation = i.rect(); |
| 171 // Split this inflated invalidation across tile boundaries and apply it | 171 // Split this inflated invalidation across tile boundaries and apply it |
| 172 // to all tiles that it touches. | 172 // to all tiles that it touches. |
| 173 for (TilingData::Iterator iter(&tiling_, invalidation); | 173 bool include_borders = true; |
| 174 iter; ++iter) { | 174 for (TilingData::Iterator iter(&tiling_, invalidation, include_borders); |
| 175 iter; |
| 176 ++iter) { |
| 175 const PictureMapKey& key = iter.index(); | 177 const PictureMapKey& key = iter.index(); |
| 176 | 178 |
| 177 PictureMap::iterator picture_it = picture_map_.find(key); | 179 PictureMap::iterator picture_it = picture_map_.find(key); |
| 178 if (picture_it == picture_map_.end()) | 180 if (picture_it == picture_map_.end()) |
| 179 continue; | 181 continue; |
| 180 | 182 |
| 181 // Inform the grid cell that it has been invalidated in this frame. | 183 // Inform the grid cell that it has been invalidated in this frame. |
| 182 invalidated = picture_it->second.Invalidate(frame_number) || invalidated; | 184 invalidated = picture_it->second.Invalidate(frame_number) || invalidated; |
| 183 } | 185 } |
| 184 } | 186 } |
| 185 | 187 |
| 186 // Make a list of all invalid tiles; we will attempt to | 188 // Make a list of all invalid tiles; we will attempt to |
| 187 // cluster these into multiple invalidation regions. | 189 // cluster these into multiple invalidation regions. |
| 188 std::vector<gfx::Rect> invalid_tiles; | 190 std::vector<gfx::Rect> invalid_tiles; |
| 189 | 191 bool include_borders = true; |
| 190 for (TilingData::Iterator it(&tiling_, interest_rect); | 192 for (TilingData::Iterator it(&tiling_, interest_rect, include_borders); it; |
| 191 it; ++it) { | 193 ++it) { |
| 192 const PictureMapKey& key = it.index(); | 194 const PictureMapKey& key = it.index(); |
| 193 PictureInfo& info = picture_map_[key]; | 195 PictureInfo& info = picture_map_[key]; |
| 194 | 196 |
| 195 gfx::Rect rect = PaddedRect(key); | 197 gfx::Rect rect = PaddedRect(key); |
| 196 int distance_to_visible = | 198 int distance_to_visible = |
| 197 rect.ManhattanInternalDistance(visible_layer_rect); | 199 rect.ManhattanInternalDistance(visible_layer_rect); |
| 198 | 200 |
| 199 if (info.NeedsRecording(frame_number, distance_to_visible)) { | 201 if (info.NeedsRecording(frame_number, distance_to_visible)) { |
| 200 gfx::Rect tile = tiling_.TileBounds(key.first, key.second); | 202 gfx::Rect tile = tiling_.TileBounds(key.first, key.second); |
| 201 invalid_tiles.push_back(tile); | 203 invalid_tiles.push_back(tile); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 num_raster_threads); | 240 num_raster_threads); |
| 239 base::TimeDelta duration = | 241 base::TimeDelta duration = |
| 240 stats_instrumentation->EndRecording(start_time); | 242 stats_instrumentation->EndRecording(start_time); |
| 241 best_duration = std::min(duration, best_duration); | 243 best_duration = std::min(duration, best_duration); |
| 242 } | 244 } |
| 243 int recorded_pixel_count = | 245 int recorded_pixel_count = |
| 244 picture->LayerRect().width() * picture->LayerRect().height(); | 246 picture->LayerRect().width() * picture->LayerRect().height(); |
| 245 stats_instrumentation->AddRecord(best_duration, recorded_pixel_count); | 247 stats_instrumentation->AddRecord(best_duration, recorded_pixel_count); |
| 246 } | 248 } |
| 247 | 249 |
| 248 for (TilingData::Iterator it(&tiling_, record_rect); | 250 bool include_borders = true; |
| 249 it; ++it) { | 251 for (TilingData::Iterator it(&tiling_, record_rect, include_borders); it; |
| 252 ++it) { |
| 250 const PictureMapKey& key = it.index(); | 253 const PictureMapKey& key = it.index(); |
| 251 gfx::Rect tile = PaddedRect(key); | 254 gfx::Rect tile = PaddedRect(key); |
| 252 if (record_rect.Contains(tile)) { | 255 if (record_rect.Contains(tile)) { |
| 253 PictureInfo& info = picture_map_[key]; | 256 PictureInfo& info = picture_map_[key]; |
| 254 info.SetPicture(picture); | 257 info.SetPicture(picture); |
| 255 } | 258 } |
| 256 } | 259 } |
| 257 } | 260 } |
| 258 | 261 |
| 259 UpdateRecordedRegion(); | 262 UpdateRecordedRegion(); |
| 260 return true; | 263 return true; |
| 261 } | 264 } |
| 262 | 265 |
| 263 } // namespace cc | 266 } // namespace cc |
| OLD | NEW |