aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PictureTest.cpp
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2016-10-25 09:57:13 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-10-25 14:19:07 +0000
commit7614794c9ad14d76abed6cf00890ad1a09c2cb8b (patch)
treefb79a90fe28039038d5d54e809f68e83399cb32a /tests/PictureTest.cpp
parent67c7c81a82b6351e9fbbf235084d7120162d9268 (diff)
remove discardablepixelref
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3883 Change-Id: Ica284be78563a4ccd6e0cb07404064fb5511ba57 Reviewed-on: https://skia-review.googlesource.com/3883 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'tests/PictureTest.cpp')
-rw-r--r--tests/PictureTest.cpp71
1 files changed, 0 insertions, 71 deletions
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index 3aca69f4e1..8c7312ef07 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -620,77 +620,6 @@ static void test_bad_bitmap() {
}
#endif
-static sk_sp<SkData> serialized_picture_from_bitmap(const SkBitmap& bitmap) {
- SkPictureRecorder recorder;
- SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(bitmap.width()),
- SkIntToScalar(bitmap.height()));
- canvas->drawBitmap(bitmap, 0, 0);
- sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
-
- SkDynamicMemoryWStream wStream;
- SkAutoTUnref<SkPixelSerializer> serializer(
- SkImageEncoder::CreatePixelSerializer());
- picture->serialize(&wStream, serializer);
- return wStream.detachAsData();
-}
-
-static void md5(const SkBitmap& bm, SkMD5::Digest* digest) {
- SkAutoLockPixels autoLockPixels(bm);
- SkASSERT(bm.getPixels());
- SkMD5 md5;
- size_t rowLen = bm.info().bytesPerPixel() * bm.width();
- for (int y = 0; y < bm.height(); ++y) {
- md5.write(bm.getAddr(0, y), rowLen);
- }
- md5.finish(*digest);
-}
-
-DEF_TEST(Picture_EncodedData, reporter) {
- // Create a bitmap that will be encoded.
- SkBitmap original;
- make_bm(&original, 100, 100, SK_ColorBLUE, true);
- SkDynamicMemoryWStream wStream;
- if (!SkImageEncoder::EncodeStream(&wStream, original, SkImageEncoder::kPNG_Type, 100)) {
- return;
- }
- sk_sp<SkData> data = wStream.detachAsData();
-
- SkBitmap bm;
- bool installSuccess = SkDEPRECATED_InstallDiscardablePixelRef(data.get(), &bm);
- REPORTER_ASSERT(reporter, installSuccess);
-
- // Write both bitmaps to pictures, and ensure that the resulting data streams are the same.
- // Flattening original will follow the old path of performing an encode, while flattening bm
- // will use the already encoded data.
- sk_sp<SkData> picture1(serialized_picture_from_bitmap(original));
- sk_sp<SkData> picture2(serialized_picture_from_bitmap(bm));
- REPORTER_ASSERT(reporter, picture1->equals(picture2.get()));
-
- // Now test that a parse error was generated when trying to create a new SkPicture without
- // providing a function to decode the bitmap.
- SkMemoryStream pictureStream(std::move(picture1));
- sk_sp<SkPicture> pictureFromStream(SkPicture::MakeFromStream(&pictureStream));
- REPORTER_ASSERT(reporter, pictureFromStream.get() != nullptr);
-
- // Test that using the version of CreateFromStream that just takes a stream also decodes the
- // bitmap. Drawing this picture should look exactly like the original bitmap.
- SkMD5::Digest referenceDigest;
- md5(original, &referenceDigest);
-
- SkBitmap dst;
- dst.allocPixels(original.info());
- dst.eraseColor(SK_ColorRED);
- SkCanvas canvas(dst);
-
- pictureStream.rewind();
- pictureFromStream = SkPicture::MakeFromStream(&pictureStream);
- canvas.drawPicture(pictureFromStream.get());
-
- SkMD5::Digest digest2;
- md5(dst, &digest2);
- REPORTER_ASSERT(reporter, referenceDigest == digest2);
-}
-
static void test_clip_bound_opt(skiatest::Reporter* reporter) {
// Test for crbug.com/229011
SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4),