OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include "Test.h" | 7 #include "Test.h" |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 SkAutoTUnref<SkPicture> pic(record_bitmaps(bm, pos, N, procs[k])); | 182 SkAutoTUnref<SkPicture> pic(record_bitmaps(bm, pos, N, procs[k])); |
183 | 183 |
184 // quick check for a small piece of each quadrant, which should just | 184 // quick check for a small piece of each quadrant, which should just |
185 // contain 1 bitmap. | 185 // contain 1 bitmap. |
186 for (size_t i = 0; i < SK_ARRAY_COUNT(pos); ++i) { | 186 for (size_t i = 0; i < SK_ARRAY_COUNT(pos); ++i) { |
187 SkRect r; | 187 SkRect r; |
188 r.set(2, 2, W - 2, H - 2); | 188 r.set(2, 2, W - 2, H - 2); |
189 r.offset(pos[i].fX, pos[i].fY); | 189 r.offset(pos[i].fX, pos[i].fY); |
190 SkAutoDataUnref data(SkPictureUtils::GatherPixelRefs(pic, r)); | 190 SkAutoDataUnref data(SkPictureUtils::GatherPixelRefs(pic, r)); |
191 REPORTER_ASSERT(reporter, data); | 191 REPORTER_ASSERT(reporter, data); |
192 int count = data->size() / sizeof(SkPixelRef*); | 192 if (data) { |
193 REPORTER_ASSERT(reporter, 1 == count); | 193 int count = data->size() / sizeof(SkPixelRef*); |
194 REPORTER_ASSERT(reporter, *(SkPixelRef**)data->data() == refs[i]); | 194 REPORTER_ASSERT(reporter, 1 == count); |
| 195 REPORTER_ASSERT(reporter, *(SkPixelRef**)data->data() == refs[i]
); |
| 196 } |
195 } | 197 } |
196 | 198 |
197 // Test a bunch of random (mostly) rects, and compare the gather results | 199 // Test a bunch of random (mostly) rects, and compare the gather results |
198 // with a deduced list of refs by looking at the colors drawn. | 200 // with a deduced list of refs by looking at the colors drawn. |
199 for (int j = 0; j < 100; ++j) { | 201 for (int j = 0; j < 100; ++j) { |
200 SkRect r; | 202 SkRect r; |
201 rand_rect(&r, rand, 2*W, 2*H); | 203 rand_rect(&r, rand, 2*W, 2*H); |
202 | 204 |
203 SkBitmap result; | 205 SkBitmap result; |
204 draw(pic, r, &result); | 206 draw(pic, r, &result); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 #endif | 559 #endif |
558 test_peephole(); | 560 test_peephole(); |
559 test_gatherpixelrefs(reporter); | 561 test_gatherpixelrefs(reporter); |
560 test_bitmap_with_encoded_data(reporter); | 562 test_bitmap_with_encoded_data(reporter); |
561 test_clone_empty(reporter); | 563 test_clone_empty(reporter); |
562 test_clip_bound_opt(reporter); | 564 test_clip_bound_opt(reporter); |
563 } | 565 } |
564 | 566 |
565 #include "TestClassDef.h" | 567 #include "TestClassDef.h" |
566 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) | 568 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) |
OLD | NEW |