Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: tests/PictureTest.cpp

Issue 1568613008: unify how canvas checks for null on skia objects (images, blobs, pictures) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: CAPITALIZE the macro, update test now that we don't record the null-image Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698