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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 for (size_t k = 0; k < SK_ARRAY_COUNT(procs); ++k) { | 181 for (size_t k = 0; k < SK_ARRAY_COUNT(procs); ++k) { |
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, NULL != data); |
reed1
2013/07/09 14:28:14
If we're going to do nothing if data is NULL, it t
tomhudson
2013/07/09 14:57:37
Done.
| |
192 int count = data->size() / sizeof(SkPixelRef*); | 192 int count = data ? data->size() / sizeof(SkPixelRef*) : 0; |
193 REPORTER_ASSERT(reporter, 1 == count); | 193 REPORTER_ASSERT(reporter, 1 == count); |
194 REPORTER_ASSERT(reporter, *(SkPixelRef**)data->data() == refs[i]); | 194 REPORTER_ASSERT(reporter, data && *(SkPixelRef**)data->data() == ref s[i]); |
195 } | 195 } |
196 | 196 |
197 // Test a bunch of random (mostly) rects, and compare the gather results | 197 // 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. | 198 // with a deduced list of refs by looking at the colors drawn. |
199 for (int j = 0; j < 100; ++j) { | 199 for (int j = 0; j < 100; ++j) { |
200 SkRect r; | 200 SkRect r; |
201 rand_rect(&r, rand, 2*W, 2*H); | 201 rand_rect(&r, rand, 2*W, 2*H); |
202 | 202 |
203 SkBitmap result; | 203 SkBitmap result; |
204 draw(pic, r, &result); | 204 draw(pic, r, &result); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 #endif | 557 #endif |
558 test_peephole(); | 558 test_peephole(); |
559 test_gatherpixelrefs(reporter); | 559 test_gatherpixelrefs(reporter); |
560 test_bitmap_with_encoded_data(reporter); | 560 test_bitmap_with_encoded_data(reporter); |
561 test_clone_empty(reporter); | 561 test_clone_empty(reporter); |
562 test_clip_bound_opt(reporter); | 562 test_clip_bound_opt(reporter); |
563 } | 563 } |
564 | 564 |
565 #include "TestClassDef.h" | 565 #include "TestClassDef.h" |
566 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) | 566 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) |
OLD | NEW |