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 15 matching lines...) Expand all Loading... | |
26 "EVENTUALLY_AND_ACTIVE_BIN")); | 26 "EVENTUALLY_AND_ACTIVE_BIN")); |
27 case EVENTUALLY_BIN: | 27 case EVENTUALLY_BIN: |
28 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 28 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
29 "EVENTUALLY_BIN")); | 29 "EVENTUALLY_BIN")); |
30 case NEVER_AND_ACTIVE_BIN: | 30 case NEVER_AND_ACTIVE_BIN: |
31 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 31 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
32 "NEVER_AND_ACTIVE_BIN")); | 32 "NEVER_AND_ACTIVE_BIN")); |
33 case NEVER_BIN: | 33 case NEVER_BIN: |
34 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 34 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
35 "NEVER_BIN")); | 35 "NEVER_BIN")); |
36 default: | |
37 DCHECK(false) << "Unrecognized ManagedTileBin value " << bin; | |
38 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | |
39 "<unknown ManagedTileBin value>")); | |
40 } | 36 } |
37 DCHECK(false) << "Unrecognized ManagedTileBin value " << bin; | |
38 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | |
39 "<unknown ManagedTileBin value>")); | |
41 } | 40 } |
42 | 41 |
43 scoped_ptr<base::Value> ManagedTileBinPriorityAsValue( | 42 scoped_ptr<base::Value> ManagedTileBinPriorityAsValue( |
vmpstr
2013/08/22 23:33:34
I don't think this function is used at all
| |
44 ManagedTileBinPriority bin_priority) { | 43 ManagedTileBinPriority bin_priority) { |
45 switch (bin_priority) { | 44 switch (bin_priority) { |
46 case HIGH_PRIORITY_BIN: | 45 case HIGH_PRIORITY_BIN: |
47 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 46 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
48 "HIGH_PRIORITY_BIN")); | 47 "HIGH_PRIORITY_BIN")); |
49 case LOW_PRIORITY_BIN: | 48 case LOW_PRIORITY_BIN: |
50 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 49 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
51 "LOW_PRIORITY_BIN")); | 50 "LOW_PRIORITY_BIN")); |
52 default: | |
53 DCHECK(false) << "Unrecognized ManagedTileBinPriority value"; | |
54 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | |
55 "<unknown ManagedTileBinPriority value>")); | |
56 } | 51 } |
52 DCHECK(false) << "Unrecognized ManagedTileBinPriority value"; | |
53 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | |
54 "<unknown ManagedTileBinPriority value>")); | |
57 } | 55 } |
58 | 56 |
59 ManagedTileState::ManagedTileState() | 57 ManagedTileState::ManagedTileState() |
60 : raster_mode(LOW_QUALITY_RASTER_MODE), | 58 : raster_mode(LOW_QUALITY_RASTER_MODE), |
61 gpu_memmgr_stats_bin(NEVER_BIN), | 59 gpu_memmgr_stats_bin(NEVER_BIN), |
62 resolution(NON_IDEAL_RESOLUTION), | 60 resolution(NON_IDEAL_RESOLUTION), |
63 required_for_activation(false), | 61 required_for_activation(false), |
64 time_to_needed_in_seconds(std::numeric_limits<float>::infinity()), | 62 time_to_needed_in_seconds(std::numeric_limits<float>::infinity()), |
65 distance_to_visible_in_pixels(std::numeric_limits<float>::infinity()), | 63 distance_to_visible_in_pixels(std::numeric_limits<float>::infinity()), |
66 visible_and_ready_to_draw(false), | 64 visible_and_ready_to_draw(false), |
67 scheduled_priority(0) { | 65 scheduled_priority(0) { |
68 for (int i = 0; i < NUM_TREES; ++i) { | 66 for (int i = 0; i <= MAX_TREE; ++i) { |
69 tree_bin[i] = NEVER_BIN; | 67 tree_bin[i] = NEVER_BIN; |
70 bin[i] = NEVER_BIN; | 68 bin[i] = NEVER_BIN; |
71 } | 69 } |
72 } | 70 } |
73 | 71 |
74 ManagedTileState::TileVersion::TileVersion() | 72 ManagedTileState::TileVersion::TileVersion() |
75 : mode_(RESOURCE_MODE), | 73 : mode_(RESOURCE_MODE), |
76 has_text_(false) { | 74 has_text_(false) { |
77 } | 75 } |
78 | 76 |
79 ManagedTileState::TileVersion::~TileVersion() { | 77 ManagedTileState::TileVersion::~TileVersion() { |
80 DCHECK(!resource_); | 78 DCHECK(!resource_); |
81 } | 79 } |
82 | 80 |
83 bool ManagedTileState::TileVersion::IsReadyToDraw() const { | 81 bool ManagedTileState::TileVersion::IsReadyToDraw() const { |
84 switch (mode_) { | 82 switch (mode_) { |
85 case RESOURCE_MODE: | 83 case RESOURCE_MODE: |
86 return !!resource_; | 84 return !!resource_; |
87 case SOLID_COLOR_MODE: | 85 case SOLID_COLOR_MODE: |
88 case PICTURE_PILE_MODE: | 86 case PICTURE_PILE_MODE: |
89 return true; | 87 return true; |
90 default: | |
91 NOTREACHED(); | |
92 return false; | |
93 } | 88 } |
89 NOTREACHED(); | |
90 return false; | |
94 } | 91 } |
95 | 92 |
96 size_t ManagedTileState::TileVersion::GPUMemoryUsageInBytes() const { | 93 size_t ManagedTileState::TileVersion::GPUMemoryUsageInBytes() const { |
97 if (!resource_) | 94 if (!resource_) |
98 return 0; | 95 return 0; |
99 return resource_->bytes(); | 96 return resource_->bytes(); |
100 } | 97 } |
101 | 98 |
102 ManagedTileState::~ManagedTileState() { | 99 ManagedTileState::~ManagedTileState() { |
103 } | 100 } |
(...skipping 18 matching lines...) Expand all Loading... | |
122 state->SetBoolean( | 119 state->SetBoolean( |
123 "is_transparent", | 120 "is_transparent", |
124 tile_versions[raster_mode].mode_ == TileVersion::SOLID_COLOR_MODE && | 121 tile_versions[raster_mode].mode_ == TileVersion::SOLID_COLOR_MODE && |
125 !SkColorGetA(tile_versions[raster_mode].solid_color_)); | 122 !SkColorGetA(tile_versions[raster_mode].solid_color_)); |
126 state->SetInteger("scheduled_priority", scheduled_priority); | 123 state->SetInteger("scheduled_priority", scheduled_priority); |
127 return state.PassAs<base::Value>(); | 124 return state.PassAs<base::Value>(); |
128 } | 125 } |
129 | 126 |
130 } // namespace cc | 127 } // namespace cc |
131 | 128 |
OLD | NEW |