Chromium Code Reviews| 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/tiles/tile_manager.h" | 5 #include "cc/tiles/tile_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1351 | 1351 |
| 1352 // Utility function that can be used to create a "Task set finished" task that | 1352 // Utility function that can be used to create a "Task set finished" task that |
| 1353 // posts |callback| to |task_runner| when run. | 1353 // posts |callback| to |task_runner| when run. |
| 1354 scoped_refptr<TileTask> TileManager::CreateTaskSetFinishedTask( | 1354 scoped_refptr<TileTask> TileManager::CreateTaskSetFinishedTask( |
| 1355 void (TileManager::*callback)()) { | 1355 void (TileManager::*callback)()) { |
| 1356 return make_scoped_refptr(new TaskSetFinishedTaskImpl( | 1356 return make_scoped_refptr(new TaskSetFinishedTaskImpl( |
| 1357 task_runner_, | 1357 task_runner_, |
| 1358 base::Bind(callback, task_set_finished_weak_ptr_factory_.GetWeakPtr()))); | 1358 base::Bind(callback, task_set_finished_weak_ptr_factory_.GetWeakPtr()))); |
| 1359 } | 1359 } |
| 1360 | 1360 |
| 1361 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | |
| 1362 TileManager::ActivationStateAsValue() { | |
| 1363 auto state = base::MakeUnique<base::trace_event::TracedValue>(); | |
| 1364 state->SetString("tree_priority", | |
| 1365 TreePriorityToString(global_state_.tree_priority)); | |
| 1366 state->SetInteger("soft_memory_limit", | |
| 1367 global_state_.soft_memory_limit_in_bytes); | |
| 1368 state->SetInteger("hard_memory_limit", | |
| 1369 global_state_.soft_memory_limit_in_bytes); | |
| 1370 state->SetInteger("pending_required_for_activation_callback_id", | |
| 1371 pending_required_for_activation_callback_id_); | |
| 1372 state->SetInteger("current_memory_usage", | |
| 1373 resource_pool_->memory_usage_bytes()); | |
| 1374 state->SetInteger("current_resource_usage", resource_pool_->resource_count()); | |
| 1375 | |
| 1376 // Use a custom tile_as_value, instead of Tile::AsValueInto, since we don't | |
| 1377 // need all of the state that would be captured by other functions. | |
| 1378 auto tile_as_value = [](const PrioritizedTile& prioritized_tile, | |
| 1379 base::trace_event::TracedValue* value) { | |
|
sunnyps
2017/04/06 01:12:37
nit: I'd expect the value param to be exclusive to
vmpstr
2017/04/06 18:16:28
Done.
| |
| 1380 Tile* tile = prioritized_tile.tile(); | |
| 1381 TilePriority priority = prioritized_tile.priority(); | |
| 1382 | |
| 1383 value->BeginDictionary(); | |
| 1384 value->SetInteger("id", tile->id()); | |
| 1385 value->SetString("content_rect", tile->content_rect().ToString().c_str()); | |
|
sunnyps
2017/04/06 01:12:37
nit: SetString takes a StringPiece so you don't ne
vmpstr
2017/04/06 18:16:28
Done.
| |
| 1386 value->SetDouble("contents_scale", tile->contents_scale()); | |
| 1387 value->SetBoolean("is_ready_to_draw", tile->draw_info().IsReadyToDraw()); | |
| 1388 value->SetString("resolution", TileResolutionToString(priority.resolution)); | |
| 1389 value->SetString("priority_bin", | |
| 1390 TilePriorityBinToString(priority.priority_bin)); | |
| 1391 value->SetDouble("distance_to_visible", priority.distance_to_visible); | |
| 1392 value->SetBoolean("required_for_activation", | |
| 1393 tile->required_for_activation()); | |
| 1394 value->SetBoolean("required_for_draw", tile->required_for_draw()); | |
| 1395 value->EndDictionary(); | |
| 1396 }; | |
| 1397 | |
| 1398 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( | |
| 1399 client_->BuildRasterQueue(global_state_.tree_priority, | |
| 1400 RasterTilePriorityQueue::Type::ALL)); | |
| 1401 state->BeginArray("raster_tiles"); | |
| 1402 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) | |
| 1403 tile_as_value(raster_priority_queue->Top(), state.get()); | |
| 1404 state->EndArray(); | |
| 1405 | |
| 1406 std::unique_ptr<RasterTilePriorityQueue> required_priority_queue( | |
| 1407 client_->BuildRasterQueue( | |
| 1408 global_state_.tree_priority, | |
| 1409 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | |
| 1410 state->BeginArray("activation_tiles"); | |
| 1411 for (; !required_priority_queue->IsEmpty(); required_priority_queue->Pop()) | |
| 1412 tile_as_value(required_priority_queue->Top(), state.get()); | |
| 1413 state->EndArray(); | |
| 1414 | |
| 1415 return state; | |
| 1416 } | |
| 1417 | |
| 1361 TileManager::MemoryUsage::MemoryUsage() | 1418 TileManager::MemoryUsage::MemoryUsage() |
| 1362 : memory_bytes_(0), resource_count_(0) {} | 1419 : memory_bytes_(0), resource_count_(0) {} |
| 1363 | 1420 |
| 1364 TileManager::MemoryUsage::MemoryUsage(size_t memory_bytes, | 1421 TileManager::MemoryUsage::MemoryUsage(size_t memory_bytes, |
| 1365 size_t resource_count) | 1422 size_t resource_count) |
| 1366 : memory_bytes_(static_cast<int64_t>(memory_bytes)), | 1423 : memory_bytes_(static_cast<int64_t>(memory_bytes)), |
| 1367 resource_count_(static_cast<int>(resource_count)) { | 1424 resource_count_(static_cast<int>(resource_count)) { |
| 1368 // MemoryUsage is constructed using size_ts, since it deals with memory and | 1425 // MemoryUsage is constructed using size_ts, since it deals with memory and |
| 1369 // the inputs are typically size_t. However, during the course of usage (in | 1426 // the inputs are typically size_t. However, during the course of usage (in |
| 1370 // particular operator-=) can cause internal values to become negative. | 1427 // particular operator-=) can cause internal values to become negative. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1434 all_tile_tasks_completed = false; | 1491 all_tile_tasks_completed = false; |
| 1435 did_notify_all_tile_tasks_completed = false; | 1492 did_notify_all_tile_tasks_completed = false; |
| 1436 } | 1493 } |
| 1437 | 1494 |
| 1438 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; | 1495 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; |
| 1439 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( | 1496 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( |
| 1440 PrioritizedWorkToSchedule&& other) = default; | 1497 PrioritizedWorkToSchedule&& other) = default; |
| 1441 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; | 1498 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; |
| 1442 | 1499 |
| 1443 } // namespace cc | 1500 } // namespace cc |
| OLD | NEW |