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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 REPORTER_ASSERT(reporter, kWidth == info7.fBounds.width() && | 466 REPORTER_ASSERT(reporter, kWidth == info7.fBounds.width() && |
467 kHeight == info7.fBounds.height()); | 467 kHeight == info7.fBounds.height()); |
468 REPORTER_ASSERT(reporter, 0 == info7.fBounds.fLeft && 0 == info7.fBounds
.fTop); | 468 REPORTER_ASSERT(reporter, 0 == info7.fBounds.fLeft && 0 == info7.fBounds
.fTop); |
469 REPORTER_ASSERT(reporter, info7.fLocalMat.isIdentity()); | 469 REPORTER_ASSERT(reporter, info7.fLocalMat.isIdentity()); |
470 REPORTER_ASSERT(reporter, info7.fPreMat.isIdentity()); | 470 REPORTER_ASSERT(reporter, info7.fPreMat.isIdentity()); |
471 REPORTER_ASSERT(reporter, nullptr != info7.fPaint); | 471 REPORTER_ASSERT(reporter, nullptr != info7.fPaint); |
472 REPORTER_ASSERT(reporter, info7.fIsNested && !info7.fHasNestedLayers); /
/ is nested | 472 REPORTER_ASSERT(reporter, info7.fIsNested && !info7.fHasNestedLayers); /
/ is nested |
473 } | 473 } |
474 } | 474 } |
475 | 475 |
476 static void test_has_text(skiatest::Reporter* reporter) { | |
477 SkPictureRecorder recorder; | |
478 | |
479 SkCanvas* canvas = recorder.beginRecording(100,100); | |
480 { | |
481 canvas->drawRect(SkRect::MakeWH(20, 20), SkPaint()); | |
482 } | |
483 sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); | |
484 REPORTER_ASSERT(reporter, !picture->hasText()); | |
485 | |
486 SkPoint point = SkPoint::Make(10, 10); | |
487 canvas = recorder.beginRecording(100,100); | |
488 { | |
489 canvas->drawText("Q", 1, point.fX, point.fY, SkPaint()); | |
490 } | |
491 picture = recorder.finishRecordingAsPicture(); | |
492 REPORTER_ASSERT(reporter, picture->hasText()); | |
493 | |
494 canvas = recorder.beginRecording(100,100); | |
495 { | |
496 canvas->drawPosText("Q", 1, &point, SkPaint()); | |
497 } | |
498 picture = recorder.finishRecordingAsPicture(); | |
499 REPORTER_ASSERT(reporter, picture->hasText()); | |
500 | |
501 canvas = recorder.beginRecording(100,100); | |
502 { | |
503 canvas->drawPosTextH("Q", 1, &point.fX, point.fY, SkPaint()); | |
504 } | |
505 picture = recorder.finishRecordingAsPicture(); | |
506 REPORTER_ASSERT(reporter, picture->hasText()); | |
507 | |
508 canvas = recorder.beginRecording(100,100); | |
509 { | |
510 SkPath path; | |
511 path.moveTo(0, 0); | |
512 path.lineTo(50, 50); | |
513 | |
514 canvas->drawTextOnPathHV("Q", 1, path, point.fX, point.fY, SkPaint()); | |
515 } | |
516 picture = recorder.finishRecordingAsPicture(); | |
517 REPORTER_ASSERT(reporter, picture->hasText()); | |
518 | |
519 canvas = recorder.beginRecording(100,100); | |
520 { | |
521 SkPath path; | |
522 path.moveTo(0, 0); | |
523 path.lineTo(50, 50); | |
524 | |
525 canvas->drawTextOnPath("Q", 1, path, nullptr, SkPaint()); | |
526 } | |
527 picture = recorder.finishRecordingAsPicture(); | |
528 REPORTER_ASSERT(reporter, picture->hasText()); | |
529 | |
530 // Nest the previous picture inside a new one. | |
531 canvas = recorder.beginRecording(100,100); | |
532 { | |
533 canvas->drawPicture(picture.get()); | |
534 } | |
535 picture = recorder.finishRecordingAsPicture(); | |
536 REPORTER_ASSERT(reporter, picture->hasText()); | |
537 } | |
538 | |
539 static void set_canvas_to_save_count_4(SkCanvas* canvas) { | 476 static void set_canvas_to_save_count_4(SkCanvas* canvas) { |
540 canvas->restoreToCount(1); | 477 canvas->restoreToCount(1); |
541 canvas->save(); | 478 canvas->save(); |
542 canvas->save(); | 479 canvas->save(); |
543 canvas->save(); | 480 canvas->save(); |
544 } | 481 } |
545 | 482 |
546 /** | 483 /** |
547 * A canvas that records the number of saves, saveLayers and restores. | 484 * A canvas that records the number of saves, saveLayers and restores. |
548 */ | 485 */ |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 REPORTER_ASSERT(reporter, hasData->uniqueID() != empty->uniqueID()); | 1110 REPORTER_ASSERT(reporter, hasData->uniqueID() != empty->uniqueID()); |
1174 } | 1111 } |
1175 | 1112 |
1176 static void test_typeface(skiatest::Reporter* reporter) { | 1113 static void test_typeface(skiatest::Reporter* reporter) { |
1177 SkPictureRecorder recorder; | 1114 SkPictureRecorder recorder; |
1178 SkCanvas* canvas = recorder.beginRecording(10, 10); | 1115 SkCanvas* canvas = recorder.beginRecording(10, 10); |
1179 SkPaint paint; | 1116 SkPaint paint; |
1180 paint.setTypeface(SkTypeface::MakeFromName("Arial", SkTypeface::kItalic)); | 1117 paint.setTypeface(SkTypeface::MakeFromName("Arial", SkTypeface::kItalic)); |
1181 canvas->drawText("Q", 1, 0, 10, paint); | 1118 canvas->drawText("Q", 1, 0, 10, paint); |
1182 sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); | 1119 sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); |
1183 REPORTER_ASSERT(reporter, picture->hasText()); | |
1184 SkDynamicMemoryWStream stream; | 1120 SkDynamicMemoryWStream stream; |
1185 picture->serialize(&stream); | 1121 picture->serialize(&stream); |
1186 } | 1122 } |
1187 | 1123 |
1188 DEF_TEST(Picture, reporter) { | 1124 DEF_TEST(Picture, reporter) { |
1189 test_typeface(reporter); | 1125 test_typeface(reporter); |
1190 #ifdef SK_DEBUG | 1126 #ifdef SK_DEBUG |
1191 test_deleting_empty_picture(); | 1127 test_deleting_empty_picture(); |
1192 test_serializing_empty_picture(); | 1128 test_serializing_empty_picture(); |
1193 #else | 1129 #else |
1194 test_bad_bitmap(); | 1130 test_bad_bitmap(); |
1195 #endif | 1131 #endif |
1196 test_unbalanced_save_restores(reporter); | 1132 test_unbalanced_save_restores(reporter); |
1197 test_peephole(); | 1133 test_peephole(); |
1198 #if SK_SUPPORT_GPU | 1134 #if SK_SUPPORT_GPU |
1199 test_gpu_veto(reporter); | 1135 test_gpu_veto(reporter); |
1200 #endif | 1136 #endif |
1201 test_has_text(reporter); | |
1202 test_images_are_found_by_willPlayBackBitmaps(reporter); | 1137 test_images_are_found_by_willPlayBackBitmaps(reporter); |
1203 test_analysis(reporter); | 1138 test_analysis(reporter); |
1204 test_clip_bound_opt(reporter); | 1139 test_clip_bound_opt(reporter); |
1205 test_clip_expansion(reporter); | 1140 test_clip_expansion(reporter); |
1206 test_hierarchical(reporter); | 1141 test_hierarchical(reporter); |
1207 test_gen_id(reporter); | 1142 test_gen_id(reporter); |
1208 test_savelayer_extraction(reporter); | 1143 test_savelayer_extraction(reporter); |
1209 test_cull_rect_reset(reporter); | 1144 test_cull_rect_reset(reporter); |
1210 } | 1145 } |
1211 | 1146 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 | 1339 |
1405 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); | 1340 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); |
1406 sk_sp<SkPicture> deserializedPicture(SkPicture::MakeFromStream(rstream)); | 1341 sk_sp<SkPicture> deserializedPicture(SkPicture::MakeFromStream(rstream)); |
1407 | 1342 |
1408 REPORTER_ASSERT(r, deserializedPicture != nullptr); | 1343 REPORTER_ASSERT(r, deserializedPicture != nullptr); |
1409 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1); | 1344 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1); |
1410 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2); | 1345 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2); |
1411 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3); | 1346 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3); |
1412 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4); | 1347 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4); |
1413 } | 1348 } |
OLD | NEW |