| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/managed_tile_state.h" | 5 #include "cc/resources/managed_tile_state.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
| 10 | 10 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 return resource_->bytes(); | 77 return resource_->bytes(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 ManagedTileState::~ManagedTileState() {} | 80 ManagedTileState::~ManagedTileState() {} |
| 81 | 81 |
| 82 scoped_ptr<base::Value> ManagedTileState::AsValue() const { | 82 scoped_ptr<base::Value> ManagedTileState::AsValue() const { |
| 83 bool has_resource = false; | 83 bool has_resource = false; |
| 84 bool has_active_task = false; | 84 bool has_active_task = false; |
| 85 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { | 85 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { |
| 86 has_resource |= (tile_versions[mode].resource_.get() != 0); | 86 has_resource |= (tile_versions[mode].resource_.get() != 0); |
| 87 has_active_task |= !tile_versions[mode].raster_task_.is_null(); | 87 has_active_task |= (tile_versions[mode].raster_task_.get() != 0); |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool is_using_gpu_memory = has_resource || has_active_task; | 90 bool is_using_gpu_memory = has_resource || has_active_task; |
| 91 | 91 |
| 92 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 92 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 93 state->SetBoolean("has_resource", has_resource); | 93 state->SetBoolean("has_resource", has_resource); |
| 94 state->SetBoolean("is_using_gpu_memory", is_using_gpu_memory); | 94 state->SetBoolean("is_using_gpu_memory", is_using_gpu_memory); |
| 95 state->Set("bin", ManagedTileBinAsValue(bin).release()); | 95 state->Set("bin", ManagedTileBinAsValue(bin).release()); |
| 96 state->Set("resolution", TileResolutionAsValue(resolution).release()); | 96 state->Set("resolution", TileResolutionAsValue(resolution).release()); |
| 97 state->Set("priority_bin", TilePriorityBinAsValue(priority_bin).release()); | 97 state->Set("priority_bin", TilePriorityBinAsValue(priority_bin).release()); |
| 98 state->Set("distance_to_visible", | 98 state->Set("distance_to_visible", |
| 99 MathUtil::AsValueSafely(distance_to_visible).release()); | 99 MathUtil::AsValueSafely(distance_to_visible).release()); |
| 100 state->SetBoolean("required_for_activation", required_for_activation); | 100 state->SetBoolean("required_for_activation", required_for_activation); |
| 101 state->SetBoolean( | 101 state->SetBoolean( |
| 102 "is_solid_color", | 102 "is_solid_color", |
| 103 tile_versions[raster_mode].mode_ == TileVersion::SOLID_COLOR_MODE); | 103 tile_versions[raster_mode].mode_ == TileVersion::SOLID_COLOR_MODE); |
| 104 state->SetBoolean( | 104 state->SetBoolean( |
| 105 "is_transparent", | 105 "is_transparent", |
| 106 tile_versions[raster_mode].mode_ == TileVersion::SOLID_COLOR_MODE && | 106 tile_versions[raster_mode].mode_ == TileVersion::SOLID_COLOR_MODE && |
| 107 !SkColorGetA(tile_versions[raster_mode].solid_color_)); | 107 !SkColorGetA(tile_versions[raster_mode].solid_color_)); |
| 108 state->SetInteger("scheduled_priority", scheduled_priority); | 108 state->SetInteger("scheduled_priority", scheduled_priority); |
| 109 return state.PassAs<base::Value>(); | 109 return state.PassAs<base::Value>(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 } // namespace cc | 112 } // namespace cc |
| OLD | NEW |