| 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 |
| 11 #include "cc/base/region.h" | 11 #include "cc/base/region.h" |
| 12 #include "cc/debug/rendering_stats_instrumentation.h" | 12 #include "cc/debug/rendering_stats_instrumentation.h" |
| 13 #include "cc/resources/picture_pile_impl.h" | 13 #include "cc/resources/picture_pile_impl.h" |
| 14 #include "cc/resources/tile_priority.h" | 14 #include "cc/resources/tile_priority.h" |
| 15 #include "cc/resources/worker_pool.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 // Layout pixel buffer around the visible layer rect to record. Any base | 18 // Layout pixel buffer around the visible layer rect to record. Any base |
| 18 // picture that intersects the visible layer rect expanded by this distance | 19 // picture that intersects the visible layer rect expanded by this distance |
| 19 // will be recorded. | 20 // will be recorded. |
| 20 const int kPixelDistanceToRecord = 8000; | 21 const int kPixelDistanceToRecord = 8000; |
| 21 | 22 |
| 22 // TODO(humper): The density threshold here is somewhat arbitrary; need a | 23 // TODO(humper): The density threshold here is somewhat arbitrary; need a |
| 23 // way to set // this from the command line so we can write a benchmark | 24 // way to set // this from the command line so we can write a benchmark |
| 24 // script and find a sweet spot. | 25 // script and find a sweet spot. |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 std::numeric_limits<int64>::max()); | 225 std::numeric_limits<int64>::max()); |
| 225 for (int i = 0; i < repeat_count; i++) { | 226 for (int i = 0; i < repeat_count; i++) { |
| 226 base::TimeTicks start_time = stats_instrumentation->StartRecording(); | 227 base::TimeTicks start_time = stats_instrumentation->StartRecording(); |
| 227 picture->Record(painter, tile_grid_info_); | 228 picture->Record(painter, tile_grid_info_); |
| 228 base::TimeDelta duration = | 229 base::TimeDelta duration = |
| 229 stats_instrumentation->EndRecording(start_time); | 230 stats_instrumentation->EndRecording(start_time); |
| 230 best_duration = std::min(duration, best_duration); | 231 best_duration = std::min(duration, best_duration); |
| 231 } | 232 } |
| 232 int recorded_pixel_count = | 233 int recorded_pixel_count = |
| 233 picture->LayerRect().width() * picture->LayerRect().height(); | 234 picture->LayerRect().width() * picture->LayerRect().height(); |
| 235 int num_raster_threads = WorkerPool::GetNumRasterThreads(); |
| 234 stats_instrumentation->AddRecord(best_duration, recorded_pixel_count); | 236 stats_instrumentation->AddRecord(best_duration, recorded_pixel_count); |
| 235 if (num_raster_threads_ > 1) | 237 if (num_raster_threads > 1) |
| 236 picture->GatherPixelRefs(tile_grid_info_); | 238 picture->GatherPixelRefs(tile_grid_info_); |
| 237 picture->CloneForDrawing(num_raster_threads_); | 239 picture->CloneForDrawing(num_raster_threads); |
| 238 } | 240 } |
| 239 | 241 |
| 240 for (TilingData::Iterator it(&tiling_, record_rect); | 242 for (TilingData::Iterator it(&tiling_, record_rect); |
| 241 it; ++it) { | 243 it; ++it) { |
| 242 const PictureMapKey& key = it.index(); | 244 const PictureMapKey& key = it.index(); |
| 243 gfx::Rect tile = PaddedRect(key); | 245 gfx::Rect tile = PaddedRect(key); |
| 244 if (record_rect.Contains(tile)) { | 246 if (record_rect.Contains(tile)) { |
| 245 PictureInfo& info = picture_map_[key]; | 247 PictureInfo& info = picture_map_[key]; |
| 246 info.SetPicture(picture); | 248 info.SetPicture(picture); |
| 247 } | 249 } |
| 248 } | 250 } |
| 249 } | 251 } |
| 250 | 252 |
| 251 UpdateRecordedRegion(); | 253 UpdateRecordedRegion(); |
| 252 return true; | 254 return true; |
| 253 } | 255 } |
| 254 | 256 |
| 255 } // namespace cc | 257 } // namespace cc |
| OLD | NEW |