Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: cc/resources/picture_layer_tiling_set_unittest.cc

Issue 1038793002: cc: Rework tiling set eviction iterator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/picture_layer_tiling_set.h" 5 #include "cc/resources/picture_layer_tiling_set.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "cc/resources/resource_provider.h" 10 #include "cc/resources/resource_provider.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 set->AddTiling(2.0, pile); 79 set->AddTiling(2.0, pile);
80 high_res_tiling = set->AddTiling(1.0, pile); 80 high_res_tiling = set->AddTiling(1.0, pile);
81 high_res_tiling->set_resolution(HIGH_RESOLUTION); 81 high_res_tiling->set_resolution(HIGH_RESOLUTION);
82 set->AddTiling(0.5, pile); 82 set->AddTiling(0.5, pile);
83 low_res_tiling = set->AddTiling(0.25, pile); 83 low_res_tiling = set->AddTiling(0.25, pile);
84 low_res_tiling->set_resolution(LOW_RESOLUTION); 84 low_res_tiling->set_resolution(LOW_RESOLUTION);
85 set->AddTiling(0.125, pile); 85 set->AddTiling(0.125, pile);
86 86
87 higher_than_high_res_range = 87 higher_than_high_res_range =
88 set->GetTilingRange(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); 88 set->GetTilingRange(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES);
89 EXPECT_EQ(0u, higher_than_high_res_range.start); 89 EXPECT_EQ(0, higher_than_high_res_range.start);
90 EXPECT_EQ(1u, higher_than_high_res_range.end); 90 EXPECT_EQ(1, higher_than_high_res_range.end);
91 91
92 high_res_range = set->GetTilingRange(PictureLayerTilingSet::HIGH_RES); 92 high_res_range = set->GetTilingRange(PictureLayerTilingSet::HIGH_RES);
93 EXPECT_EQ(1u, high_res_range.start); 93 EXPECT_EQ(1, high_res_range.start);
94 EXPECT_EQ(2u, high_res_range.end); 94 EXPECT_EQ(2, high_res_range.end);
95 95
96 between_high_and_low_res_range = 96 between_high_and_low_res_range =
97 set->GetTilingRange(PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); 97 set->GetTilingRange(PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES);
98 EXPECT_EQ(2u, between_high_and_low_res_range.start); 98 EXPECT_EQ(2, between_high_and_low_res_range.start);
99 EXPECT_EQ(3u, between_high_and_low_res_range.end); 99 EXPECT_EQ(3, between_high_and_low_res_range.end);
100 100
101 low_res_range = set->GetTilingRange(PictureLayerTilingSet::LOW_RES); 101 low_res_range = set->GetTilingRange(PictureLayerTilingSet::LOW_RES);
102 EXPECT_EQ(3u, low_res_range.start); 102 EXPECT_EQ(3, low_res_range.start);
103 EXPECT_EQ(4u, low_res_range.end); 103 EXPECT_EQ(4, low_res_range.end);
104 104
105 lower_than_low_res_range = 105 lower_than_low_res_range =
106 set->GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES); 106 set->GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES);
107 EXPECT_EQ(4u, lower_than_low_res_range.start); 107 EXPECT_EQ(4, lower_than_low_res_range.start);
108 EXPECT_EQ(5u, lower_than_low_res_range.end); 108 EXPECT_EQ(5, lower_than_low_res_range.end);
109 109
110 scoped_ptr<PictureLayerTilingSet> set_without_low_res = 110 scoped_ptr<PictureLayerTilingSet> set_without_low_res =
111 CreateTilingSet(&client); 111 CreateTilingSet(&client);
112 set_without_low_res->AddTiling(2.0, pile); 112 set_without_low_res->AddTiling(2.0, pile);
113 high_res_tiling = set_without_low_res->AddTiling(1.0, pile); 113 high_res_tiling = set_without_low_res->AddTiling(1.0, pile);
114 high_res_tiling->set_resolution(HIGH_RESOLUTION); 114 high_res_tiling->set_resolution(HIGH_RESOLUTION);
115 set_without_low_res->AddTiling(0.5, pile); 115 set_without_low_res->AddTiling(0.5, pile);
116 set_without_low_res->AddTiling(0.25, pile); 116 set_without_low_res->AddTiling(0.25, pile);
117 117
118 higher_than_high_res_range = set_without_low_res->GetTilingRange( 118 higher_than_high_res_range = set_without_low_res->GetTilingRange(
119 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); 119 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES);
120 EXPECT_EQ(0u, higher_than_high_res_range.start); 120 EXPECT_EQ(0, higher_than_high_res_range.start);
121 EXPECT_EQ(1u, higher_than_high_res_range.end); 121 EXPECT_EQ(1, higher_than_high_res_range.end);
122 122
123 high_res_range = 123 high_res_range =
124 set_without_low_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); 124 set_without_low_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES);
125 EXPECT_EQ(1u, high_res_range.start); 125 EXPECT_EQ(1, high_res_range.start);
126 EXPECT_EQ(2u, high_res_range.end); 126 EXPECT_EQ(2, high_res_range.end);
127 127
128 between_high_and_low_res_range = set_without_low_res->GetTilingRange( 128 between_high_and_low_res_range = set_without_low_res->GetTilingRange(
129 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); 129 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES);
130 EXPECT_EQ(2u, between_high_and_low_res_range.start); 130 EXPECT_EQ(2, between_high_and_low_res_range.start);
131 EXPECT_EQ(4u, between_high_and_low_res_range.end); 131 EXPECT_EQ(4, between_high_and_low_res_range.end);
132 132
133 low_res_range = 133 low_res_range =
134 set_without_low_res->GetTilingRange(PictureLayerTilingSet::LOW_RES); 134 set_without_low_res->GetTilingRange(PictureLayerTilingSet::LOW_RES);
135 EXPECT_EQ(0u, low_res_range.end - low_res_range.start); 135 EXPECT_EQ(0, low_res_range.end - low_res_range.start);
136 136
137 lower_than_low_res_range = set_without_low_res->GetTilingRange( 137 lower_than_low_res_range = set_without_low_res->GetTilingRange(
138 PictureLayerTilingSet::LOWER_THAN_LOW_RES); 138 PictureLayerTilingSet::LOWER_THAN_LOW_RES);
139 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); 139 EXPECT_EQ(0, lower_than_low_res_range.end - lower_than_low_res_range.start);
140 140
141 scoped_ptr<PictureLayerTilingSet> set_with_only_high_and_low_res = 141 scoped_ptr<PictureLayerTilingSet> set_with_only_high_and_low_res =
142 CreateTilingSet(&client); 142 CreateTilingSet(&client);
143 high_res_tiling = set_with_only_high_and_low_res->AddTiling(1.0, pile); 143 high_res_tiling = set_with_only_high_and_low_res->AddTiling(1.0, pile);
144 high_res_tiling->set_resolution(HIGH_RESOLUTION); 144 high_res_tiling->set_resolution(HIGH_RESOLUTION);
145 low_res_tiling = set_with_only_high_and_low_res->AddTiling(0.5, pile); 145 low_res_tiling = set_with_only_high_and_low_res->AddTiling(0.5, pile);
146 low_res_tiling->set_resolution(LOW_RESOLUTION); 146 low_res_tiling->set_resolution(LOW_RESOLUTION);
147 147
148 higher_than_high_res_range = set_with_only_high_and_low_res->GetTilingRange( 148 higher_than_high_res_range = set_with_only_high_and_low_res->GetTilingRange(
149 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); 149 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES);
150 EXPECT_EQ(0u, 150 EXPECT_EQ(0,
151 higher_than_high_res_range.end - higher_than_high_res_range.start); 151 higher_than_high_res_range.end - higher_than_high_res_range.start);
152 152
153 high_res_range = set_with_only_high_and_low_res->GetTilingRange( 153 high_res_range = set_with_only_high_and_low_res->GetTilingRange(
154 PictureLayerTilingSet::HIGH_RES); 154 PictureLayerTilingSet::HIGH_RES);
155 EXPECT_EQ(0u, high_res_range.start); 155 EXPECT_EQ(0, high_res_range.start);
156 EXPECT_EQ(1u, high_res_range.end); 156 EXPECT_EQ(1, high_res_range.end);
157 157
158 between_high_and_low_res_range = 158 between_high_and_low_res_range =
159 set_with_only_high_and_low_res->GetTilingRange( 159 set_with_only_high_and_low_res->GetTilingRange(
160 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); 160 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES);
161 EXPECT_EQ(0u, between_high_and_low_res_range.end - 161 EXPECT_EQ(0, between_high_and_low_res_range.end -
162 between_high_and_low_res_range.start); 162 between_high_and_low_res_range.start);
163 163
164 low_res_range = set_with_only_high_and_low_res->GetTilingRange( 164 low_res_range = set_with_only_high_and_low_res->GetTilingRange(
165 PictureLayerTilingSet::LOW_RES); 165 PictureLayerTilingSet::LOW_RES);
166 EXPECT_EQ(1u, low_res_range.start); 166 EXPECT_EQ(1, low_res_range.start);
167 EXPECT_EQ(2u, low_res_range.end); 167 EXPECT_EQ(2, low_res_range.end);
168 168
169 lower_than_low_res_range = set_with_only_high_and_low_res->GetTilingRange( 169 lower_than_low_res_range = set_with_only_high_and_low_res->GetTilingRange(
170 PictureLayerTilingSet::LOWER_THAN_LOW_RES); 170 PictureLayerTilingSet::LOWER_THAN_LOW_RES);
171 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); 171 EXPECT_EQ(0, lower_than_low_res_range.end - lower_than_low_res_range.start);
172 172
173 scoped_ptr<PictureLayerTilingSet> set_with_only_high_res = 173 scoped_ptr<PictureLayerTilingSet> set_with_only_high_res =
174 CreateTilingSet(&client); 174 CreateTilingSet(&client);
175 high_res_tiling = set_with_only_high_res->AddTiling(1.0, pile); 175 high_res_tiling = set_with_only_high_res->AddTiling(1.0, pile);
176 high_res_tiling->set_resolution(HIGH_RESOLUTION); 176 high_res_tiling->set_resolution(HIGH_RESOLUTION);
177 177
178 higher_than_high_res_range = set_with_only_high_res->GetTilingRange( 178 higher_than_high_res_range = set_with_only_high_res->GetTilingRange(
179 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); 179 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES);
180 EXPECT_EQ(0u, 180 EXPECT_EQ(0,
181 higher_than_high_res_range.end - higher_than_high_res_range.start); 181 higher_than_high_res_range.end - higher_than_high_res_range.start);
182 182
183 high_res_range = 183 high_res_range =
184 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); 184 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES);
185 EXPECT_EQ(0u, high_res_range.start); 185 EXPECT_EQ(0, high_res_range.start);
186 EXPECT_EQ(1u, high_res_range.end); 186 EXPECT_EQ(1, high_res_range.end);
187 187
188 between_high_and_low_res_range = set_with_only_high_res->GetTilingRange( 188 between_high_and_low_res_range = set_with_only_high_res->GetTilingRange(
189 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); 189 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES);
190 EXPECT_EQ(0u, between_high_and_low_res_range.end - 190 EXPECT_EQ(0, between_high_and_low_res_range.end -
191 between_high_and_low_res_range.start); 191 between_high_and_low_res_range.start);
192 192
193 low_res_range = 193 low_res_range =
194 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::LOW_RES); 194 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::LOW_RES);
195 EXPECT_EQ(0u, low_res_range.end - low_res_range.start); 195 EXPECT_EQ(0, low_res_range.end - low_res_range.start);
196 196
197 lower_than_low_res_range = set_with_only_high_res->GetTilingRange( 197 lower_than_low_res_range = set_with_only_high_res->GetTilingRange(
198 PictureLayerTilingSet::LOWER_THAN_LOW_RES); 198 PictureLayerTilingSet::LOWER_THAN_LOW_RES);
199 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); 199 EXPECT_EQ(0, lower_than_low_res_range.end - lower_than_low_res_range.start);
200 } 200 }
201 201
202 class PictureLayerTilingSetTestWithResources : public testing::Test { 202 class PictureLayerTilingSetTestWithResources : public testing::Test {
203 public: 203 public:
204 void runTest( 204 void runTest(
205 int num_tilings, 205 int num_tilings,
206 float min_scale, 206 float min_scale,
207 float scale_increment, 207 float scale_increment,
208 float ideal_contents_scale, 208 float ideal_contents_scale,
209 float expected_scale) { 209 float expected_scale) {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 446
447 // Clone from the pending to the active tree with the same max content size. 447 // Clone from the pending to the active tree with the same max content size.
448 active_set->UpdateTilingsToCurrentRasterSource( 448 active_set->UpdateTilingsToCurrentRasterSource(
449 pile.get(), pending_set.get(), Region(), 1.f, max_content_scale); 449 pile.get(), pending_set.get(), Region(), 1.f, max_content_scale);
450 // All the tilings are on the active tree. 450 // All the tilings are on the active tree.
451 EXPECT_EQ(2u, active_set->num_tilings()); 451 EXPECT_EQ(2u, active_set->num_tilings());
452 } 452 }
453 453
454 } // namespace 454 } // namespace
455 } // namespace cc 455 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698