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

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

Issue 1168903003: cc: Fix size_t to int truncations in tiles/ and trees/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « cc/tiles/picture_layer_tiling_set.cc ('k') | cc/tiles/tile.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/tiles/picture_layer_tiling_set.h" 5 #include "cc/tiles/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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 set->AddTiling(2.0, pile); 80 set->AddTiling(2.0, pile);
81 high_res_tiling = set->AddTiling(1.0, pile); 81 high_res_tiling = set->AddTiling(1.0, pile);
82 high_res_tiling->set_resolution(HIGH_RESOLUTION); 82 high_res_tiling->set_resolution(HIGH_RESOLUTION);
83 set->AddTiling(0.5, pile); 83 set->AddTiling(0.5, pile);
84 low_res_tiling = set->AddTiling(0.25, pile); 84 low_res_tiling = set->AddTiling(0.25, pile);
85 low_res_tiling->set_resolution(LOW_RESOLUTION); 85 low_res_tiling->set_resolution(LOW_RESOLUTION);
86 set->AddTiling(0.125, pile); 86 set->AddTiling(0.125, pile);
87 87
88 higher_than_high_res_range = 88 higher_than_high_res_range =
89 set->GetTilingRange(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); 89 set->GetTilingRange(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES);
90 EXPECT_EQ(0, higher_than_high_res_range.start); 90 EXPECT_EQ(0u, higher_than_high_res_range.start);
91 EXPECT_EQ(1, higher_than_high_res_range.end); 91 EXPECT_EQ(1u, higher_than_high_res_range.end);
92 92
93 high_res_range = set->GetTilingRange(PictureLayerTilingSet::HIGH_RES); 93 high_res_range = set->GetTilingRange(PictureLayerTilingSet::HIGH_RES);
94 EXPECT_EQ(1, high_res_range.start); 94 EXPECT_EQ(1u, high_res_range.start);
95 EXPECT_EQ(2, high_res_range.end); 95 EXPECT_EQ(2u, high_res_range.end);
96 96
97 between_high_and_low_res_range = 97 between_high_and_low_res_range =
98 set->GetTilingRange(PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); 98 set->GetTilingRange(PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES);
99 EXPECT_EQ(2, between_high_and_low_res_range.start); 99 EXPECT_EQ(2u, between_high_and_low_res_range.start);
100 EXPECT_EQ(3, between_high_and_low_res_range.end); 100 EXPECT_EQ(3u, between_high_and_low_res_range.end);
101 101
102 low_res_range = set->GetTilingRange(PictureLayerTilingSet::LOW_RES); 102 low_res_range = set->GetTilingRange(PictureLayerTilingSet::LOW_RES);
103 EXPECT_EQ(3, low_res_range.start); 103 EXPECT_EQ(3u, low_res_range.start);
104 EXPECT_EQ(4, low_res_range.end); 104 EXPECT_EQ(4u, low_res_range.end);
105 105
106 lower_than_low_res_range = 106 lower_than_low_res_range =
107 set->GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES); 107 set->GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES);
108 EXPECT_EQ(4, lower_than_low_res_range.start); 108 EXPECT_EQ(4u, lower_than_low_res_range.start);
109 EXPECT_EQ(5, lower_than_low_res_range.end); 109 EXPECT_EQ(5u, lower_than_low_res_range.end);
110 110
111 scoped_ptr<PictureLayerTilingSet> set_without_low_res = 111 scoped_ptr<PictureLayerTilingSet> set_without_low_res =
112 CreateTilingSet(&client); 112 CreateTilingSet(&client);
113 set_without_low_res->AddTiling(2.0, pile); 113 set_without_low_res->AddTiling(2.0, pile);
114 high_res_tiling = set_without_low_res->AddTiling(1.0, pile); 114 high_res_tiling = set_without_low_res->AddTiling(1.0, pile);
115 high_res_tiling->set_resolution(HIGH_RESOLUTION); 115 high_res_tiling->set_resolution(HIGH_RESOLUTION);
116 set_without_low_res->AddTiling(0.5, pile); 116 set_without_low_res->AddTiling(0.5, pile);
117 set_without_low_res->AddTiling(0.25, pile); 117 set_without_low_res->AddTiling(0.25, pile);
118 118
119 higher_than_high_res_range = set_without_low_res->GetTilingRange( 119 higher_than_high_res_range = set_without_low_res->GetTilingRange(
120 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); 120 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES);
121 EXPECT_EQ(0, higher_than_high_res_range.start); 121 EXPECT_EQ(0u, higher_than_high_res_range.start);
122 EXPECT_EQ(1, higher_than_high_res_range.end); 122 EXPECT_EQ(1u, higher_than_high_res_range.end);
123 123
124 high_res_range = 124 high_res_range =
125 set_without_low_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); 125 set_without_low_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES);
126 EXPECT_EQ(1, high_res_range.start); 126 EXPECT_EQ(1u, high_res_range.start);
127 EXPECT_EQ(2, high_res_range.end); 127 EXPECT_EQ(2u, high_res_range.end);
128 128
129 between_high_and_low_res_range = set_without_low_res->GetTilingRange( 129 between_high_and_low_res_range = set_without_low_res->GetTilingRange(
130 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); 130 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES);
131 EXPECT_EQ(2, between_high_and_low_res_range.start); 131 EXPECT_EQ(2u, between_high_and_low_res_range.start);
132 EXPECT_EQ(4, between_high_and_low_res_range.end); 132 EXPECT_EQ(4u, between_high_and_low_res_range.end);
133 133
134 low_res_range = 134 low_res_range =
135 set_without_low_res->GetTilingRange(PictureLayerTilingSet::LOW_RES); 135 set_without_low_res->GetTilingRange(PictureLayerTilingSet::LOW_RES);
136 EXPECT_EQ(0, low_res_range.end - low_res_range.start); 136 EXPECT_EQ(0u, low_res_range.end - low_res_range.start);
137 137
138 lower_than_low_res_range = set_without_low_res->GetTilingRange( 138 lower_than_low_res_range = set_without_low_res->GetTilingRange(
139 PictureLayerTilingSet::LOWER_THAN_LOW_RES); 139 PictureLayerTilingSet::LOWER_THAN_LOW_RES);
140 EXPECT_EQ(0, lower_than_low_res_range.end - lower_than_low_res_range.start); 140 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start);
141 141
142 scoped_ptr<PictureLayerTilingSet> set_with_only_high_and_low_res = 142 scoped_ptr<PictureLayerTilingSet> set_with_only_high_and_low_res =
143 CreateTilingSet(&client); 143 CreateTilingSet(&client);
144 high_res_tiling = set_with_only_high_and_low_res->AddTiling(1.0, pile); 144 high_res_tiling = set_with_only_high_and_low_res->AddTiling(1.0, pile);
145 high_res_tiling->set_resolution(HIGH_RESOLUTION); 145 high_res_tiling->set_resolution(HIGH_RESOLUTION);
146 low_res_tiling = set_with_only_high_and_low_res->AddTiling(0.5, pile); 146 low_res_tiling = set_with_only_high_and_low_res->AddTiling(0.5, pile);
147 low_res_tiling->set_resolution(LOW_RESOLUTION); 147 low_res_tiling->set_resolution(LOW_RESOLUTION);
148 148
149 higher_than_high_res_range = set_with_only_high_and_low_res->GetTilingRange( 149 higher_than_high_res_range = set_with_only_high_and_low_res->GetTilingRange(
150 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); 150 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES);
151 EXPECT_EQ(0, 151 EXPECT_EQ(0u,
152 higher_than_high_res_range.end - higher_than_high_res_range.start); 152 higher_than_high_res_range.end - higher_than_high_res_range.start);
153 153
154 high_res_range = set_with_only_high_and_low_res->GetTilingRange( 154 high_res_range = set_with_only_high_and_low_res->GetTilingRange(
155 PictureLayerTilingSet::HIGH_RES); 155 PictureLayerTilingSet::HIGH_RES);
156 EXPECT_EQ(0, high_res_range.start); 156 EXPECT_EQ(0u, high_res_range.start);
157 EXPECT_EQ(1, high_res_range.end); 157 EXPECT_EQ(1u, high_res_range.end);
158 158
159 between_high_and_low_res_range = 159 between_high_and_low_res_range =
160 set_with_only_high_and_low_res->GetTilingRange( 160 set_with_only_high_and_low_res->GetTilingRange(
161 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); 161 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES);
162 EXPECT_EQ(0, between_high_and_low_res_range.end - 162 EXPECT_EQ(0u, between_high_and_low_res_range.end -
163 between_high_and_low_res_range.start); 163 between_high_and_low_res_range.start);
164 164
165 low_res_range = set_with_only_high_and_low_res->GetTilingRange( 165 low_res_range = set_with_only_high_and_low_res->GetTilingRange(
166 PictureLayerTilingSet::LOW_RES); 166 PictureLayerTilingSet::LOW_RES);
167 EXPECT_EQ(1, low_res_range.start); 167 EXPECT_EQ(1u, low_res_range.start);
168 EXPECT_EQ(2, low_res_range.end); 168 EXPECT_EQ(2u, low_res_range.end);
169 169
170 lower_than_low_res_range = set_with_only_high_and_low_res->GetTilingRange( 170 lower_than_low_res_range = set_with_only_high_and_low_res->GetTilingRange(
171 PictureLayerTilingSet::LOWER_THAN_LOW_RES); 171 PictureLayerTilingSet::LOWER_THAN_LOW_RES);
172 EXPECT_EQ(0, lower_than_low_res_range.end - lower_than_low_res_range.start); 172 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start);
173 173
174 scoped_ptr<PictureLayerTilingSet> set_with_only_high_res = 174 scoped_ptr<PictureLayerTilingSet> set_with_only_high_res =
175 CreateTilingSet(&client); 175 CreateTilingSet(&client);
176 high_res_tiling = set_with_only_high_res->AddTiling(1.0, pile); 176 high_res_tiling = set_with_only_high_res->AddTiling(1.0, pile);
177 high_res_tiling->set_resolution(HIGH_RESOLUTION); 177 high_res_tiling->set_resolution(HIGH_RESOLUTION);
178 178
179 higher_than_high_res_range = set_with_only_high_res->GetTilingRange( 179 higher_than_high_res_range = set_with_only_high_res->GetTilingRange(
180 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); 180 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES);
181 EXPECT_EQ(0, 181 EXPECT_EQ(0u,
182 higher_than_high_res_range.end - higher_than_high_res_range.start); 182 higher_than_high_res_range.end - higher_than_high_res_range.start);
183 183
184 high_res_range = 184 high_res_range =
185 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); 185 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES);
186 EXPECT_EQ(0, high_res_range.start); 186 EXPECT_EQ(0u, high_res_range.start);
187 EXPECT_EQ(1, high_res_range.end); 187 EXPECT_EQ(1u, high_res_range.end);
188 188
189 between_high_and_low_res_range = set_with_only_high_res->GetTilingRange( 189 between_high_and_low_res_range = set_with_only_high_res->GetTilingRange(
190 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); 190 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES);
191 EXPECT_EQ(0, between_high_and_low_res_range.end - 191 EXPECT_EQ(0u, between_high_and_low_res_range.end -
192 between_high_and_low_res_range.start); 192 between_high_and_low_res_range.start);
193 193
194 low_res_range = 194 low_res_range =
195 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::LOW_RES); 195 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::LOW_RES);
196 EXPECT_EQ(0, low_res_range.end - low_res_range.start); 196 EXPECT_EQ(0u, low_res_range.end - low_res_range.start);
197 197
198 lower_than_low_res_range = set_with_only_high_res->GetTilingRange( 198 lower_than_low_res_range = set_with_only_high_res->GetTilingRange(
199 PictureLayerTilingSet::LOWER_THAN_LOW_RES); 199 PictureLayerTilingSet::LOWER_THAN_LOW_RES);
200 EXPECT_EQ(0, lower_than_low_res_range.end - lower_than_low_res_range.start); 200 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start);
201 } 201 }
202 202
203 class PictureLayerTilingSetTestWithResources : public testing::Test { 203 class PictureLayerTilingSetTestWithResources : public testing::Test {
204 public: 204 public:
205 void RunTest(int num_tilings, 205 void RunTest(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) {
210 FakeOutputSurfaceClient output_surface_client; 210 FakeOutputSurfaceClient output_surface_client;
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 447
448 // Clone from the pending to the active tree with the same max content size. 448 // Clone from the pending to the active tree with the same max content size.
449 active_set->UpdateTilingsToCurrentRasterSourceForActivation( 449 active_set->UpdateTilingsToCurrentRasterSourceForActivation(
450 pile.get(), pending_set.get(), Region(), 1.f, max_content_scale); 450 pile.get(), pending_set.get(), Region(), 1.f, max_content_scale);
451 // All the tilings are on the active tree. 451 // All the tilings are on the active tree.
452 EXPECT_EQ(2u, active_set->num_tilings()); 452 EXPECT_EQ(2u, active_set->num_tilings());
453 } 453 }
454 454
455 } // namespace 455 } // namespace
456 } // namespace cc 456 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/picture_layer_tiling_set.cc ('k') | cc/tiles/tile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698