OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "DMSrcSink.h" | 8 #include "DMSrcSink.h" |
9 #include "SkAndroidCodec.h" | 9 #include "SkAndroidCodec.h" |
10 #include "SkCodec.h" | 10 #include "SkCodec.h" |
11 #include "SkCodecImageGenerator.h" | 11 #include "SkCodecImageGenerator.h" |
12 #include "SkCommonFlags.h" | 12 #include "SkCommonFlags.h" |
13 #include "SkData.h" | 13 #include "SkData.h" |
14 #include "SkDocument.h" | 14 #include "SkDocument.h" |
15 #include "SkError.h" | 15 #include "SkError.h" |
16 #include "SkImageGenerator.h" | 16 #include "SkImageGenerator.h" |
17 #include "SkImageGeneratorCG.h" | 17 #include "SkImageGeneratorCG.h" |
| 18 #include "SkImageGeneratorWIC.h" |
18 #include "SkMallocPixelRef.h" | 19 #include "SkMallocPixelRef.h" |
19 #include "SkMultiPictureDraw.h" | 20 #include "SkMultiPictureDraw.h" |
20 #include "SkNullCanvas.h" | 21 #include "SkNullCanvas.h" |
21 #include "SkOSFile.h" | 22 #include "SkOSFile.h" |
22 #include "SkOpts.h" | 23 #include "SkOpts.h" |
23 #include "SkPictureData.h" | 24 #include "SkPictureData.h" |
24 #include "SkPictureRecorder.h" | 25 #include "SkPictureRecorder.h" |
25 #include "SkRandom.h" | 26 #include "SkRandom.h" |
26 #include "SkRecordDraw.h" | 27 #include "SkRecordDraw.h" |
27 #include "SkRecorder.h" | 28 #include "SkRecorder.h" |
28 #include "SkSVGCanvas.h" | 29 #include "SkSVGCanvas.h" |
29 #include "SkStream.h" | 30 #include "SkStream.h" |
30 #include "SkTLogic.h" | 31 #include "SkTLogic.h" |
31 #include "SkXMLWriter.h" | 32 #include "SkXMLWriter.h" |
32 #include "SkSwizzler.h" | 33 #include "SkSwizzler.h" |
33 #include <functional> | 34 #include <functional> |
34 | 35 |
| 36 #if defined(SK_BUILD_FOR_WIN) |
| 37 #include "SkAutoCoInitialize.h" |
| 38 #endif |
| 39 |
35 #ifdef SK_MOJO | 40 #ifdef SK_MOJO |
36 #include "SkMojo.mojom.h" | 41 #include "SkMojo.mojom.h" |
37 #endif | 42 #endif |
38 | 43 |
39 DEFINE_bool(multiPage, false, "For document-type backends, render the source" | 44 DEFINE_bool(multiPage, false, "For document-type backends, render the source" |
40 " into multiple pages"); | 45 " into multiple pages"); |
41 DEFINE_bool(RAW_threading, true, "Allow RAW decodes to run on multiple threads?"
); | 46 DEFINE_bool(RAW_threading, true, "Allow RAW decodes to run on multiple threads?"
); |
42 | 47 |
43 namespace DM { | 48 namespace DM { |
44 | 49 |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 Error ImageGenSrc::draw(SkCanvas* canvas) const { | 789 Error ImageGenSrc::draw(SkCanvas* canvas) const { |
785 if (kRGB_565_SkColorType == canvas->imageInfo().colorType()) { | 790 if (kRGB_565_SkColorType == canvas->imageInfo().colorType()) { |
786 return Error::Nonfatal("Uninteresting to test image generator to 565."); | 791 return Error::Nonfatal("Uninteresting to test image generator to 565."); |
787 } | 792 } |
788 | 793 |
789 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); | 794 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); |
790 if (!encoded) { | 795 if (!encoded) { |
791 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); | 796 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); |
792 } | 797 } |
793 | 798 |
| 799 #if defined(SK_BUILD_FOR_WIN) |
| 800 // Initialize COM in order to test with WIC. |
| 801 SkAutoCoInitialize com; |
| 802 if (!com.succeeded()) { |
| 803 return "Could not initialize COM."; |
| 804 } |
| 805 #endif |
| 806 |
794 SkAutoTDelete<SkImageGenerator> gen(nullptr); | 807 SkAutoTDelete<SkImageGenerator> gen(nullptr); |
795 switch (fMode) { | 808 switch (fMode) { |
796 case kCodec_Mode: | 809 case kCodec_Mode: |
797 gen.reset(SkCodecImageGenerator::NewFromEncodedCodec(encoded)); | 810 gen.reset(SkCodecImageGenerator::NewFromEncodedCodec(encoded)); |
798 if (!gen) { | 811 if (!gen) { |
799 return "Could not create codec image generator."; | 812 return "Could not create codec image generator."; |
800 } | 813 } |
801 break; | 814 break; |
| 815 case kPlatform_Mode: { |
802 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) | 816 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) |
803 case kPlatform_Mode: | |
804 gen.reset(SkImageGeneratorCG::NewFromEncodedCG(encoded)); | 817 gen.reset(SkImageGeneratorCG::NewFromEncodedCG(encoded)); |
| 818 #elif defined(SK_BUILD_FOR_WIN) |
| 819 gen.reset(SkImageGeneratorWIC::NewFromEncodedWIC(encoded)); |
| 820 #endif |
| 821 |
805 if (!gen) { | 822 if (!gen) { |
806 return "Could not create CG image generator."; | 823 return "Could not create platform image generator."; |
807 } | 824 } |
808 break; | 825 break; |
809 #endif | 826 } |
810 default: | 827 default: |
811 SkASSERT(false); | 828 SkASSERT(false); |
812 return "Invalid image generator mode"; | 829 return "Invalid image generator mode"; |
813 } | 830 } |
814 | 831 |
815 // Test deferred decoding path on GPU | 832 // Test deferred decoding path on GPU |
816 if (fIsGpu) { | 833 if (fIsGpu) { |
817 // FIXME: The gpu backend does not draw kGray sources correctly. (skbug.
com/4822) | 834 // FIXME: The gpu backend does not draw kGray sources correctly. (skbug.
com/4822) |
818 // We have disabled these tests in DM.cpp. | 835 // We have disabled these tests in DM.cpp. |
819 SkASSERT(kGray_8_SkColorType != gen->getInfo().colorType()); | 836 SkASSERT(kGray_8_SkColorType != gen->getInfo().colorType()); |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 skr.visit<void>(i, drawsAsSingletonPictures); | 1512 skr.visit<void>(i, drawsAsSingletonPictures); |
1496 } | 1513 } |
1497 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); | 1514 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); |
1498 | 1515 |
1499 canvas->drawPicture(macroPic); | 1516 canvas->drawPicture(macroPic); |
1500 return check_against_reference(bitmap, src, fSink); | 1517 return check_against_reference(bitmap, src, fSink); |
1501 }); | 1518 }); |
1502 } | 1519 } |
1503 | 1520 |
1504 } // namespace DM | 1521 } // namespace DM |
OLD | NEW |