| 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 #include "Test.h" | 7 #include "Test.h" |
| 8 #include "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 // Create a bitmap that will be encoded. | 372 // Create a bitmap that will be encoded. |
| 373 SkBitmap original; | 373 SkBitmap original; |
| 374 make_bm(&original, 100, 100, SK_ColorBLUE, true); | 374 make_bm(&original, 100, 100, SK_ColorBLUE, true); |
| 375 SkDynamicMemoryWStream wStream; | 375 SkDynamicMemoryWStream wStream; |
| 376 if (!SkImageEncoder::EncodeStream(&wStream, original, SkImageEncoder::kPNG_T
ype, 100)) { | 376 if (!SkImageEncoder::EncodeStream(&wStream, original, SkImageEncoder::kPNG_T
ype, 100)) { |
| 377 return; | 377 return; |
| 378 } | 378 } |
| 379 SkAutoDataUnref data(wStream.copyToData()); | 379 SkAutoDataUnref data(wStream.copyToData()); |
| 380 | 380 |
| 381 SkBitmap bm; | 381 SkBitmap bm; |
| 382 bool installSuccess = SkDecodingImageGenerator::Install(data, &bm); | 382 bool installSuccess = SkDecodingImageGenerator::Install(data, &bm, NULL); |
| 383 REPORTER_ASSERT(reporter, installSuccess); | 383 REPORTER_ASSERT(reporter, installSuccess); |
| 384 | 384 |
| 385 // Write both bitmaps to pictures, and ensure that the resulting data stream
s are the same. | 385 // Write both bitmaps to pictures, and ensure that the resulting data stream
s are the same. |
| 386 // Flattening original will follow the old path of performing an encode, whi
le flattening bm | 386 // Flattening original will follow the old path of performing an encode, whi
le flattening bm |
| 387 // will use the already encoded data. | 387 // will use the already encoded data. |
| 388 SkAutoDataUnref picture1(serialized_picture_from_bitmap(original)); | 388 SkAutoDataUnref picture1(serialized_picture_from_bitmap(original)); |
| 389 SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm)); | 389 SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm)); |
| 390 REPORTER_ASSERT(reporter, picture1->equals(picture2)); | 390 REPORTER_ASSERT(reporter, picture1->equals(picture2)); |
| 391 // Now test that a parse error was generated when trying to create a new SkP
icture without | 391 // Now test that a parse error was generated when trying to create a new SkP
icture without |
| 392 // providing a function to decode the bitmap. | 392 // providing a function to decode the bitmap. |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 test_gatherpixelrefs(reporter); | 633 test_gatherpixelrefs(reporter); |
| 634 test_bitmap_with_encoded_data(reporter); | 634 test_bitmap_with_encoded_data(reporter); |
| 635 test_clone_empty(reporter); | 635 test_clone_empty(reporter); |
| 636 test_clip_bound_opt(reporter); | 636 test_clip_bound_opt(reporter); |
| 637 test_clip_expansion(reporter); | 637 test_clip_expansion(reporter); |
| 638 test_hierarchical(reporter); | 638 test_hierarchical(reporter); |
| 639 } | 639 } |
| 640 | 640 |
| 641 #include "TestClassDef.h" | 641 #include "TestClassDef.h" |
| 642 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) | 642 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) |
| OLD | NEW |