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/tile_manager.h" | 5 #include "cc/resources/tile_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/debug/trace_event_argument.h" | 12 #include "base/debug/trace_event_argument.h" |
13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "cc/debug/devtools_instrumentation.h" | 16 #include "cc/debug/devtools_instrumentation.h" |
17 #include "cc/debug/frame_viewer_instrumentation.h" | 17 #include "cc/debug/frame_viewer_instrumentation.h" |
18 #include "cc/debug/traced_value.h" | 18 #include "cc/debug/traced_value.h" |
19 #include "cc/layers/picture_layer_impl.h" | 19 #include "cc/layers/picture_layer_impl.h" |
20 #include "cc/resources/raster_buffer.h" | 20 #include "cc/resources/raster_buffer.h" |
21 #include "cc/resources/rasterizer.h" | 21 #include "cc/resources/rasterizer.h" |
22 #include "cc/resources/tile.h" | 22 #include "cc/resources/tile.h" |
23 #include "ui/gfx/rect_conversions.h" | 23 #include "ui/gfx/geometry/rect_conversions.h" |
24 | 24 |
25 namespace cc { | 25 namespace cc { |
26 namespace { | 26 namespace { |
27 | 27 |
28 // Flag to indicate whether we should try and detect that | 28 // Flag to indicate whether we should try and detect that |
29 // a tile is of solid color. | 29 // a tile is of solid color. |
30 const bool kUseColorEstimator = true; | 30 const bool kUseColorEstimator = true; |
31 | 31 |
32 class RasterTaskImpl : public RasterTask { | 32 class RasterTaskImpl : public RasterTask { |
33 public: | 33 public: |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 186 |
187 private: | 187 private: |
188 skia::RefPtr<SkPixelRef> pixel_ref_; | 188 skia::RefPtr<SkPixelRef> pixel_ref_; |
189 int layer_id_; | 189 int layer_id_; |
190 RenderingStatsInstrumentation* rendering_stats_; | 190 RenderingStatsInstrumentation* rendering_stats_; |
191 const base::Callback<void(bool was_canceled)> reply_; | 191 const base::Callback<void(bool was_canceled)> reply_; |
192 | 192 |
193 DISALLOW_COPY_AND_ASSIGN(ImageDecodeTaskImpl); | 193 DISALLOW_COPY_AND_ASSIGN(ImageDecodeTaskImpl); |
194 }; | 194 }; |
195 | 195 |
196 const size_t kScheduledRasterTasksLimit = 32u; | |
197 | |
198 } // namespace | 196 } // namespace |
199 | 197 |
200 RasterTaskCompletionStats::RasterTaskCompletionStats() | 198 RasterTaskCompletionStats::RasterTaskCompletionStats() |
201 : completed_count(0u), canceled_count(0u) {} | 199 : completed_count(0u), canceled_count(0u) {} |
202 | 200 |
203 scoped_refptr<base::debug::ConvertableToTraceFormat> | 201 scoped_refptr<base::debug::ConvertableToTraceFormat> |
204 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats) { | 202 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats) { |
205 scoped_refptr<base::debug::TracedValue> state = | 203 scoped_refptr<base::debug::TracedValue> state = |
206 new base::debug::TracedValue(); | 204 new base::debug::TracedValue(); |
207 state->SetInteger("completed_count", stats.completed_count); | 205 state->SetInteger("completed_count", stats.completed_count); |
208 state->SetInteger("canceled_count", stats.canceled_count); | 206 state->SetInteger("canceled_count", stats.canceled_count); |
209 return state; | 207 return state; |
210 } | 208 } |
211 | 209 |
212 // static | 210 // static |
213 scoped_ptr<TileManager> TileManager::Create( | 211 scoped_ptr<TileManager> TileManager::Create( |
214 TileManagerClient* client, | 212 TileManagerClient* client, |
215 base::SequencedTaskRunner* task_runner, | 213 base::SequencedTaskRunner* task_runner, |
216 ResourcePool* resource_pool, | 214 ResourcePool* resource_pool, |
217 Rasterizer* rasterizer, | 215 Rasterizer* rasterizer, |
218 RenderingStatsInstrumentation* rendering_stats_instrumentation) { | 216 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 217 size_t scheduled_raster_task_limit) { |
219 return make_scoped_ptr(new TileManager(client, | 218 return make_scoped_ptr(new TileManager(client, |
220 task_runner, | 219 task_runner, |
221 resource_pool, | 220 resource_pool, |
222 rasterizer, | 221 rasterizer, |
223 rendering_stats_instrumentation)); | 222 rendering_stats_instrumentation, |
| 223 scheduled_raster_task_limit)); |
224 } | 224 } |
225 | 225 |
226 TileManager::TileManager( | 226 TileManager::TileManager( |
227 TileManagerClient* client, | 227 TileManagerClient* client, |
228 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 228 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
229 ResourcePool* resource_pool, | 229 ResourcePool* resource_pool, |
230 Rasterizer* rasterizer, | 230 Rasterizer* rasterizer, |
231 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 231 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 232 size_t scheduled_raster_task_limit) |
232 : client_(client), | 233 : client_(client), |
233 task_runner_(task_runner), | 234 task_runner_(task_runner), |
234 resource_pool_(resource_pool), | 235 resource_pool_(resource_pool), |
235 rasterizer_(rasterizer), | 236 rasterizer_(rasterizer), |
| 237 scheduled_raster_task_limit_(scheduled_raster_task_limit), |
236 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), | 238 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), |
237 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 239 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
238 did_initialize_visible_tile_(false), | 240 did_initialize_visible_tile_(false), |
239 did_check_for_completed_tasks_since_last_schedule_tasks_(true), | 241 did_check_for_completed_tasks_since_last_schedule_tasks_(true), |
240 did_oom_on_last_assign_(false), | 242 did_oom_on_last_assign_(false), |
241 ready_to_activate_check_notifier_( | 243 ready_to_activate_check_notifier_( |
242 task_runner_.get(), | 244 task_runner_.get(), |
243 base::Bind(&TileManager::CheckIfReadyToActivate, | 245 base::Bind(&TileManager::CheckIfReadyToActivate, |
244 base::Unretained(this))) { | 246 base::Unretained(this))) { |
245 rasterizer_->SetClient(this); | 247 rasterizer_->SetClient(this); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 if (TilePriorityViolatesMemoryPolicy(priority)) { | 565 if (TilePriorityViolatesMemoryPolicy(priority)) { |
564 TRACE_EVENT_INSTANT0( | 566 TRACE_EVENT_INSTANT0( |
565 "cc", | 567 "cc", |
566 "TileManager::AssignGpuMemory tile violates memory policy", | 568 "TileManager::AssignGpuMemory tile violates memory policy", |
567 TRACE_EVENT_SCOPE_THREAD); | 569 TRACE_EVENT_SCOPE_THREAD); |
568 break; | 570 break; |
569 } | 571 } |
570 | 572 |
571 // We won't be able to schedule this tile, so break out early. | 573 // We won't be able to schedule this tile, so break out early. |
572 if (tiles_that_need_to_be_rasterized->size() >= | 574 if (tiles_that_need_to_be_rasterized->size() >= |
573 kScheduledRasterTasksLimit) { | 575 scheduled_raster_task_limit_) { |
574 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; | 576 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; |
575 break; | 577 break; |
576 } | 578 } |
577 | 579 |
578 ManagedTileState& mts = tile->managed_state(); | 580 ManagedTileState& mts = tile->managed_state(); |
579 mts.scheduled_priority = schedule_priority++; | 581 mts.scheduled_priority = schedule_priority++; |
580 | 582 |
581 DCHECK(mts.draw_info.mode() == | 583 DCHECK(mts.draw_info.mode() == |
582 ManagedTileState::DrawInfo::PICTURE_PILE_MODE || | 584 ManagedTileState::DrawInfo::PICTURE_PILE_MODE || |
583 !mts.draw_info.IsReadyToDraw()); | 585 !mts.draw_info.IsReadyToDraw()); |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 result -= other; | 921 result -= other; |
920 return result; | 922 return result; |
921 } | 923 } |
922 | 924 |
923 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 925 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
924 return memory_bytes_ > limit.memory_bytes_ || | 926 return memory_bytes_ > limit.memory_bytes_ || |
925 resource_count_ > limit.resource_count_; | 927 resource_count_ > limit.resource_count_; |
926 } | 928 } |
927 | 929 |
928 } // namespace cc | 930 } // namespace cc |
OLD | NEW |