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 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 context.fReporter = reporter; | 1487 context.fReporter = reporter; |
1488 SkSetErrorCallback(assert_one_parse_error_cb, &context); | 1488 SkSetErrorCallback(assert_one_parse_error_cb, &context); |
1489 SkMemoryStream pictureStream(picture1); | 1489 SkMemoryStream pictureStream(picture1); |
1490 SkClearLastError(); | 1490 SkClearLastError(); |
1491 SkAutoUnref pictureFromStream(SkPicture::CreateFromStream(&pictureStream, NU
LL)); | 1491 SkAutoUnref pictureFromStream(SkPicture::CreateFromStream(&pictureStream, NU
LL)); |
1492 REPORTER_ASSERT(reporter, pictureFromStream.get() != NULL); | 1492 REPORTER_ASSERT(reporter, pictureFromStream.get() != NULL); |
1493 SkClearLastError(); | 1493 SkClearLastError(); |
1494 SkSetErrorCallback(NULL, NULL); | 1494 SkSetErrorCallback(NULL, NULL); |
1495 } | 1495 } |
1496 | 1496 |
1497 static void test_draw_empty(skiatest::Reporter* reporter) { | |
1498 SkBitmap result; | |
1499 make_bm(&result, 2, 2, SK_ColorBLACK, false); | |
1500 | |
1501 SkCanvas canvas(result); | |
1502 | |
1503 { | |
1504 // stock SkPicture | |
1505 SkPictureRecorder recorder; | |
1506 recorder.beginRecording(1, 1); | |
1507 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | |
1508 | |
1509 canvas.drawPicture(picture); | |
1510 } | |
1511 | |
1512 { | |
1513 // tile grid | |
1514 SkTileGridFactory::TileGridInfo gridInfo; | |
1515 gridInfo.fMargin.setEmpty(); | |
1516 gridInfo.fOffset.setZero(); | |
1517 gridInfo.fTileInterval.set(1, 1); | |
1518 | |
1519 SkTileGridFactory factory(gridInfo); | |
1520 SkPictureRecorder recorder; | |
1521 recorder.beginRecording(1, 1, &factory); | |
1522 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | |
1523 | |
1524 canvas.drawPicture(picture); | |
1525 } | |
1526 | |
1527 { | |
1528 // RTree | |
1529 SkRTreeFactory factory; | |
1530 SkPictureRecorder recorder; | |
1531 recorder.beginRecording(1, 1, &factory); | |
1532 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | |
1533 | |
1534 canvas.drawPicture(picture); | |
1535 } | |
1536 } | |
1537 | |
1538 static void test_clip_bound_opt(skiatest::Reporter* reporter) { | 1497 static void test_clip_bound_opt(skiatest::Reporter* reporter) { |
1539 // Test for crbug.com/229011 | 1498 // Test for crbug.com/229011 |
1540 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4), | 1499 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4), |
1541 SkIntToScalar(2), SkIntToScalar(2)); | 1500 SkIntToScalar(2), SkIntToScalar(2)); |
1542 SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(7), SkIntToScalar(7), | 1501 SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(7), SkIntToScalar(7), |
1543 SkIntToScalar(1), SkIntToScalar(1)); | 1502 SkIntToScalar(1), SkIntToScalar(1)); |
1544 SkRect rect3 = SkRect::MakeXYWH(SkIntToScalar(6), SkIntToScalar(6), | 1503 SkRect rect3 = SkRect::MakeXYWH(SkIntToScalar(6), SkIntToScalar(6), |
1545 SkIntToScalar(1), SkIntToScalar(1)); | 1504 SkIntToScalar(1), SkIntToScalar(1)); |
1546 | 1505 |
1547 SkPath invPath; | 1506 SkPath invPath; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1758 test_unbalanced_save_restores(reporter); | 1717 test_unbalanced_save_restores(reporter); |
1759 test_peephole(); | 1718 test_peephole(); |
1760 #if SK_SUPPORT_GPU | 1719 #if SK_SUPPORT_GPU |
1761 test_gpu_veto(reporter); | 1720 test_gpu_veto(reporter); |
1762 #endif | 1721 #endif |
1763 test_has_text(reporter); | 1722 test_has_text(reporter); |
1764 test_analysis(reporter); | 1723 test_analysis(reporter); |
1765 test_gatherpixelrefs(reporter); | 1724 test_gatherpixelrefs(reporter); |
1766 test_gatherpixelrefsandrects(reporter); | 1725 test_gatherpixelrefsandrects(reporter); |
1767 test_bitmap_with_encoded_data(reporter); | 1726 test_bitmap_with_encoded_data(reporter); |
1768 test_draw_empty(reporter); | |
1769 test_clip_bound_opt(reporter); | 1727 test_clip_bound_opt(reporter); |
1770 test_clip_expansion(reporter); | 1728 test_clip_expansion(reporter); |
1771 test_hierarchical(reporter); | 1729 test_hierarchical(reporter); |
1772 test_gen_id(reporter); | 1730 test_gen_id(reporter); |
1773 } | 1731 } |
1774 | 1732 |
1775 #if SK_SUPPORT_GPU | 1733 #if SK_SUPPORT_GPU |
1776 DEF_GPUTEST(GPUPicture, reporter, factory) { | 1734 DEF_GPUTEST(GPUPicture, reporter, factory) { |
1777 test_gpu_picture_optimization(reporter, factory); | 1735 test_gpu_picture_optimization(reporter, factory); |
1778 } | 1736 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1920 | 1878 |
1921 // The picture shares the immutable pixels but copies the mutable ones. | 1879 // The picture shares the immutable pixels but copies the mutable ones. |
1922 REPORTER_ASSERT(r, mut.pixelRef()->unique()); | 1880 REPORTER_ASSERT(r, mut.pixelRef()->unique()); |
1923 REPORTER_ASSERT(r, !immut.pixelRef()->unique()); | 1881 REPORTER_ASSERT(r, !immut.pixelRef()->unique()); |
1924 | 1882 |
1925 // When the picture goes away, it's just our bitmaps holding the refs. | 1883 // When the picture goes away, it's just our bitmaps holding the refs. |
1926 pic.reset(NULL); | 1884 pic.reset(NULL); |
1927 REPORTER_ASSERT(r, mut.pixelRef()->unique()); | 1885 REPORTER_ASSERT(r, mut.pixelRef()->unique()); |
1928 REPORTER_ASSERT(r, immut.pixelRef()->unique()); | 1886 REPORTER_ASSERT(r, immut.pixelRef()->unique()); |
1929 } | 1887 } |
OLD | NEW |