| 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
| 10 #include "SkData.h" | 10 #include "SkData.h" |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 fData->ref(); | 352 fData->ref(); |
| 353 return fData; | 353 return fData; |
| 354 } | 354 } |
| 355 | 355 |
| 356 private: | 356 private: |
| 357 SkData* fData; | 357 SkData* fData; |
| 358 }; | 358 }; |
| 359 | 359 |
| 360 #include "SkImageEncoder.h" | 360 #include "SkImageEncoder.h" |
| 361 | 361 |
| 362 static bool PNGEncodeBitmapToStream(SkWStream* wStream, const SkBitmap& bm) { | 362 static SkData* encode_bitmap_to_data(size_t* offset, const SkBitmap& bm) { |
| 363 return SkImageEncoder::EncodeStream(wStream, bm, SkImageEncoder::kPNG_Type,
100); | 363 *offset = 0; |
| 364 return SkImageEncoder::EncodeData(bm, SkImageEncoder::kPNG_Type, 100); |
| 364 } | 365 } |
| 365 | 366 |
| 366 static SkData* serialized_picture_from_bitmap(const SkBitmap& bitmap) { | 367 static SkData* serialized_picture_from_bitmap(const SkBitmap& bitmap) { |
| 367 SkPicture picture; | 368 SkPicture picture; |
| 368 SkCanvas* canvas = picture.beginRecording(bitmap.width(), bitmap.height()); | 369 SkCanvas* canvas = picture.beginRecording(bitmap.width(), bitmap.height()); |
| 369 canvas->drawBitmap(bitmap, 0, 0); | 370 canvas->drawBitmap(bitmap, 0, 0); |
| 370 SkDynamicMemoryWStream wStream; | 371 SkDynamicMemoryWStream wStream; |
| 371 picture.serialize(&wStream, &PNGEncodeBitmapToStream); | 372 picture.serialize(&wStream, &encode_bitmap_to_data); |
| 372 return wStream.copyToData(); | 373 return wStream.copyToData(); |
| 373 } | 374 } |
| 374 | 375 |
| 375 struct ErrorContext { | 376 struct ErrorContext { |
| 376 int fErrors; | 377 int fErrors; |
| 377 skiatest::Reporter* fReporter; | 378 skiatest::Reporter* fReporter; |
| 378 }; | 379 }; |
| 379 | 380 |
| 380 static void assert_one_parse_error_cb(SkError error, void* context) { | 381 static void assert_one_parse_error_cb(SkError error, void* context) { |
| 381 ErrorContext* errorContext = static_cast<ErrorContext*>(context); | 382 ErrorContext* errorContext = static_cast<ErrorContext*>(context); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 #endif | 558 #endif |
| 558 test_peephole(); | 559 test_peephole(); |
| 559 test_gatherpixelrefs(reporter); | 560 test_gatherpixelrefs(reporter); |
| 560 test_bitmap_with_encoded_data(reporter); | 561 test_bitmap_with_encoded_data(reporter); |
| 561 test_clone_empty(reporter); | 562 test_clone_empty(reporter); |
| 562 test_clip_bound_opt(reporter); | 563 test_clip_bound_opt(reporter); |
| 563 } | 564 } |
| 564 | 565 |
| 565 #include "TestClassDef.h" | 566 #include "TestClassDef.h" |
| 566 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) | 567 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) |
| OLD | NEW |