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

Side by Side Diff: tests/PictureTest.cpp

Issue 1319723002: Have SkPicture::willPlayBackBitmaps() count SkImages too. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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/SkPictureCommon.h ('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 30 matching lines...) Expand all
41 #include "SkColorFilterImageFilter.h" 41 #include "SkColorFilterImageFilter.h"
42 42
43 static void make_bm(SkBitmap* bm, int w, int h, SkColor color, bool immutable) { 43 static void make_bm(SkBitmap* bm, int w, int h, SkColor color, bool immutable) {
44 bm->allocN32Pixels(w, h); 44 bm->allocN32Pixels(w, h);
45 bm->eraseColor(color); 45 bm->eraseColor(color);
46 if (immutable) { 46 if (immutable) {
47 bm->setImmutable(); 47 bm->setImmutable();
48 } 48 }
49 } 49 }
50 50
51 // For a while willPlayBackBitmaps() ignored SkImages and just looked for SkBitm aps.
52 static void test_images_are_found_by_willPlayBackBitmaps(skiatest::Reporter* rep orter) {
53 // We just need _some_ SkImage.
54 SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(SkBitmap()));
f(malita) 2015/08/26 14:56:00 I was kinda surprised that this works: we never in
mtklein 2015/08/26 15:13:56 Yeah, I was just sort of looking for the simplest
55
56 SkPictureRecorder recorder;
57 {
58 auto canvas = recorder.beginRecording(100,100);
59 canvas->drawImage(image, 0,0);
60 }
61 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
62
63 REPORTER_ASSERT(reporter, picture->willPlayBackBitmaps());
64 }
65
51 /* Hit a few SkPicture::Analysis cases not handled elsewhere. */ 66 /* Hit a few SkPicture::Analysis cases not handled elsewhere. */
52 static void test_analysis(skiatest::Reporter* reporter) { 67 static void test_analysis(skiatest::Reporter* reporter) {
53 SkPictureRecorder recorder; 68 SkPictureRecorder recorder;
54 69
55 SkCanvas* canvas = recorder.beginRecording(100, 100); 70 SkCanvas* canvas = recorder.beginRecording(100, 100);
56 { 71 {
57 canvas->drawRect(SkRect::MakeWH(10, 10), SkPaint ()); 72 canvas->drawRect(SkRect::MakeWH(10, 10), SkPaint ());
58 } 73 }
59 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 74 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
60 REPORTER_ASSERT(reporter, !picture->willPlayBackBitmaps()); 75 REPORTER_ASSERT(reporter, !picture->willPlayBackBitmaps());
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 test_serializing_empty_picture(); 1157 test_serializing_empty_picture();
1143 #else 1158 #else
1144 test_bad_bitmap(); 1159 test_bad_bitmap();
1145 #endif 1160 #endif
1146 test_unbalanced_save_restores(reporter); 1161 test_unbalanced_save_restores(reporter);
1147 test_peephole(); 1162 test_peephole();
1148 #if SK_SUPPORT_GPU 1163 #if SK_SUPPORT_GPU
1149 test_gpu_veto(reporter); 1164 test_gpu_veto(reporter);
1150 #endif 1165 #endif
1151 test_has_text(reporter); 1166 test_has_text(reporter);
1167 test_images_are_found_by_willPlayBackBitmaps(reporter);
1152 test_analysis(reporter); 1168 test_analysis(reporter);
1153 test_bitmap_with_encoded_data(reporter); 1169 test_bitmap_with_encoded_data(reporter);
1154 test_clip_bound_opt(reporter); 1170 test_clip_bound_opt(reporter);
1155 test_clip_expansion(reporter); 1171 test_clip_expansion(reporter);
1156 test_hierarchical(reporter); 1172 test_hierarchical(reporter);
1157 test_gen_id(reporter); 1173 test_gen_id(reporter);
1158 test_savelayer_extraction(reporter); 1174 test_savelayer_extraction(reporter);
1159 test_cull_rect_reset(reporter); 1175 test_cull_rect_reset(reporter);
1160 } 1176 }
1161 1177
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 1370
1355 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); 1371 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
1356 SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstr eam)); 1372 SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstr eam));
1357 1373
1358 REPORTER_ASSERT(r, SkToBool(deserializedPicture)); 1374 REPORTER_ASSERT(r, SkToBool(deserializedPicture));
1359 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1); 1375 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1);
1360 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2); 1376 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2);
1361 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3); 1377 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3);
1362 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4); 1378 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4);
1363 } 1379 }
OLDNEW
« no previous file with comments | « src/core/SkPictureCommon.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698