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 | 7 |
8 #include "SkBBoxHierarchy.h" | 8 #include "SkBBoxHierarchy.h" |
9 #include "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 static void make_bm(SkBitmap* bm, int w, int h, SkColor color, bool immutable) { | 39 static void make_bm(SkBitmap* bm, int w, int h, SkColor color, bool immutable) { |
40 bm->allocN32Pixels(w, h); | 40 bm->allocN32Pixels(w, h); |
41 bm->eraseColor(color); | 41 bm->eraseColor(color); |
42 if (immutable) { | 42 if (immutable) { |
43 bm->setImmutable(); | 43 bm->setImmutable(); |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 // For a while willPlayBackBitmaps() ignored SkImages and just looked for SkBitm
aps. | 47 // For a while willPlayBackBitmaps() ignored SkImages and just looked for SkBitm
aps. |
48 static void test_images_are_found_by_willPlayBackBitmaps(skiatest::Reporter* rep
orter) { | 48 static void test_images_are_found_by_willPlayBackBitmaps(skiatest::Reporter* rep
orter) { |
49 // We just need _some_ SkImage. | 49 // We just need _some_ SkImage |
50 SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(SkBitmap())); | 50 const SkPMColor pixel = 0; |
| 51 const SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1); |
| 52 SkAutoTUnref<SkImage> image(SkImage::NewRasterCopy(info, &pixel, sizeof(pixe
l))); |
51 | 53 |
52 SkPictureRecorder recorder; | 54 SkPictureRecorder recorder; |
53 { | 55 recorder.beginRecording(100,100)->drawImage(image, 0,0); |
54 auto canvas = recorder.beginRecording(100,100); | |
55 canvas->drawImage(image, 0,0); | |
56 } | |
57 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 56 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
58 | 57 |
59 REPORTER_ASSERT(reporter, picture->willPlayBackBitmaps()); | 58 REPORTER_ASSERT(reporter, picture->willPlayBackBitmaps()); |
60 } | 59 } |
61 | 60 |
62 /* Hit a few SkPicture::Analysis cases not handled elsewhere. */ | 61 /* Hit a few SkPicture::Analysis cases not handled elsewhere. */ |
63 static void test_analysis(skiatest::Reporter* reporter) { | 62 static void test_analysis(skiatest::Reporter* reporter) { |
64 SkPictureRecorder recorder; | 63 SkPictureRecorder recorder; |
65 | 64 |
66 SkCanvas* canvas = recorder.beginRecording(100, 100); | 65 SkCanvas* canvas = recorder.beginRecording(100, 100); |
(...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 | 1378 |
1380 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); | 1379 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); |
1381 SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstr
eam)); | 1380 SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstr
eam)); |
1382 | 1381 |
1383 REPORTER_ASSERT(r, SkToBool(deserializedPicture)); | 1382 REPORTER_ASSERT(r, SkToBool(deserializedPicture)); |
1384 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1); | 1383 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1); |
1385 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2); | 1384 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2); |
1386 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3); | 1385 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3); |
1387 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4); | 1386 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4); |
1388 } | 1387 } |
OLD | NEW |