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 "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 184 |
185 // quick check for a small piece of each quadrant, which should just | 185 // quick check for a small piece of each quadrant, which should just |
186 // contain 1 bitmap. | 186 // contain 1 bitmap. |
187 for (size_t i = 0; i < SK_ARRAY_COUNT(pos); ++i) { | 187 for (size_t i = 0; i < SK_ARRAY_COUNT(pos); ++i) { |
188 SkRect r; | 188 SkRect r; |
189 r.set(2, 2, W - 2, H - 2); | 189 r.set(2, 2, W - 2, H - 2); |
190 r.offset(pos[i].fX, pos[i].fY); | 190 r.offset(pos[i].fX, pos[i].fY); |
191 SkAutoDataUnref data(SkPictureUtils::GatherPixelRefs(pic, r)); | 191 SkAutoDataUnref data(SkPictureUtils::GatherPixelRefs(pic, r)); |
192 REPORTER_ASSERT(reporter, data); | 192 REPORTER_ASSERT(reporter, data); |
193 if (data) { | 193 if (data) { |
194 int count = data->size() / sizeof(SkPixelRef*); | 194 int count = static_cast<int>(data->size() / sizeof(SkPixelRef*))
; |
195 REPORTER_ASSERT(reporter, 1 == count); | 195 REPORTER_ASSERT(reporter, 1 == count); |
196 REPORTER_ASSERT(reporter, *(SkPixelRef**)data->data() == refs[i]
); | 196 REPORTER_ASSERT(reporter, *(SkPixelRef**)data->data() == refs[i]
); |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 // Test a bunch of random (mostly) rects, and compare the gather results | 200 // Test a bunch of random (mostly) rects, and compare the gather results |
201 // with a deduced list of refs by looking at the colors drawn. | 201 // with a deduced list of refs by looking at the colors drawn. |
202 for (int j = 0; j < 100; ++j) { | 202 for (int j = 0; j < 100; ++j) { |
203 SkRect r; | 203 SkRect r; |
204 rand_rect(&r, rand, 2*W, 2*H); | 204 rand_rect(&r, rand, 2*W, 2*H); |
205 | 205 |
206 SkBitmap result; | 206 SkBitmap result; |
207 draw(pic, r, &result); | 207 draw(pic, r, &result); |
208 SkTDArray<SkPixelRef*> array; | 208 SkTDArray<SkPixelRef*> array; |
209 | 209 |
210 SkData* data = SkPictureUtils::GatherPixelRefs(pic, r); | 210 SkData* data = SkPictureUtils::GatherPixelRefs(pic, r); |
211 size_t dataSize = data ? data->size() : 0; | 211 size_t dataSize = data ? data->size() : 0; |
212 int gatherCount = dataSize / sizeof(SkPixelRef*); | 212 int gatherCount = static_cast<int>(dataSize / sizeof(SkPixelRef*)); |
213 SkASSERT(gatherCount * sizeof(SkPixelRef*) == dataSize); | 213 SkASSERT(gatherCount * sizeof(SkPixelRef*) == dataSize); |
214 SkPixelRef** gatherRefs = data ? (SkPixelRef**)(data->data()) : NULL
; | 214 SkPixelRef** gatherRefs = data ? (SkPixelRef**)(data->data()) : NULL
; |
215 SkAutoDataUnref adu(data); | 215 SkAutoDataUnref adu(data); |
216 | 216 |
217 gather_from_colors(result, refs, N, &array); | 217 gather_from_colors(result, refs, N, &array); |
218 | 218 |
219 /* | 219 /* |
220 * GatherPixelRefs is conservative, so it can return more bitmaps | 220 * GatherPixelRefs is conservative, so it can return more bitmaps |
221 * that we actually can see (usually because of conservative bounds | 221 * that we actually can see (usually because of conservative bounds |
222 * inflation for antialiasing). Thus our check here is only that | 222 * inflation for antialiasing). Thus our check here is only that |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 test_peephole(); | 617 test_peephole(); |
618 test_gatherpixelrefs(reporter); | 618 test_gatherpixelrefs(reporter); |
619 test_bitmap_with_encoded_data(reporter); | 619 test_bitmap_with_encoded_data(reporter); |
620 test_clone_empty(reporter); | 620 test_clone_empty(reporter); |
621 test_clip_bound_opt(reporter); | 621 test_clip_bound_opt(reporter); |
622 test_clip_expansion(reporter); | 622 test_clip_expansion(reporter); |
623 } | 623 } |
624 | 624 |
625 #include "TestClassDef.h" | 625 #include "TestClassDef.h" |
626 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) | 626 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) |
OLD | NEW |