| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 RenderingStatsInstrumentation* stats_instrumentation) { | 157 RenderingStatsInstrumentation* stats_instrumentation) { |
| 158 background_color_ = background_color; | 158 background_color_ = background_color; |
| 159 contents_opaque_ = contents_opaque; | 159 contents_opaque_ = contents_opaque; |
| 160 | 160 |
| 161 gfx::Rect interest_rect = visible_layer_rect; | 161 gfx::Rect interest_rect = visible_layer_rect; |
| 162 interest_rect.Inset( | 162 interest_rect.Inset( |
| 163 -kPixelDistanceToRecord, | 163 -kPixelDistanceToRecord, |
| 164 -kPixelDistanceToRecord, | 164 -kPixelDistanceToRecord, |
| 165 -kPixelDistanceToRecord, | 165 -kPixelDistanceToRecord, |
| 166 -kPixelDistanceToRecord); | 166 -kPixelDistanceToRecord); |
| 167 recorded_viewport_ = interest_rect; |
| 168 recorded_viewport_.Intersect(gfx::Rect(size())); |
| 167 | 169 |
| 168 bool invalidated = false; | 170 bool invalidated = false; |
| 169 for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { | 171 for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { |
| 170 gfx::Rect invalidation = i.rect(); | 172 gfx::Rect invalidation = i.rect(); |
| 171 // Split this inflated invalidation across tile boundaries and apply it | 173 // Split this inflated invalidation across tile boundaries and apply it |
| 172 // to all tiles that it touches. | 174 // to all tiles that it touches. |
| 173 bool include_borders = true; | 175 bool include_borders = true; |
| 174 for (TilingData::Iterator iter(&tiling_, invalidation, include_borders); | 176 for (TilingData::Iterator iter(&tiling_, invalidation, include_borders); |
| 175 iter; | 177 iter; |
| 176 ++iter) { | 178 ++iter) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 194 const PictureMapKey& key = it.index(); | 196 const PictureMapKey& key = it.index(); |
| 195 PictureInfo& info = picture_map_[key]; | 197 PictureInfo& info = picture_map_[key]; |
| 196 | 198 |
| 197 gfx::Rect rect = PaddedRect(key); | 199 gfx::Rect rect = PaddedRect(key); |
| 198 int distance_to_visible = | 200 int distance_to_visible = |
| 199 rect.ManhattanInternalDistance(visible_layer_rect); | 201 rect.ManhattanInternalDistance(visible_layer_rect); |
| 200 | 202 |
| 201 if (info.NeedsRecording(frame_number, distance_to_visible)) { | 203 if (info.NeedsRecording(frame_number, distance_to_visible)) { |
| 202 gfx::Rect tile = tiling_.TileBounds(key.first, key.second); | 204 gfx::Rect tile = tiling_.TileBounds(key.first, key.second); |
| 203 invalid_tiles.push_back(tile); | 205 invalid_tiles.push_back(tile); |
| 206 } else if (!info.GetPicture() && recorded_viewport_.Intersects(rect)) { |
| 207 // Recorded viewport is just an optimization for a fully recorded |
| 208 // interest rect. In this case, a tile in that rect has declined |
| 209 // to be recorded (probably due to frequent invalidations). |
| 210 // TODO(enne): Shrink the recorded_viewport_ rather than clearing. |
| 211 recorded_viewport_ = gfx::Rect(); |
| 204 } | 212 } |
| 205 } | 213 } |
| 206 | 214 |
| 207 std::vector<gfx::Rect> record_rects; | 215 std::vector<gfx::Rect> record_rects; |
| 208 ClusterTiles(invalid_tiles, &record_rects); | 216 ClusterTiles(invalid_tiles, &record_rects); |
| 209 | 217 |
| 210 if (record_rects.empty()) { | 218 if (record_rects.empty()) |
| 211 if (invalidated) | |
| 212 UpdateRecordedRegion(); | |
| 213 return invalidated; | 219 return invalidated; |
| 214 } | |
| 215 | 220 |
| 216 for (std::vector<gfx::Rect>::iterator it = record_rects.begin(); | 221 for (std::vector<gfx::Rect>::iterator it = record_rects.begin(); |
| 217 it != record_rects.end(); | 222 it != record_rects.end(); |
| 218 it++) { | 223 it++) { |
| 219 gfx::Rect record_rect = *it; | 224 gfx::Rect record_rect = *it; |
| 220 record_rect = PadRect(record_rect); | 225 record_rect = PadRect(record_rect); |
| 221 | 226 |
| 222 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_); | 227 int repeat_count = std::max(1, slow_down_raster_scale_factor_for_debug_); |
| 223 scoped_refptr<Picture> picture; | 228 scoped_refptr<Picture> picture; |
| 224 int num_raster_threads = RasterWorkerPool::GetNumRasterThreads(); | 229 int num_raster_threads = RasterWorkerPool::GetNumRasterThreads(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 240 num_raster_threads); | 245 num_raster_threads); |
| 241 base::TimeDelta duration = | 246 base::TimeDelta duration = |
| 242 stats_instrumentation->EndRecording(start_time); | 247 stats_instrumentation->EndRecording(start_time); |
| 243 best_duration = std::min(duration, best_duration); | 248 best_duration = std::min(duration, best_duration); |
| 244 } | 249 } |
| 245 int recorded_pixel_count = | 250 int recorded_pixel_count = |
| 246 picture->LayerRect().width() * picture->LayerRect().height(); | 251 picture->LayerRect().width() * picture->LayerRect().height(); |
| 247 stats_instrumentation->AddRecord(best_duration, recorded_pixel_count); | 252 stats_instrumentation->AddRecord(best_duration, recorded_pixel_count); |
| 248 } | 253 } |
| 249 | 254 |
| 255 bool found_tile_for_recorded_picture = false; |
| 256 |
| 250 bool include_borders = true; | 257 bool include_borders = true; |
| 251 for (TilingData::Iterator it(&tiling_, record_rect, include_borders); it; | 258 for (TilingData::Iterator it(&tiling_, record_rect, include_borders); it; |
| 252 ++it) { | 259 ++it) { |
| 253 const PictureMapKey& key = it.index(); | 260 const PictureMapKey& key = it.index(); |
| 254 gfx::Rect tile = PaddedRect(key); | 261 gfx::Rect tile = PaddedRect(key); |
| 255 if (record_rect.Contains(tile)) { | 262 if (record_rect.Contains(tile)) { |
| 256 PictureInfo& info = picture_map_[key]; | 263 PictureInfo& info = picture_map_[key]; |
| 257 info.SetPicture(picture); | 264 info.SetPicture(picture); |
| 265 found_tile_for_recorded_picture = true; |
| 258 } | 266 } |
| 259 } | 267 } |
| 268 DCHECK(found_tile_for_recorded_picture); |
| 260 } | 269 } |
| 261 | 270 |
| 262 UpdateRecordedRegion(); | 271 has_any_recordings_ = true; |
| 272 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); |
| 263 return true; | 273 return true; |
| 264 } | 274 } |
| 265 | 275 |
| 266 } // namespace cc | 276 } // namespace cc |
| OLD | NEW |