Chromium Code Reviews| 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 "SamplePipeControllers.h" | 9 #include "SamplePipeControllers.h" |
| 10 #include "SkCommonFlags.h" | 10 #include "SkCommonFlags.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | 73 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
| 74 if (NULL == codec.get()) { | 74 if (NULL == codec.get()) { |
| 75 return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str()); | 75 return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Choose the color type to decode to | 78 // Choose the color type to decode to |
| 79 SkImageInfo decodeInfo = codec->getInfo(); | 79 SkImageInfo decodeInfo = codec->getInfo(); |
| 80 SkColorType canvasColorType = canvasInfo.colorType(); | 80 SkColorType canvasColorType = canvasInfo.colorType(); |
| 81 switch (fDstColorType) { | 81 switch (fDstColorType) { |
| 82 case kIndex8_Always_DstColorType: | 82 case kIndex8_Always_DstColorType: |
| 83 case kGrayscale_Always_DstColorType: | 83 if (kIndex_8_SkColorType != decodeInfo.colorType()) { |
|
scroggo
2015/04/10 17:19:05
I'd prefer just setting decodeInfo to use kIndex8,
msarett
2015/04/13 20:54:04
Completely agree. See my comment in DM.cpp.
| |
| 84 return Error::Nonfatal("Cannot decode to kIndex8."); | |
| 85 } | |
| 84 if (kRGB_565_SkColorType == canvasColorType) { | 86 if (kRGB_565_SkColorType == canvasColorType) { |
| 85 return Error::Nonfatal("Testing non-565 to 565 is uninteresting. "); | 87 return Error::Nonfatal("Testing non-565 to 565 is uninteresting. "); |
| 86 } | 88 } |
| 89 break; | |
| 90 case kGrayscale_Always_DstColorType: | |
| 91 if (kGray_8_SkColorType != decodeInfo.colorType()) { | |
| 92 return Error::Nonfatal("Cannot decode to kGray8."); | |
| 93 } | |
| 94 if (kRGB_565_SkColorType == canvasColorType) { | |
| 95 return Error::Nonfatal("Testing non-565 to 565 is uninteresting. "); | |
| 96 } | |
| 87 break; | 97 break; |
| 88 default: | 98 default: |
| 89 decodeInfo = decodeInfo.makeColorType(canvasColorType); | 99 decodeInfo = decodeInfo.makeColorType(canvasColorType); |
| 90 break; | 100 break; |
| 91 } | 101 } |
| 92 | 102 |
| 93 // Construct a color table for the decode if necessary | 103 // Construct a color table for the decode if necessary |
| 94 SkAutoTUnref<SkColorTable> colorTable(NULL); | 104 SkAutoTUnref<SkColorTable> colorTable(NULL); |
| 95 SkPMColor* colorPtr = NULL; | 105 SkPMColor* colorPtr = NULL; |
| 96 int* colorCountPtr = NULL; | 106 int* colorCountPtr = NULL; |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 695 canvas->drawPicture(pic); | 705 canvas->drawPicture(pic); |
| 696 return ""; | 706 return ""; |
| 697 } | 707 } |
| 698 SkISize size() const override { return fSrc.size(); } | 708 SkISize size() const override { return fSrc.size(); } |
| 699 Name name() const override { sk_throw(); return ""; } // No one should be calling this. | 709 Name name() const override { sk_throw(); return ""; } // No one should be calling this. |
| 700 } proxy(src); | 710 } proxy(src); |
| 701 return fSink->draw(proxy, bitmap, stream, log); | 711 return fSink->draw(proxy, bitmap, stream, log); |
| 702 } | 712 } |
| 703 | 713 |
| 704 } // namespace DM | 714 } // namespace DM |
| OLD | NEW |