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 "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 SkBitmap original; | 1106 SkBitmap original; |
1107 make_bm(&original, 100, 100, SK_ColorBLUE, true); | 1107 make_bm(&original, 100, 100, SK_ColorBLUE, true); |
1108 SkDynamicMemoryWStream wStream; | 1108 SkDynamicMemoryWStream wStream; |
1109 if (!SkImageEncoder::EncodeStream(&wStream, original, SkImageEncoder::kPNG_T
ype, 100)) { | 1109 if (!SkImageEncoder::EncodeStream(&wStream, original, SkImageEncoder::kPNG_T
ype, 100)) { |
1110 return; | 1110 return; |
1111 } | 1111 } |
1112 SkAutoDataUnref data(wStream.copyToData()); | 1112 SkAutoDataUnref data(wStream.copyToData()); |
1113 | 1113 |
1114 SkBitmap bm; | 1114 SkBitmap bm; |
1115 bool installSuccess = SkInstallDiscardablePixelRef( | 1115 bool installSuccess = SkInstallDiscardablePixelRef( |
1116 SkDecodingImageGenerator::Create(data, SkDecodingImageGenerator::Option
s()), &bm, NULL); | 1116 SkDecodingImageGenerator::Create(data, SkDecodingImageGenerator::Option
s()), &bm); |
1117 REPORTER_ASSERT(reporter, installSuccess); | 1117 REPORTER_ASSERT(reporter, installSuccess); |
1118 | 1118 |
1119 // Write both bitmaps to pictures, and ensure that the resulting data stream
s are the same. | 1119 // Write both bitmaps to pictures, and ensure that the resulting data stream
s are the same. |
1120 // Flattening original will follow the old path of performing an encode, whi
le flattening bm | 1120 // Flattening original will follow the old path of performing an encode, whi
le flattening bm |
1121 // will use the already encoded data. | 1121 // will use the already encoded data. |
1122 SkAutoDataUnref picture1(serialized_picture_from_bitmap(original)); | 1122 SkAutoDataUnref picture1(serialized_picture_from_bitmap(original)); |
1123 SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm)); | 1123 SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm)); |
1124 REPORTER_ASSERT(reporter, picture1->equals(picture2)); | 1124 REPORTER_ASSERT(reporter, picture1->equals(picture2)); |
1125 // Now test that a parse error was generated when trying to create a new SkP
icture without | 1125 // Now test that a parse error was generated when trying to create a new SkP
icture without |
1126 // providing a function to decode the bitmap. | 1126 // providing a function to decode the bitmap. |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1500 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 1500 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
1501 } | 1501 } |
1502 | 1502 |
1503 DEF_TEST(Canvas_EmptyBitmap, r) { | 1503 DEF_TEST(Canvas_EmptyBitmap, r) { |
1504 SkBitmap dst; | 1504 SkBitmap dst; |
1505 dst.allocN32Pixels(10, 10); | 1505 dst.allocN32Pixels(10, 10); |
1506 SkCanvas canvas(dst); | 1506 SkCanvas canvas(dst); |
1507 | 1507 |
1508 test_draw_bitmaps(&canvas); | 1508 test_draw_bitmaps(&canvas); |
1509 } | 1509 } |
OLD | NEW |