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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "cc/playback/display_list_raster_source.h" | 6 #include "cc/playback/display_list_raster_source.h" |
7 #include "cc/test/fake_display_list_recording_source.h" | 7 #include "cc/test/fake_display_list_recording_source.h" |
8 #include "cc/test/skia_common.h" | 8 #include "cc/test/skia_common.h" |
9 #include "skia/ext/refptr.h" | 9 #include "skia/ext/refptr.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 recording_source->SetGatherPixelRefs(true); | 194 recording_source->SetGatherPixelRefs(true); |
195 recording_source->Rerecord(); | 195 recording_source->Rerecord(); |
196 | 196 |
197 scoped_refptr<DisplayListRasterSource> raster = | 197 scoped_refptr<DisplayListRasterSource> raster = |
198 DisplayListRasterSource::CreateFromDisplayListRecordingSource( | 198 DisplayListRasterSource::CreateFromDisplayListRecordingSource( |
199 recording_source.get(), false); | 199 recording_source.get(), false); |
200 | 200 |
201 // Tile sized iterators. These should find only one pixel ref. | 201 // Tile sized iterators. These should find only one pixel ref. |
202 { | 202 { |
203 std::vector<skia::PositionPixelRef> pixel_refs; | 203 std::vector<skia::PositionPixelRef> pixel_refs; |
204 raster->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 1.0, &pixel_refs); | 204 raster->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), &pixel_refs); |
205 EXPECT_EQ(1u, pixel_refs.size()); | 205 EXPECT_EQ(1u, pixel_refs.size()); |
206 EXPECT_EQ(discardable_bitmap[0][0].pixelRef(), pixel_refs[0].pixel_ref); | 206 EXPECT_EQ(discardable_bitmap[0][0].pixelRef(), pixel_refs[0].pixel_ref); |
207 EXPECT_EQ(gfx::RectF(32, 32).ToString(), | 207 EXPECT_EQ(gfx::RectF(32, 32).ToString(), |
208 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
209 } | |
210 { | |
211 std::vector<skia::PositionPixelRef> pixel_refs; | |
212 raster->GatherPixelRefs(gfx::Rect(0, 0, 512, 512), 2.0, &pixel_refs); | |
213 EXPECT_EQ(1u, pixel_refs.size()); | |
214 EXPECT_EQ(discardable_bitmap[0][0].pixelRef(), pixel_refs[0].pixel_ref); | |
215 EXPECT_EQ(gfx::RectF(32, 32).ToString(), | |
216 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
217 } | |
218 { | |
219 std::vector<skia::PositionPixelRef> pixel_refs; | |
220 raster->GatherPixelRefs(gfx::Rect(0, 0, 128, 128), 0.5, &pixel_refs); | |
221 EXPECT_EQ(1u, pixel_refs.size()); | |
222 EXPECT_EQ(discardable_bitmap[0][0].pixelRef(), pixel_refs[0].pixel_ref); | |
223 EXPECT_EQ(gfx::RectF(32, 32).ToString(), | |
224 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | 208 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); |
225 } | 209 } |
226 // Shifted tile sized iterators. These should find only one pixel ref. | 210 // Shifted tile sized iterators. These should find only one pixel ref. |
227 { | 211 { |
228 std::vector<skia::PositionPixelRef> pixel_refs; | 212 std::vector<skia::PositionPixelRef> pixel_refs; |
229 raster->GatherPixelRefs(gfx::Rect(260, 260, 256, 256), 1.0, &pixel_refs); | 213 raster->GatherPixelRefs(gfx::Rect(260, 260, 256, 256), &pixel_refs); |
230 EXPECT_EQ(1u, pixel_refs.size()); | 214 EXPECT_EQ(1u, pixel_refs.size()); |
231 EXPECT_EQ(discardable_bitmap[1][1].pixelRef(), pixel_refs[0].pixel_ref); | 215 EXPECT_EQ(discardable_bitmap[1][1].pixelRef(), pixel_refs[0].pixel_ref); |
232 EXPECT_EQ(gfx::RectF(260, 260, 32, 32).ToString(), | 216 EXPECT_EQ(gfx::RectF(260, 260, 32, 32).ToString(), |
233 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
234 } | |
235 { | |
236 std::vector<skia::PositionPixelRef> pixel_refs; | |
237 raster->GatherPixelRefs(gfx::Rect(520, 520, 512, 512), 2.0, &pixel_refs); | |
238 EXPECT_EQ(1u, pixel_refs.size()); | |
239 EXPECT_EQ(discardable_bitmap[1][1].pixelRef(), pixel_refs[0].pixel_ref); | |
240 EXPECT_EQ(gfx::RectF(260, 260, 32, 32).ToString(), | |
241 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
242 } | |
243 { | |
244 std::vector<skia::PositionPixelRef> pixel_refs; | |
245 raster->GatherPixelRefs(gfx::Rect(130, 130, 128, 128), 0.5, &pixel_refs); | |
246 EXPECT_EQ(1u, pixel_refs.size()); | |
247 EXPECT_EQ(discardable_bitmap[1][1].pixelRef(), pixel_refs[0].pixel_ref); | |
248 EXPECT_EQ(gfx::RectF(260, 260, 32, 32).ToString(), | |
249 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | 217 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); |
250 } | 218 } |
251 // Ensure there's no discardable pixel refs in the empty cell | 219 // Ensure there's no discardable pixel refs in the empty cell |
252 { | 220 { |
253 std::vector<skia::PositionPixelRef> pixel_refs; | 221 std::vector<skia::PositionPixelRef> pixel_refs; |
254 raster->GatherPixelRefs(gfx::Rect(0, 256, 256, 256), 1.0, &pixel_refs); | 222 raster->GatherPixelRefs(gfx::Rect(0, 256, 256, 256), &pixel_refs); |
255 EXPECT_EQ(0u, pixel_refs.size()); | 223 EXPECT_EQ(0u, pixel_refs.size()); |
256 } | 224 } |
257 // Layer sized iterators. These should find three pixel ref. | 225 // Layer sized iterators. These should find three pixel ref. |
258 { | 226 { |
259 std::vector<skia::PositionPixelRef> pixel_refs; | 227 std::vector<skia::PositionPixelRef> pixel_refs; |
260 raster->GatherPixelRefs(gfx::Rect(0, 0, 512, 512), 1.0, &pixel_refs); | 228 raster->GatherPixelRefs(gfx::Rect(0, 0, 512, 512), &pixel_refs); |
261 EXPECT_EQ(3u, pixel_refs.size()); | 229 EXPECT_EQ(3u, pixel_refs.size()); |
262 EXPECT_EQ(discardable_bitmap[0][0].pixelRef(), pixel_refs[0].pixel_ref); | 230 EXPECT_EQ(discardable_bitmap[0][0].pixelRef(), pixel_refs[0].pixel_ref); |
263 EXPECT_EQ(discardable_bitmap[0][1].pixelRef(), pixel_refs[1].pixel_ref); | 231 EXPECT_EQ(discardable_bitmap[0][1].pixelRef(), pixel_refs[1].pixel_ref); |
264 EXPECT_EQ(discardable_bitmap[1][1].pixelRef(), pixel_refs[2].pixel_ref); | |
265 EXPECT_EQ(gfx::RectF(32, 32).ToString(), | |
266 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
267 EXPECT_EQ(gfx::RectF(260, 0, 32, 32).ToString(), | |
268 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString()); | |
269 EXPECT_EQ(gfx::RectF(260, 260, 32, 32).ToString(), | |
270 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString()); | |
271 } | |
272 { | |
273 std::vector<skia::PositionPixelRef> pixel_refs; | |
274 raster->GatherPixelRefs(gfx::Rect(0, 0, 1024, 1024), 2.0, &pixel_refs); | |
275 EXPECT_EQ(3u, pixel_refs.size()); | |
276 EXPECT_EQ(discardable_bitmap[0][0].pixelRef(), pixel_refs[0].pixel_ref); | |
277 EXPECT_EQ(discardable_bitmap[0][1].pixelRef(), pixel_refs[1].pixel_ref); | |
278 EXPECT_EQ(discardable_bitmap[1][1].pixelRef(), pixel_refs[2].pixel_ref); | |
279 EXPECT_EQ(gfx::RectF(32, 32).ToString(), | |
280 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | |
281 EXPECT_EQ(gfx::RectF(260, 0, 32, 32).ToString(), | |
282 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString()); | |
283 EXPECT_EQ(gfx::RectF(260, 260, 32, 32).ToString(), | |
284 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString()); | |
285 } | |
286 { | |
287 std::vector<skia::PositionPixelRef> pixel_refs; | |
288 raster->GatherPixelRefs(gfx::Rect(0, 0, 256, 256), 0.5, &pixel_refs); | |
289 EXPECT_EQ(3u, pixel_refs.size()); | |
290 EXPECT_EQ(discardable_bitmap[0][0].pixelRef(), pixel_refs[0].pixel_ref); | |
291 EXPECT_EQ(discardable_bitmap[0][1].pixelRef(), pixel_refs[1].pixel_ref); | |
292 EXPECT_EQ(discardable_bitmap[1][1].pixelRef(), pixel_refs[2].pixel_ref); | 232 EXPECT_EQ(discardable_bitmap[1][1].pixelRef(), pixel_refs[2].pixel_ref); |
293 EXPECT_EQ(gfx::RectF(32, 32).ToString(), | 233 EXPECT_EQ(gfx::RectF(32, 32).ToString(), |
294 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); | 234 gfx::SkRectToRectF(pixel_refs[0].pixel_ref_rect).ToString()); |
295 EXPECT_EQ(gfx::RectF(260, 0, 32, 32).ToString(), | 235 EXPECT_EQ(gfx::RectF(260, 0, 32, 32).ToString(), |
296 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString()); | 236 gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect).ToString()); |
297 EXPECT_EQ(gfx::RectF(260, 260, 32, 32).ToString(), | 237 EXPECT_EQ(gfx::RectF(260, 260, 32, 32).ToString(), |
298 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString()); | 238 gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect).ToString()); |
299 } | 239 } |
300 } | 240 } |
301 | 241 |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 scoped_refptr<DisplayListRasterSource> raster = | 534 scoped_refptr<DisplayListRasterSource> raster = |
595 DisplayListRasterSource::CreateFromDisplayListRecordingSource( | 535 DisplayListRasterSource::CreateFromDisplayListRecordingSource( |
596 recording_source.get(), false); | 536 recording_source.get(), false); |
597 size_t total_memory_usage = raster->GetPictureMemoryUsage(); | 537 size_t total_memory_usage = raster->GetPictureMemoryUsage(); |
598 EXPECT_GE(total_memory_usage, kReportedMemoryUsageInBytes); | 538 EXPECT_GE(total_memory_usage, kReportedMemoryUsageInBytes); |
599 EXPECT_LT(total_memory_usage, 2 * kReportedMemoryUsageInBytes); | 539 EXPECT_LT(total_memory_usage, 2 * kReportedMemoryUsageInBytes); |
600 } | 540 } |
601 | 541 |
602 } // namespace | 542 } // namespace |
603 } // namespace cc | 543 } // namespace cc |
OLD | NEW |