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 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 // Create a bitmap that will be encoded. | 880 // Create a bitmap that will be encoded. |
881 SkBitmap original; | 881 SkBitmap original; |
882 make_bm(&original, 100, 100, SK_ColorBLUE, true); | 882 make_bm(&original, 100, 100, SK_ColorBLUE, true); |
883 SkDynamicMemoryWStream wStream; | 883 SkDynamicMemoryWStream wStream; |
884 if (!SkImageEncoder::EncodeStream(&wStream, original, SkImageEncoder::kPNG_T
ype, 100)) { | 884 if (!SkImageEncoder::EncodeStream(&wStream, original, SkImageEncoder::kPNG_T
ype, 100)) { |
885 return; | 885 return; |
886 } | 886 } |
887 SkAutoDataUnref data(wStream.copyToData()); | 887 SkAutoDataUnref data(wStream.copyToData()); |
888 | 888 |
889 SkBitmap bm; | 889 SkBitmap bm; |
890 bool installSuccess = SkInstallDiscardablePixelRef(data, &bm); | 890 bool installSuccess = SkDEPRECATED_InstallDiscardablePixelRef(data, &bm); |
891 REPORTER_ASSERT(reporter, installSuccess); | 891 REPORTER_ASSERT(reporter, installSuccess); |
892 | 892 |
893 // Write both bitmaps to pictures, and ensure that the resulting data stream
s are the same. | 893 // Write both bitmaps to pictures, and ensure that the resulting data stream
s are the same. |
894 // Flattening original will follow the old path of performing an encode, whi
le flattening bm | 894 // Flattening original will follow the old path of performing an encode, whi
le flattening bm |
895 // will use the already encoded data. | 895 // will use the already encoded data. |
896 SkAutoDataUnref picture1(serialized_picture_from_bitmap(original)); | 896 SkAutoDataUnref picture1(serialized_picture_from_bitmap(original)); |
897 SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm)); | 897 SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm)); |
898 REPORTER_ASSERT(reporter, picture1->equals(picture2)); | 898 REPORTER_ASSERT(reporter, picture1->equals(picture2)); |
899 // Now test that a parse error was generated when trying to create a new SkP
icture without | 899 // Now test that a parse error was generated when trying to create a new SkP
icture without |
900 // providing a function to decode the bitmap. | 900 // providing a function to decode the bitmap. |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 | 1383 |
1384 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); | 1384 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); |
1385 SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstr
eam)); | 1385 SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstr
eam)); |
1386 | 1386 |
1387 REPORTER_ASSERT(r, SkToBool(deserializedPicture)); | 1387 REPORTER_ASSERT(r, SkToBool(deserializedPicture)); |
1388 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1); | 1388 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1); |
1389 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2); | 1389 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2); |
1390 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3); | 1390 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3); |
1391 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4); | 1391 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4); |
1392 } | 1392 } |
OLD | NEW |