OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "cc/playback/display_list_raster_source.h" | 7 #include "cc/playback/display_list_raster_source.h" |
8 #include "cc/test/fake_display_list_recording_source.h" | 8 #include "cc/test/fake_display_list_recording_source.h" |
9 #include "cc/test/fake_picture_pile.h" | 9 #include "cc/test/fake_picture_pile.h" |
10 #include "cc/test/fake_picture_pile_impl.h" | 10 #include "cc/test/fake_picture_pile_impl.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 recording_source->SetGatherPixelRefs(false); | 74 recording_source->SetGatherPixelRefs(false); |
75 recording_source->Rerecord(); | 75 recording_source->Rerecord(); |
76 | 76 |
77 scoped_refptr<RasterSource> raster_source = | 77 scoped_refptr<RasterSource> raster_source = |
78 CreateRasterSource<TypeParam>(recording_source.get()); | 78 CreateRasterSource<TypeParam>(recording_source.get()); |
79 | 79 |
80 // If recording source do not gather pixel ref, raster source is not going to | 80 // If recording source do not gather pixel ref, raster source is not going to |
81 // get pixel refs. | 81 // get pixel refs. |
82 { | 82 { |
83 std::vector<skia::PositionPixelRef> pixel_refs; | 83 std::vector<skia::PositionPixelRef> pixel_refs; |
84 raster_source->GatherPixelRefs(recorded_viewport, 1.0, &pixel_refs); | 84 raster_source->GatherPixelRefs(recorded_viewport, &pixel_refs); |
85 EXPECT_TRUE(pixel_refs.empty()); | 85 EXPECT_TRUE(pixel_refs.empty()); |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 TYPED_TEST(RecordingSourceTest, EmptyPixelRefs) { | 89 TYPED_TEST(RecordingSourceTest, EmptyPixelRefs) { |
90 gfx::Size grid_cell_size(128, 128); | 90 gfx::Size grid_cell_size(128, 128); |
91 gfx::Rect recorded_viewport(0, 0, 256, 256); | 91 gfx::Rect recorded_viewport(0, 0, 256, 256); |
92 | 92 |
93 scoped_ptr<TypeParam> recording_source = | 93 scoped_ptr<TypeParam> recording_source = |
94 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size); | 94 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size); |
95 recording_source->SetGatherPixelRefs(true); | 95 recording_source->SetGatherPixelRefs(true); |
96 recording_source->Rerecord(); | 96 recording_source->Rerecord(); |
97 | 97 |
98 scoped_refptr<RasterSource> raster_source = | 98 scoped_refptr<RasterSource> raster_source = |
99 CreateRasterSource<TypeParam>(recording_source.get()); | 99 CreateRasterSource<TypeParam>(recording_source.get()); |
100 | 100 |
101 // Tile sized iterators. | 101 // Tile sized iterators. |
102 { | 102 { |
103 std::vector<skia::PositionPixelRef> pixel_refs; | 103 std::vector<skia::PositionPixelRef> pixel_refs; |
104 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), 1.0, &pixel_refs); | 104 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), &pixel_refs); |
105 EXPECT_TRUE(pixel_refs.empty()); | |
106 } | |
107 { | |
108 std::vector<skia::PositionPixelRef> pixel_refs; | |
109 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 2.0, &pixel_refs); | |
110 EXPECT_TRUE(pixel_refs.empty()); | |
111 } | |
112 { | |
113 std::vector<skia::PositionPixelRef> pixel_refs; | |
114 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 64, 64), 0.5, &pixel_refs); | |
115 EXPECT_TRUE(pixel_refs.empty()); | 105 EXPECT_TRUE(pixel_refs.empty()); |
116 } | 106 } |
117 // Shifted tile sized iterators. | 107 // Shifted tile sized iterators. |
118 { | 108 { |
119 std::vector<skia::PositionPixelRef> pixel_refs; | 109 std::vector<skia::PositionPixelRef> pixel_refs; |
120 raster_source->GatherPixelRefs(gfx::Rect(140, 140, 128, 128), 1.0, | 110 raster_source->GatherPixelRefs(gfx::Rect(140, 140, 128, 128), &pixel_refs); |
121 &pixel_refs); | |
122 EXPECT_TRUE(pixel_refs.empty()); | |
123 } | |
124 { | |
125 std::vector<skia::PositionPixelRef> pixel_refs; | |
126 raster_source->GatherPixelRefs(gfx::Rect(280, 280, 256, 256), 2.0, | |
127 &pixel_refs); | |
128 EXPECT_TRUE(pixel_refs.empty()); | |
129 } | |
130 { | |
131 std::vector<skia::PositionPixelRef> pixel_refs; | |
132 raster_source->GatherPixelRefs(gfx::Rect(70, 70, 64, 64), 0.5, &pixel_refs); | |
133 EXPECT_TRUE(pixel_refs.empty()); | 111 EXPECT_TRUE(pixel_refs.empty()); |
134 } | 112 } |
135 // Layer sized iterators. | 113 // Layer sized iterators. |
136 { | 114 { |
137 std::vector<skia::PositionPixelRef> pixel_refs; | 115 std::vector<skia::PositionPixelRef> pixel_refs; |
138 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 1.0, &pixel_refs); | 116 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), &pixel_refs); |
139 EXPECT_TRUE(pixel_refs.empty()); | |
140 } | |
141 { | |
142 std::vector<skia::PositionPixelRef> pixel_refs; | |
143 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 512, 512), 2.0, &pixel_refs); | |
144 EXPECT_TRUE(pixel_refs.empty()); | |
145 } | |
146 { | |
147 std::vector<skia::PositionPixelRef> pixel_refs; | |
148 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), 0.5, &pixel_refs); | |
149 EXPECT_TRUE(pixel_refs.empty()); | 117 EXPECT_TRUE(pixel_refs.empty()); |
150 } | 118 } |
151 } | 119 } |
152 | 120 |
153 TYPED_TEST(RecordingSourceTest, NoDiscardablePixelRefs) { | 121 TYPED_TEST(RecordingSourceTest, NoDiscardablePixelRefs) { |
154 gfx::Size grid_cell_size(128, 128); | 122 gfx::Size grid_cell_size(128, 128); |
155 gfx::Rect recorded_viewport(0, 0, 256, 256); | 123 gfx::Rect recorded_viewport(0, 0, 256, 256); |
156 | 124 |
157 scoped_ptr<TypeParam> recording_source = | 125 scoped_ptr<TypeParam> recording_source = |
158 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size); | 126 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size); |
(...skipping 19 matching lines...) Expand all Loading... |
178 gfx::Point(150, 150)); | 146 gfx::Point(150, 150)); |
179 recording_source->SetGatherPixelRefs(true); | 147 recording_source->SetGatherPixelRefs(true); |
180 recording_source->Rerecord(); | 148 recording_source->Rerecord(); |
181 | 149 |
182 scoped_refptr<RasterSource> raster_source = | 150 scoped_refptr<RasterSource> raster_source = |
183 CreateRasterSource<TypeParam>(recording_source.get()); | 151 CreateRasterSource<TypeParam>(recording_source.get()); |
184 | 152 |
185 // Tile sized iterators. | 153 // Tile sized iterators. |
186 { | 154 { |
187 std::vector<skia::PositionPixelRef> pixel_refs; | 155 std::vector<skia::PositionPixelRef> pixel_refs; |
188 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), 1.0, &pixel_refs); | 156 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), &pixel_refs); |
189 EXPECT_TRUE(pixel_refs.empty()); | |
190 } | |
191 { | |
192 std::vector<skia::PositionPixelRef> pixel_refs; | |
193 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 2.0, &pixel_refs); | |
194 EXPECT_TRUE(pixel_refs.empty()); | |
195 } | |
196 { | |
197 std::vector<skia::PositionPixelRef> pixel_refs; | |
198 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 64, 64), 0.5, &pixel_refs); | |
199 EXPECT_TRUE(pixel_refs.empty()); | 157 EXPECT_TRUE(pixel_refs.empty()); |
200 } | 158 } |
201 // Shifted tile sized iterators. | 159 // Shifted tile sized iterators. |
202 { | 160 { |
203 std::vector<skia::PositionPixelRef> pixel_refs; | 161 std::vector<skia::PositionPixelRef> pixel_refs; |
204 raster_source->GatherPixelRefs(gfx::Rect(140, 140, 128, 128), 1.0, | 162 raster_source->GatherPixelRefs(gfx::Rect(140, 140, 128, 128), &pixel_refs); |
205 &pixel_refs); | |
206 EXPECT_TRUE(pixel_refs.empty()); | |
207 } | |
208 { | |
209 std::vector<skia::PositionPixelRef> pixel_refs; | |
210 raster_source->GatherPixelRefs(gfx::Rect(280, 280, 256, 256), 2.0, | |
211 &pixel_refs); | |
212 EXPECT_TRUE(pixel_refs.empty()); | |
213 } | |
214 { | |
215 std::vector<skia::PositionPixelRef> pixel_refs; | |
216 raster_source->GatherPixelRefs(gfx::Rect(70, 70, 64, 64), 0.5, &pixel_refs); | |
217 EXPECT_TRUE(pixel_refs.empty()); | 163 EXPECT_TRUE(pixel_refs.empty()); |
218 } | 164 } |
219 // Layer sized iterators. | 165 // Layer sized iterators. |
220 { | 166 { |
221 std::vector<skia::PositionPixelRef> pixel_refs; | 167 std::vector<skia::PositionPixelRef> pixel_refs; |
222 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 1.0, &pixel_refs); | 168 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), &pixel_refs); |
223 EXPECT_TRUE(pixel_refs.empty()); | |
224 } | |
225 { | |
226 std::vector<skia::PositionPixelRef> pixel_refs; | |
227 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 512, 512), 2.0, &pixel_refs); | |
228 EXPECT_TRUE(pixel_refs.empty()); | |
229 } | |
230 { | |
231 std::vector<skia::PositionPixelRef> pixel_refs; | |
232 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), 0.5, &pixel_refs); | |
233 EXPECT_TRUE(pixel_refs.empty()); | 169 EXPECT_TRUE(pixel_refs.empty()); |
234 } | 170 } |
235 } | 171 } |
236 | 172 |
237 TYPED_TEST(RecordingSourceTest, DiscardablePixelRefs) { | 173 TYPED_TEST(RecordingSourceTest, DiscardablePixelRefs) { |
238 gfx::Size grid_cell_size(128, 128); | 174 gfx::Size grid_cell_size(128, 128); |
239 gfx::Rect recorded_viewport(0, 0, 256, 256); | 175 gfx::Rect recorded_viewport(0, 0, 256, 256); |
240 | 176 |
241 scoped_ptr<TypeParam> recording_source = | 177 scoped_ptr<TypeParam> recording_source = |
242 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size); | 178 CreateRecordingSource<TypeParam>(recorded_viewport, grid_cell_size); |
(...skipping 16 matching lines...) Expand all Loading... |
259 gfx::Point(140, 140)); | 195 gfx::Point(140, 140)); |
260 recording_source->SetGatherPixelRefs(true); | 196 recording_source->SetGatherPixelRefs(true); |
261 recording_source->Rerecord(); | 197 recording_source->Rerecord(); |
262 | 198 |
263 scoped_refptr<RasterSource> raster_source = | 199 scoped_refptr<RasterSource> raster_source = |
264 CreateRasterSource<TypeParam>(recording_source.get()); | 200 CreateRasterSource<TypeParam>(recording_source.get()); |
265 | 201 |
266 // Tile sized iterators. These should find only one pixel ref. | 202 // Tile sized iterators. These should find only one pixel ref. |
267 { | 203 { |
268 std::vector<skia::PositionPixelRef> pixel_refs; | 204 std::vector<skia::PositionPixelRef> pixel_refs; |
269 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), 1.0, &pixel_refs); | 205 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), &pixel_refs); |
270 EXPECT_EQ(1u, pixel_refs.size()); | 206 EXPECT_EQ(1u, pixel_refs.size()); |
271 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef()); | 207 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef()); |
272 EXPECT_EQ(gfx::RectF(32, 32).ToString(), | 208 EXPECT_EQ(gfx::RectF(32, 32).ToString(), |
273 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
274 } | |
275 { | |
276 std::vector<skia::PositionPixelRef> pixel_refs; | |
277 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 2.0, &pixel_refs); | |
278 EXPECT_EQ(1u, pixel_refs.size()); | |
279 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef()); | |
280 EXPECT_EQ(gfx::RectF(32, 32).ToString(), | |
281 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
282 } | |
283 { | |
284 std::vector<skia::PositionPixelRef> pixel_refs; | |
285 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 64, 64), 0.5, &pixel_refs); | |
286 EXPECT_EQ(1u, pixel_refs.size()); | |
287 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef()); | |
288 EXPECT_EQ(gfx::RectF(32, 32).ToString(), | |
289 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | 209 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); |
290 } | 210 } |
291 | 211 |
292 // Shifted tile sized iterators. These should find only one pixel ref. | 212 // Shifted tile sized iterators. These should find only one pixel ref. |
293 { | 213 { |
294 std::vector<skia::PositionPixelRef> pixel_refs; | 214 std::vector<skia::PositionPixelRef> pixel_refs; |
295 raster_source->GatherPixelRefs(gfx::Rect(140, 140, 128, 128), 1.0, | 215 raster_source->GatherPixelRefs(gfx::Rect(140, 140, 128, 128), &pixel_refs); |
296 &pixel_refs); | |
297 EXPECT_EQ(1u, pixel_refs.size()); | 216 EXPECT_EQ(1u, pixel_refs.size()); |
298 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[1][1].pixelRef()); | 217 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[1][1].pixelRef()); |
299 EXPECT_EQ(gfx::RectF(140, 140, 32, 32).ToString(), | 218 EXPECT_EQ(gfx::RectF(140, 140, 32, 32).ToString(), |
300 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
301 } | |
302 { | |
303 std::vector<skia::PositionPixelRef> pixel_refs; | |
304 raster_source->GatherPixelRefs(gfx::Rect(280, 280, 256, 256), 2.0, | |
305 &pixel_refs); | |
306 EXPECT_EQ(1u, pixel_refs.size()); | |
307 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[1][1].pixelRef()); | |
308 EXPECT_EQ(gfx::RectF(140, 140, 32, 32).ToString(), | |
309 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
310 } | |
311 { | |
312 std::vector<skia::PositionPixelRef> pixel_refs; | |
313 raster_source->GatherPixelRefs(gfx::Rect(70, 70, 64, 64), 0.5, &pixel_refs); | |
314 EXPECT_EQ(1u, pixel_refs.size()); | |
315 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[1][1].pixelRef()); | |
316 EXPECT_EQ(gfx::RectF(140, 140, 32, 32).ToString(), | |
317 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | 219 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); |
318 } | 220 } |
319 | 221 |
320 // Ensure there's no discardable pixel refs in the empty cell | 222 // Ensure there's no discardable pixel refs in the empty cell |
321 { | 223 { |
322 std::vector<skia::PositionPixelRef> pixel_refs; | 224 std::vector<skia::PositionPixelRef> pixel_refs; |
323 raster_source->GatherPixelRefs(gfx::Rect(140, 0, 128, 128), 1.0, | 225 raster_source->GatherPixelRefs(gfx::Rect(140, 0, 128, 128), &pixel_refs); |
324 &pixel_refs); | |
325 EXPECT_TRUE(pixel_refs.empty()); | 226 EXPECT_TRUE(pixel_refs.empty()); |
326 } | 227 } |
327 | 228 |
328 // Layer sized iterators. These should find all 3 pixel refs. | 229 // Layer sized iterators. These should find all 3 pixel refs. |
329 { | 230 { |
330 std::vector<skia::PositionPixelRef> pixel_refs; | 231 std::vector<skia::PositionPixelRef> pixel_refs; |
331 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 1.0, &pixel_refs); | 232 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), &pixel_refs); |
332 EXPECT_EQ(3u, pixel_refs.size()); | 233 EXPECT_EQ(3u, pixel_refs.size()); |
333 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef()); | 234 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef()); |
334 EXPECT_TRUE(pixel_refs[1].pixel_ref == discardable_bitmap[1][0].pixelRef()); | 235 EXPECT_TRUE(pixel_refs[1].pixel_ref == discardable_bitmap[1][0].pixelRef()); |
335 EXPECT_TRUE(pixel_refs[2].pixel_ref == discardable_bitmap[1][1].pixelRef()); | |
336 EXPECT_EQ(gfx::RectF(32, 32).ToString(), | |
337 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
338 EXPECT_EQ(gfx::RectF(0, 130, 32, 32).ToString(), | |
339 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString()); | |
340 EXPECT_EQ(gfx::RectF(140, 140, 32, 32).ToString(), | |
341 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString()); | |
342 } | |
343 { | |
344 std::vector<skia::PositionPixelRef> pixel_refs; | |
345 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 512, 512), 2.0, &pixel_refs); | |
346 EXPECT_EQ(3u, pixel_refs.size()); | |
347 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef()); | |
348 EXPECT_TRUE(pixel_refs[1].pixel_ref == discardable_bitmap[1][0].pixelRef()); | |
349 EXPECT_TRUE(pixel_refs[2].pixel_ref == discardable_bitmap[1][1].pixelRef()); | |
350 EXPECT_EQ(gfx::RectF(32, 32).ToString(), | |
351 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
352 EXPECT_EQ(gfx::RectF(0, 130, 32, 32).ToString(), | |
353 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString()); | |
354 EXPECT_EQ(gfx::RectF(140, 140, 32, 32).ToString(), | |
355 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString()); | |
356 } | |
357 { | |
358 std::vector<skia::PositionPixelRef> pixel_refs; | |
359 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), 0.5, &pixel_refs); | |
360 EXPECT_EQ(3u, pixel_refs.size()); | |
361 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef()); | |
362 EXPECT_TRUE(pixel_refs[1].pixel_ref == discardable_bitmap[1][0].pixelRef()); | |
363 EXPECT_TRUE(pixel_refs[2].pixel_ref == discardable_bitmap[1][1].pixelRef()); | 236 EXPECT_TRUE(pixel_refs[2].pixel_ref == discardable_bitmap[1][1].pixelRef()); |
364 EXPECT_EQ(gfx::RectF(32, 32).ToString(), | 237 EXPECT_EQ(gfx::RectF(32, 32).ToString(), |
365 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | 238 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); |
366 EXPECT_EQ(gfx::RectF(0, 130, 32, 32).ToString(), | 239 EXPECT_EQ(gfx::RectF(0, 130, 32, 32).ToString(), |
367 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString()); | 240 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString()); |
368 EXPECT_EQ(gfx::RectF(140, 140, 32, 32).ToString(), | 241 EXPECT_EQ(gfx::RectF(140, 140, 32, 32).ToString(), |
369 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString()); | 242 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString()); |
370 } | 243 } |
371 } | 244 } |
372 | 245 |
(...skipping 28 matching lines...) Expand all Loading... |
401 gfx::Point(260, 260)); | 274 gfx::Point(260, 260)); |
402 recording_source->SetGatherPixelRefs(true); | 275 recording_source->SetGatherPixelRefs(true); |
403 recording_source->Rerecord(); | 276 recording_source->Rerecord(); |
404 | 277 |
405 scoped_refptr<RasterSource> raster_source = | 278 scoped_refptr<RasterSource> raster_source = |
406 CreateRasterSource<TypeParam>(recording_source.get()); | 279 CreateRasterSource<TypeParam>(recording_source.get()); |
407 | 280 |
408 // Tile sized iterators. These should find only one pixel ref. | 281 // Tile sized iterators. These should find only one pixel ref. |
409 { | 282 { |
410 std::vector<skia::PositionPixelRef> pixel_refs; | 283 std::vector<skia::PositionPixelRef> pixel_refs; |
411 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 1.0, &pixel_refs); | 284 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), &pixel_refs); |
412 EXPECT_EQ(1u, pixel_refs.size()); | 285 EXPECT_EQ(1u, pixel_refs.size()); |
413 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef()); | 286 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef()); |
414 EXPECT_EQ(gfx::RectF(128, 128).ToString(), | 287 EXPECT_EQ(gfx::RectF(128, 128).ToString(), |
415 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
416 } | |
417 { | |
418 std::vector<skia::PositionPixelRef> pixel_refs; | |
419 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 512, 512), 2.0, &pixel_refs); | |
420 EXPECT_EQ(1u, pixel_refs.size()); | |
421 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef()); | |
422 EXPECT_EQ(gfx::RectF(128, 128).ToString(), | |
423 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
424 } | |
425 { | |
426 std::vector<skia::PositionPixelRef> pixel_refs; | |
427 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), 0.5, &pixel_refs); | |
428 EXPECT_EQ(1u, pixel_refs.size()); | |
429 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef()); | |
430 EXPECT_EQ(gfx::RectF(128, 128).ToString(), | |
431 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | 288 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); |
432 } | 289 } |
433 // Shifted tile sized iterators. These should find only one pixel ref. | 290 // Shifted tile sized iterators. These should find only one pixel ref. |
434 { | 291 { |
435 std::vector<skia::PositionPixelRef> pixel_refs; | 292 std::vector<skia::PositionPixelRef> pixel_refs; |
436 raster_source->GatherPixelRefs(gfx::Rect(260, 260, 256, 256), 1.0, | 293 raster_source->GatherPixelRefs(gfx::Rect(260, 260, 256, 256), &pixel_refs); |
437 &pixel_refs); | |
438 EXPECT_EQ(1u, pixel_refs.size()); | 294 EXPECT_EQ(1u, pixel_refs.size()); |
439 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[1][1].pixelRef()); | 295 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[1][1].pixelRef()); |
440 EXPECT_EQ(gfx::RectF(260, 260, 128, 128).ToString(), | 296 EXPECT_EQ(gfx::RectF(260, 260, 128, 128).ToString(), |
441 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
442 } | |
443 { | |
444 std::vector<skia::PositionPixelRef> pixel_refs; | |
445 raster_source->GatherPixelRefs(gfx::Rect(520, 520, 512, 512), 2.0, | |
446 &pixel_refs); | |
447 EXPECT_EQ(1u, pixel_refs.size()); | |
448 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[1][1].pixelRef()); | |
449 EXPECT_EQ(gfx::RectF(260, 260, 128, 128).ToString(), | |
450 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
451 } | |
452 { | |
453 std::vector<skia::PositionPixelRef> pixel_refs; | |
454 raster_source->GatherPixelRefs(gfx::Rect(130, 130, 128, 128), 0.5, | |
455 &pixel_refs); | |
456 EXPECT_EQ(1u, pixel_refs.size()); | |
457 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[1][1].pixelRef()); | |
458 EXPECT_EQ(gfx::RectF(260, 260, 128, 128).ToString(), | |
459 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | 297 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); |
460 } | 298 } |
461 // Ensure there's no discardable pixel refs in the empty cell | 299 // Ensure there's no discardable pixel refs in the empty cell |
462 { | 300 { |
463 std::vector<skia::PositionPixelRef> pixel_refs; | 301 std::vector<skia::PositionPixelRef> pixel_refs; |
464 raster_source->GatherPixelRefs(gfx::Rect(0, 256, 256, 256), 1.0, | 302 raster_source->GatherPixelRefs(gfx::Rect(0, 256, 256, 256), &pixel_refs); |
465 &pixel_refs); | |
466 EXPECT_TRUE(pixel_refs.empty()); | 303 EXPECT_TRUE(pixel_refs.empty()); |
467 } | 304 } |
468 // Layer sized iterators. These should find three pixel ref. | 305 // Layer sized iterators. These should find three pixel ref. |
469 { | 306 { |
470 std::vector<skia::PositionPixelRef> pixel_refs; | 307 std::vector<skia::PositionPixelRef> pixel_refs; |
471 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 512, 512), 1.0, &pixel_refs); | 308 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 512, 512), &pixel_refs); |
472 EXPECT_EQ(3u, pixel_refs.size()); | 309 EXPECT_EQ(3u, pixel_refs.size()); |
473 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef()); | 310 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef()); |
474 EXPECT_TRUE(pixel_refs[1].pixel_ref == discardable_bitmap[0][1].pixelRef()); | 311 EXPECT_TRUE(pixel_refs[1].pixel_ref == discardable_bitmap[0][1].pixelRef()); |
475 EXPECT_TRUE(pixel_refs[2].pixel_ref == discardable_bitmap[1][1].pixelRef()); | |
476 EXPECT_EQ(gfx::RectF(128, 128).ToString(), | |
477 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
478 EXPECT_EQ(gfx::RectF(260, 0, 128, 128).ToString(), | |
479 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString()); | |
480 EXPECT_EQ(gfx::RectF(260, 260, 128, 128).ToString(), | |
481 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString()); | |
482 } | |
483 { | |
484 std::vector<skia::PositionPixelRef> pixel_refs; | |
485 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 1024, 1024), 2.0, | |
486 &pixel_refs); | |
487 EXPECT_EQ(3u, pixel_refs.size()); | |
488 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef()); | |
489 EXPECT_TRUE(pixel_refs[1].pixel_ref == discardable_bitmap[0][1].pixelRef()); | |
490 EXPECT_TRUE(pixel_refs[2].pixel_ref == discardable_bitmap[1][1].pixelRef()); | |
491 EXPECT_EQ(gfx::RectF(128, 128).ToString(), | |
492 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
493 EXPECT_EQ(gfx::RectF(260, 0, 128, 128).ToString(), | |
494 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString()); | |
495 EXPECT_EQ(gfx::RectF(260, 260, 128, 128).ToString(), | |
496 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString()); | |
497 } | |
498 { | |
499 std::vector<skia::PositionPixelRef> pixel_refs; | |
500 raster_source->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 0.5, &pixel_refs); | |
501 EXPECT_EQ(3u, pixel_refs.size()); | |
502 EXPECT_TRUE(pixel_refs[0].pixel_ref == discardable_bitmap[0][0].pixelRef()); | |
503 EXPECT_TRUE(pixel_refs[1].pixel_ref == discardable_bitmap[0][1].pixelRef()); | |
504 EXPECT_TRUE(pixel_refs[2].pixel_ref == discardable_bitmap[1][1].pixelRef()); | 312 EXPECT_TRUE(pixel_refs[2].pixel_ref == discardable_bitmap[1][1].pixelRef()); |
505 EXPECT_EQ(gfx::RectF(128, 128).ToString(), | 313 EXPECT_EQ(gfx::RectF(128, 128).ToString(), |
506 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | 314 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); |
507 EXPECT_EQ(gfx::RectF(260, 0, 128, 128).ToString(), | 315 EXPECT_EQ(gfx::RectF(260, 0, 128, 128).ToString(), |
508 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString()); | 316 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString()); |
509 EXPECT_EQ(gfx::RectF(260, 260, 128, 128).ToString(), | 317 EXPECT_EQ(gfx::RectF(260, 260, 128, 128).ToString(), |
510 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString()); | 318 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString()); |
511 } | 319 } |
512 } | 320 } |
513 | 321 |
514 } // namespace | 322 } // namespace |
515 } // namespace cc | 323 } // namespace cc |
OLD | NEW |