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.h" | 5 #include "cc/resources/tile.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/debug/trace_event_argument.h" | |
10 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
11 #include "cc/debug/traced_value.h" | 10 #include "cc/debug/traced_value.h" |
12 #include "cc/resources/tile_manager.h" | 11 #include "cc/resources/tile_manager.h" |
13 #include "third_party/khronos/GLES2/gl2.h" | 12 #include "third_party/khronos/GLES2/gl2.h" |
14 | 13 |
15 namespace cc { | 14 namespace cc { |
16 | 15 |
17 Tile::Id Tile::s_next_id_ = 0; | 16 Tile::Id Tile::s_next_id_ = 0; |
18 | 17 |
19 Tile::Tile(TileManager* tile_manager, | 18 Tile::Tile(TileManager* tile_manager, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 54 } |
56 | 55 |
57 void Tile::MarkRequiredForActivation() { | 56 void Tile::MarkRequiredForActivation() { |
58 if (priority_[PENDING_TREE].required_for_activation) | 57 if (priority_[PENDING_TREE].required_for_activation) |
59 return; | 58 return; |
60 | 59 |
61 priority_[PENDING_TREE].required_for_activation = true; | 60 priority_[PENDING_TREE].required_for_activation = true; |
62 tile_manager_->DidChangeTilePriority(this); | 61 tile_manager_->DidChangeTilePriority(this); |
63 } | 62 } |
64 | 63 |
65 void Tile::AsValueInto(base::debug::TracedValue* res) const { | 64 scoped_ptr<base::Value> Tile::AsValue() const { |
| 65 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); |
66 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( | 66 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( |
67 TRACE_DISABLED_BY_DEFAULT("cc.debug"), res, "cc::Tile", this); | 67 TRACE_DISABLED_BY_DEFAULT("cc.debug"), res.get(), "cc::Tile", this); |
68 TracedValue::SetIDRef(picture_pile_.get(), res, "picture_pile"); | 68 res->Set("picture_pile", |
| 69 TracedValue::CreateIDRef(picture_pile_.get()).release()); |
69 res->SetDouble("contents_scale", contents_scale_); | 70 res->SetDouble("contents_scale", contents_scale_); |
70 | 71 res->Set("content_rect", MathUtil::AsValue(content_rect_).release()); |
71 res->BeginArray("content_rect"); | |
72 MathUtil::AddToTracedValue(content_rect_, res); | |
73 res->EndArray(); | |
74 | |
75 res->SetInteger("layer_id", layer_id_); | 72 res->SetInteger("layer_id", layer_id_); |
76 | 73 res->Set("active_priority", priority_[ACTIVE_TREE].AsValue().release()); |
77 res->BeginDictionary("active_priority"); | 74 res->Set("pending_priority", priority_[PENDING_TREE].AsValue().release()); |
78 priority_[ACTIVE_TREE].AsValueInto(res); | 75 res->Set("managed_state", managed_state_.AsValue().release()); |
79 res->EndDictionary(); | |
80 | |
81 res->BeginDictionary("pending_priority"); | |
82 priority_[PENDING_TREE].AsValueInto(res); | |
83 res->EndDictionary(); | |
84 | |
85 res->BeginDictionary("managed_state"); | |
86 managed_state_.AsValueInto(res); | |
87 res->EndDictionary(); | |
88 | |
89 res->SetBoolean("use_picture_analysis", use_picture_analysis()); | 76 res->SetBoolean("use_picture_analysis", use_picture_analysis()); |
| 77 return res.PassAs<base::Value>(); |
90 } | 78 } |
91 | 79 |
92 size_t Tile::GPUMemoryUsageInBytes() const { | 80 size_t Tile::GPUMemoryUsageInBytes() const { |
93 size_t total_size = 0; | 81 size_t total_size = 0; |
94 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) | 82 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) |
95 total_size += managed_state_.tile_versions[mode].GPUMemoryUsageInBytes(); | 83 total_size += managed_state_.tile_versions[mode].GPUMemoryUsageInBytes(); |
96 return total_size; | 84 return total_size; |
97 } | 85 } |
98 | 86 |
99 RasterMode Tile::DetermineRasterModeForTree(WhichTree tree) const { | 87 RasterMode Tile::DetermineRasterModeForTree(WhichTree tree) const { |
100 return DetermineRasterModeForResolution(priority(tree).resolution); | 88 return DetermineRasterModeForResolution(priority(tree).resolution); |
101 } | 89 } |
102 | 90 |
103 RasterMode Tile::DetermineOverallRasterMode() const { | 91 RasterMode Tile::DetermineOverallRasterMode() const { |
104 return DetermineRasterModeForResolution(managed_state_.resolution); | 92 return DetermineRasterModeForResolution(managed_state_.resolution); |
105 } | 93 } |
106 | 94 |
107 RasterMode Tile::DetermineRasterModeForResolution( | 95 RasterMode Tile::DetermineRasterModeForResolution( |
108 TileResolution resolution) const { | 96 TileResolution resolution) const { |
109 RasterMode current_mode = managed_state_.raster_mode; | 97 RasterMode current_mode = managed_state_.raster_mode; |
110 RasterMode raster_mode = resolution == LOW_RESOLUTION | 98 RasterMode raster_mode = resolution == LOW_RESOLUTION |
111 ? LOW_QUALITY_RASTER_MODE | 99 ? LOW_QUALITY_RASTER_MODE |
112 : HIGH_QUALITY_RASTER_MODE; | 100 : HIGH_QUALITY_RASTER_MODE; |
113 return std::min(raster_mode, current_mode); | 101 return std::min(raster_mode, current_mode); |
114 } | 102 } |
115 | 103 |
116 } // namespace cc | 104 } // namespace cc |
OLD | NEW |