| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "base/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
| 12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
| 13 #include "base/trace_event/trace_event_argument.h" | 13 #include "base/trace_event/trace_event_argument.h" |
| 14 #include "cc/base/math_util.h" | 14 #include "cc/base/math_util.h" |
| 15 #include "cc/debug/traced_value.h" | 15 #include "cc/debug/traced_value.h" |
| 16 #include "cc/tiles/tile_manager.h" | 16 #include "cc/tiles/tile_manager.h" |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 | 19 |
| 20 Tile::Tile(TileManager* tile_manager, | 20 Tile::Tile(TileManager* tile_manager, |
| 21 const CreateInfo& info, | 21 const CreateInfo& info, |
| 22 int layer_id, | 22 int layer_id, |
| 23 int source_frame_number, | 23 int source_frame_number, |
| 24 int flags) | 24 int flags) |
| 25 : tile_manager_(tile_manager), | 25 : tile_manager_(tile_manager), |
| 26 tiling_(info.tiling), | 26 tiling_(info.tiling), |
| 27 content_rect_(info.content_rect), | 27 content_rect_(info.content_rect), |
| 28 enclosing_layer_rect_(info.enclosing_layer_rect), | 28 enclosing_layer_rect_(info.enclosing_layer_rect), |
| 29 raster_scales_(info.raster_scales), | 29 contents_scale_(info.contents_scale), |
| 30 layer_id_(layer_id), | 30 layer_id_(layer_id), |
| 31 source_frame_number_(source_frame_number), | 31 source_frame_number_(source_frame_number), |
| 32 flags_(flags), | 32 flags_(flags), |
| 33 tiling_i_index_(info.tiling_i_index), | 33 tiling_i_index_(info.tiling_i_index), |
| 34 tiling_j_index_(info.tiling_j_index), | 34 tiling_j_index_(info.tiling_j_index), |
| 35 required_for_activation_(false), | 35 required_for_activation_(false), |
| 36 required_for_draw_(false), | 36 required_for_draw_(false), |
| 37 is_solid_color_analysis_performed_(false), | 37 is_solid_color_analysis_performed_(false), |
| 38 id_(tile_manager->GetUniqueTileId()), | 38 id_(tile_manager->GetUniqueTileId()), |
| 39 invalidated_id_(0), | 39 invalidated_id_(0), |
| 40 scheduled_priority_(0) {} | 40 scheduled_priority_(0) {} |
| 41 | 41 |
| 42 Tile::~Tile() { | 42 Tile::~Tile() { |
| 43 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 43 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
| 44 TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 44 TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
| 45 "cc::Tile", this); | 45 "cc::Tile", this); |
| 46 tile_manager_->Release(this); | 46 tile_manager_->Release(this); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void Tile::AsValueInto(base::trace_event::TracedValue* value) const { | 49 void Tile::AsValueInto(base::trace_event::TracedValue* value) const { |
| 50 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( | 50 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( |
| 51 TRACE_DISABLED_BY_DEFAULT("cc.debug"), value, "cc::Tile", this); | 51 TRACE_DISABLED_BY_DEFAULT("cc.debug"), value, "cc::Tile", this); |
| 52 // TODO(vmpstr): Update tracing to use x/y scales. | 52 value->SetDouble("contents_scale", contents_scale()); |
| 53 value->SetDouble("contents_scale", contents_scale_key()); | |
| 54 | |
| 55 value->BeginArray("raster_scales"); | |
| 56 value->AppendDouble(raster_scales_.width()); | |
| 57 value->AppendDouble(raster_scales_.height()); | |
| 58 value->EndArray(); | |
| 59 | 53 |
| 60 MathUtil::AddToTracedValue("content_rect", content_rect_, value); | 54 MathUtil::AddToTracedValue("content_rect", content_rect_, value); |
| 61 | 55 |
| 62 value->SetInteger("layer_id", layer_id_); | 56 value->SetInteger("layer_id", layer_id_); |
| 63 | 57 |
| 64 value->BeginDictionary("draw_info"); | 58 value->BeginDictionary("draw_info"); |
| 65 draw_info_.AsValueInto(value); | 59 draw_info_.AsValueInto(value); |
| 66 value->EndDictionary(); | 60 value->EndDictionary(); |
| 67 | 61 |
| 68 value->SetBoolean("has_resource", draw_info().has_resource()); | 62 value->SetBoolean("has_resource", draw_info().has_resource()); |
| 69 value->SetBoolean("is_using_gpu_memory", | 63 value->SetBoolean("is_using_gpu_memory", |
| 70 draw_info().has_resource() || HasRasterTask()); | 64 draw_info().has_resource() || HasRasterTask()); |
| 71 value->SetInteger("scheduled_priority", scheduled_priority_); | 65 value->SetInteger("scheduled_priority", scheduled_priority_); |
| 72 value->SetBoolean("use_picture_analysis", use_picture_analysis()); | 66 value->SetBoolean("use_picture_analysis", use_picture_analysis()); |
| 73 value->SetInteger("gpu_memory_usage", | 67 value->SetInteger("gpu_memory_usage", |
| 74 base::saturated_cast<int>(GPUMemoryUsageInBytes())); | 68 base::saturated_cast<int>(GPUMemoryUsageInBytes())); |
| 75 } | 69 } |
| 76 | 70 |
| 77 size_t Tile::GPUMemoryUsageInBytes() const { | 71 size_t Tile::GPUMemoryUsageInBytes() const { |
| 78 if (draw_info_.resource_) { | 72 if (draw_info_.resource_) { |
| 79 // We can use UncheckedSizeInBytes, since the tile size is determined by the | 73 // We can use UncheckedSizeInBytes, since the tile size is determined by the |
| 80 // compositor. | 74 // compositor. |
| 81 return ResourceUtil::UncheckedSizeInBytes<size_t>( | 75 return ResourceUtil::UncheckedSizeInBytes<size_t>( |
| 82 draw_info_.resource_->size(), draw_info_.resource_->format()); | 76 draw_info_.resource_->size(), draw_info_.resource_->format()); |
| 83 } | 77 } |
| 84 return 0; | 78 return 0; |
| 85 } | 79 } |
| 86 | 80 |
| 87 } // namespace cc | 81 } // namespace cc |
| OLD | NEW |