| 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.h" | 5 #include "cc/tiles/tile.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/numerics/safe_conversions.h" |
| 9 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
| 10 #include "cc/base/math_util.h" | 11 #include "cc/base/math_util.h" |
| 11 #include "cc/debug/traced_value.h" | 12 #include "cc/debug/traced_value.h" |
| 12 #include "cc/tiles/tile_manager.h" | 13 #include "cc/tiles/tile_manager.h" |
| 13 | 14 |
| 14 namespace cc { | 15 namespace cc { |
| 15 | 16 |
| 16 Tile::Id Tile::s_next_id_ = 1; | 17 Tile::Id Tile::s_next_id_ = 1; |
| 17 | 18 |
| 18 Tile::Tile(TileManager* tile_manager, | 19 Tile::Tile(TileManager* tile_manager, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 56 |
| 56 value->BeginDictionary("draw_info"); | 57 value->BeginDictionary("draw_info"); |
| 57 draw_info_.AsValueInto(value); | 58 draw_info_.AsValueInto(value); |
| 58 value->EndDictionary(); | 59 value->EndDictionary(); |
| 59 | 60 |
| 60 value->SetBoolean("has_resource", draw_info().has_resource()); | 61 value->SetBoolean("has_resource", draw_info().has_resource()); |
| 61 value->SetBoolean("is_using_gpu_memory", | 62 value->SetBoolean("is_using_gpu_memory", |
| 62 draw_info().has_resource() || HasRasterTask()); | 63 draw_info().has_resource() || HasRasterTask()); |
| 63 value->SetInteger("scheduled_priority", scheduled_priority_); | 64 value->SetInteger("scheduled_priority", scheduled_priority_); |
| 64 value->SetBoolean("use_picture_analysis", use_picture_analysis()); | 65 value->SetBoolean("use_picture_analysis", use_picture_analysis()); |
| 65 value->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes()); | 66 value->SetInteger("gpu_memory_usage", |
| 67 base::saturated_cast<int>(GPUMemoryUsageInBytes())); |
| 66 } | 68 } |
| 67 | 69 |
| 68 size_t Tile::GPUMemoryUsageInBytes() const { | 70 size_t Tile::GPUMemoryUsageInBytes() const { |
| 69 if (draw_info_.resource_) { | 71 if (draw_info_.resource_) { |
| 70 // We can use UncheckedSizeInBytes, since the tile size is determined by the | 72 // We can use UncheckedSizeInBytes, since the tile size is determined by the |
| 71 // compositor. | 73 // compositor. |
| 72 return Resource::UncheckedMemorySizeBytes(draw_info_.resource_->size(), | 74 return Resource::UncheckedMemorySizeBytes(draw_info_.resource_->size(), |
| 73 draw_info_.resource_->format()); | 75 draw_info_.resource_->format()); |
| 74 } | 76 } |
| 75 return 0; | 77 return 0; |
| 76 } | 78 } |
| 77 | 79 |
| 78 void Tile::Deleter::operator()(Tile* tile) const { | 80 void Tile::Deleter::operator()(Tile* tile) const { |
| 79 TileManager* tile_manager = tile->tile_manager_; | 81 TileManager* tile_manager = tile->tile_manager_; |
| 80 tile_manager->Release(tile); | 82 tile_manager->Release(tile); |
| 81 } | 83 } |
| 82 | 84 |
| 83 } // namespace cc | 85 } // namespace cc |
| OLD | NEW |