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 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1496 SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm)); | 1496 SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm)); |
1497 REPORTER_ASSERT(reporter, picture1->equals(picture2)); | 1497 REPORTER_ASSERT(reporter, picture1->equals(picture2)); |
1498 // Now test that a parse error was generated when trying to create a new SkP
icture without | 1498 // Now test that a parse error was generated when trying to create a new SkP
icture without |
1499 // providing a function to decode the bitmap. | 1499 // providing a function to decode the bitmap. |
1500 ErrorContext context; | 1500 ErrorContext context; |
1501 context.fErrors = 0; | 1501 context.fErrors = 0; |
1502 context.fReporter = reporter; | 1502 context.fReporter = reporter; |
1503 SkSetErrorCallback(assert_one_parse_error_cb, &context); | 1503 SkSetErrorCallback(assert_one_parse_error_cb, &context); |
1504 SkMemoryStream pictureStream(picture1); | 1504 SkMemoryStream pictureStream(picture1); |
1505 SkClearLastError(); | 1505 SkClearLastError(); |
1506 SkAutoUnref pictureFromStream(SkPicture::CreateFromStream(&pictureStream, NU
LL)); | 1506 SkAutoTUnref<SkPicture> pictureFromStream(SkPicture::CreateFromStream(&pictu
reStream, NULL)); |
1507 REPORTER_ASSERT(reporter, pictureFromStream.get() != NULL); | 1507 REPORTER_ASSERT(reporter, pictureFromStream.get() != NULL); |
1508 SkClearLastError(); | 1508 SkClearLastError(); |
1509 SkSetErrorCallback(NULL, NULL); | 1509 SkSetErrorCallback(NULL, NULL); |
1510 } | 1510 } |
1511 | 1511 |
1512 static void test_clip_bound_opt(skiatest::Reporter* reporter) { | 1512 static void test_clip_bound_opt(skiatest::Reporter* reporter) { |
1513 // Test for crbug.com/229011 | 1513 // Test for crbug.com/229011 |
1514 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4), | 1514 SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4), |
1515 SkIntToScalar(2), SkIntToScalar(2)); | 1515 SkIntToScalar(2), SkIntToScalar(2)); |
1516 SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(7), SkIntToScalar(7), | 1516 SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(7), SkIntToScalar(7), |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1726 SkPictureRecorder recorder; | 1726 SkPictureRecorder recorder; |
1727 | 1727 |
1728 recorder.beginRecording(0, 0); | 1728 recorder.beginRecording(0, 0); |
1729 SkAutoTUnref<SkPicture> empty(recorder.endRecording()); | 1729 SkAutoTUnref<SkPicture> empty(recorder.endRecording()); |
1730 | 1730 |
1731 // Sanity check to make sure we aren't under-measuring. | 1731 // Sanity check to make sure we aren't under-measuring. |
1732 REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(empty.get())
>= | 1732 REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(empty.get())
>= |
1733 sizeof(SkPicture) + sizeof(SkRecord)); | 1733 sizeof(SkPicture) + sizeof(SkRecord)); |
1734 | 1734 |
1735 // Protect against any unintentional bloat. | 1735 // Protect against any unintentional bloat. |
1736 REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(empty.get())
<= 184); | 1736 REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(empty.get())
<= 144); |
1737 | 1737 |
1738 // Sanity check of nested SkPictures. | 1738 // Sanity check of nested SkPictures. |
1739 SkPictureRecorder r2; | 1739 SkPictureRecorder r2; |
1740 r2.beginRecording(0, 0); | 1740 r2.beginRecording(0, 0); |
1741 r2.getRecordingCanvas()->drawPicture(empty.get()); | 1741 r2.getRecordingCanvas()->drawPicture(empty.get()); |
1742 SkAutoTUnref<SkPicture> nested(r2.endRecording()); | 1742 SkAutoTUnref<SkPicture> nested(r2.endRecording()); |
1743 | 1743 |
1744 REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(nested.get())
> | 1744 REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(nested.get())
> |
1745 SkPictureUtils::ApproximateBytesUsed(empty.get()))
; | 1745 SkPictureUtils::ApproximateBytesUsed(empty.get()))
; |
1746 } | 1746 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1913 | 1913 |
1914 // The picture shares the immutable pixels but copies the mutable ones. | 1914 // The picture shares the immutable pixels but copies the mutable ones. |
1915 REPORTER_ASSERT(r, mut.pixelRef()->unique()); | 1915 REPORTER_ASSERT(r, mut.pixelRef()->unique()); |
1916 REPORTER_ASSERT(r, !immut.pixelRef()->unique()); | 1916 REPORTER_ASSERT(r, !immut.pixelRef()->unique()); |
1917 | 1917 |
1918 // When the picture goes away, it's just our bitmaps holding the refs. | 1918 // When the picture goes away, it's just our bitmaps holding the refs. |
1919 pic.reset(NULL); | 1919 pic.reset(NULL); |
1920 REPORTER_ASSERT(r, mut.pixelRef()->unique()); | 1920 REPORTER_ASSERT(r, mut.pixelRef()->unique()); |
1921 REPORTER_ASSERT(r, immut.pixelRef()->unique()); | 1921 REPORTER_ASSERT(r, immut.pixelRef()->unique()); |
1922 } | 1922 } |
OLD | NEW |