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

Side by Side Diff: tests/PictureTest.cpp

Issue 678303004: Make RTree handle the case where the playback canvas has empty clip bounds (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 6 years, 1 month 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
« src/core/SkRecordDraw.cpp ('K') | « src/core/SkRecordDraw.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 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 // RTree 1528 // RTree
1529 SkRTreeFactory factory; 1529 SkRTreeFactory factory;
1530 SkPictureRecorder recorder; 1530 SkPictureRecorder recorder;
1531 recorder.beginRecording(1, 1, &factory); 1531 recorder.beginRecording(1, 1, &factory);
1532 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 1532 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
1533 1533
1534 canvas.drawPicture(picture); 1534 canvas.drawPicture(picture);
1535 } 1535 }
1536 } 1536 }
1537 1537
1538 static void test_draw_empty_clip(skiatest::Reporter* reporter) {
1539 SkBitmap result;
1540 make_bm(&result, 2, 2, SK_ColorGREEN, false);
1541
1542 // Test playing a non-empty picture into a canvas with an empty clip
1543 SkCanvas destinationCanvas(result);
1544 destinationCanvas.clipRect(SkRect::MakeXYWH(10, 10, 1, 1), SkRegion::kInters ect_Op);
1545 SkPaint paint;
1546
1547 {
1548 // stock SkPicture
1549 SkPictureRecorder recorder;
1550 SkCanvas* canvas = recorder.beginRecording(3, 3);
reed1 2014/10/28 17:39:51 we seem to make this picture three times, but only
1551 canvas->drawRect(SkRect::MakeXYWH(0, 0, 3, 3), paint);
1552 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
1553
1554 destinationCanvas.drawPicture(picture);
1555 REPORTER_ASSERT(reporter, SK_ColorGREEN == result.getColor(0, 0));
1556 }
1557
1558 {
1559 // tile grid
1560 SkTileGridFactory::TileGridInfo gridInfo;
1561 gridInfo.fMargin.setEmpty();
1562 gridInfo.fOffset.setZero();
1563 gridInfo.fTileInterval.set(1, 1);
1564
1565 SkTileGridFactory factory(gridInfo);
1566 SkPictureRecorder recorder;
1567 SkCanvas* canvas = recorder.beginRecording(3, 3, &factory);
1568 canvas->drawRect(SkRect::MakeXYWH(0, 0, 3, 3), paint);
1569 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
1570
1571 destinationCanvas.drawPicture(picture);
1572 REPORTER_ASSERT(reporter, SK_ColorGREEN == result.getColor(0, 0));
1573 }
1574
1575 {
1576 // RTree
1577 SkRTreeFactory factory;
1578 SkPictureRecorder recorder;
1579 SkCanvas* canvas = recorder.beginRecording(3, 3, &factory);
1580 canvas->drawRect(SkRect::MakeXYWH(0, 0, 3, 3), paint);
1581 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
1582
1583 destinationCanvas.drawPicture(picture);
1584 REPORTER_ASSERT(reporter, SK_ColorGREEN == result.getColor(0, 0));
1585 }
1586 }
1587
1538 static void test_clip_bound_opt(skiatest::Reporter* reporter) { 1588 static void test_clip_bound_opt(skiatest::Reporter* reporter) {
1539 // Test for crbug.com/229011 1589 // Test for crbug.com/229011
1540 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4), 1590 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4),
1541 SkIntToScalar(2), SkIntToScalar(2)); 1591 SkIntToScalar(2), SkIntToScalar(2));
1542 SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(7), SkIntToScalar(7), 1592 SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(7), SkIntToScalar(7),
1543 SkIntToScalar(1), SkIntToScalar(1)); 1593 SkIntToScalar(1), SkIntToScalar(1));
1544 SkRect rect3 = SkRect::MakeXYWH(SkIntToScalar(6), SkIntToScalar(6), 1594 SkRect rect3 = SkRect::MakeXYWH(SkIntToScalar(6), SkIntToScalar(6),
1545 SkIntToScalar(1), SkIntToScalar(1)); 1595 SkIntToScalar(1), SkIntToScalar(1));
1546 1596
1547 SkPath invPath; 1597 SkPath invPath;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 test_peephole(); 1809 test_peephole();
1760 #if SK_SUPPORT_GPU 1810 #if SK_SUPPORT_GPU
1761 test_gpu_veto(reporter); 1811 test_gpu_veto(reporter);
1762 #endif 1812 #endif
1763 test_has_text(reporter); 1813 test_has_text(reporter);
1764 test_analysis(reporter); 1814 test_analysis(reporter);
1765 test_gatherpixelrefs(reporter); 1815 test_gatherpixelrefs(reporter);
1766 test_gatherpixelrefsandrects(reporter); 1816 test_gatherpixelrefsandrects(reporter);
1767 test_bitmap_with_encoded_data(reporter); 1817 test_bitmap_with_encoded_data(reporter);
1768 test_draw_empty(reporter); 1818 test_draw_empty(reporter);
1819 test_draw_empty_clip(reporter);
1769 test_clip_bound_opt(reporter); 1820 test_clip_bound_opt(reporter);
1770 test_clip_expansion(reporter); 1821 test_clip_expansion(reporter);
1771 test_hierarchical(reporter); 1822 test_hierarchical(reporter);
1772 test_gen_id(reporter); 1823 test_gen_id(reporter);
1773 } 1824 }
1774 1825
1775 #if SK_SUPPORT_GPU 1826 #if SK_SUPPORT_GPU
1776 DEF_GPUTEST(GPUPicture, reporter, factory) { 1827 DEF_GPUTEST(GPUPicture, reporter, factory) {
1777 test_gpu_picture_optimization(reporter, factory); 1828 test_gpu_picture_optimization(reporter, factory);
1778 } 1829 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 1971
1921 // The picture shares the immutable pixels but copies the mutable ones. 1972 // The picture shares the immutable pixels but copies the mutable ones.
1922 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1973 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1923 REPORTER_ASSERT(r, !immut.pixelRef()->unique()); 1974 REPORTER_ASSERT(r, !immut.pixelRef()->unique());
1924 1975
1925 // When the picture goes away, it's just our bitmaps holding the refs. 1976 // When the picture goes away, it's just our bitmaps holding the refs.
1926 pic.reset(NULL); 1977 pic.reset(NULL);
1927 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1978 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1928 REPORTER_ASSERT(r, immut.pixelRef()->unique()); 1979 REPORTER_ASSERT(r, immut.pixelRef()->unique());
1929 } 1980 }
OLDNEW
« src/core/SkRecordDraw.cpp ('K') | « src/core/SkRecordDraw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698