| 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 "SkCodec.h" | 10 #include "SkCodec.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 case CodecSrc::kGrayscale_Always_DstColorType: | 107 case CodecSrc::kGrayscale_Always_DstColorType: |
| 108 colorType = kGray_8_SkColorType; | 108 colorType = kGray_8_SkColorType; |
| 109 break; | 109 break; |
| 110 } | 110 } |
| 111 | 111 |
| 112 SkAutoTDelete<SkBitmapRegionDecoderInterface> brd(create_brd(fPath, fStrateg
y)); | 112 SkAutoTDelete<SkBitmapRegionDecoderInterface> brd(create_brd(fPath, fStrateg
y)); |
| 113 if (nullptr == brd.get()) { | 113 if (nullptr == brd.get()) { |
| 114 return Error::Nonfatal(SkStringPrintf("Could not create brd for %s.", fP
ath.c_str())); | 114 return Error::Nonfatal(SkStringPrintf("Could not create brd for %s.", fP
ath.c_str())); |
| 115 } | 115 } |
| 116 | 116 |
| 117 if (!brd->conversionSupported(colorType)) { |
| 118 return Error::Nonfatal("Cannot convert to color type.\n"); |
| 119 } |
| 120 |
| 117 const uint32_t width = brd->width(); | 121 const uint32_t width = brd->width(); |
| 118 const uint32_t height = brd->height(); | 122 const uint32_t height = brd->height(); |
| 119 // Visually inspecting very small output images is not necessary. | 123 // Visually inspecting very small output images is not necessary. |
| 120 if ((width / fSampleSize <= 10 || height / fSampleSize <= 10) && 1 != fSampl
eSize) { | 124 if ((width / fSampleSize <= 10 || height / fSampleSize <= 10) && 1 != fSampl
eSize) { |
| 121 return Error::Nonfatal("Scaling very small images is uninteresting."); | 125 return Error::Nonfatal("Scaling very small images is uninteresting."); |
| 122 } | 126 } |
| 123 switch (fMode) { | 127 switch (fMode) { |
| 124 case kFullImage_Mode: { | 128 case kFullImage_Mode: { |
| 125 SkAutoTDelete<SkBitmap> bitmap(brd->decodeRegion(0, 0, width, height
, fSampleSize, | 129 SkAutoTDelete<SkBitmap> bitmap(brd->decodeRegion(0, 0, width, height
, fSampleSize, |
| 126 colorType)); | 130 colorType)); |
| (...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 skr.visit<void>(i, drawsAsSingletonPictures); | 1208 skr.visit<void>(i, drawsAsSingletonPictures); |
| 1205 } | 1209 } |
| 1206 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); | 1210 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); |
| 1207 | 1211 |
| 1208 canvas->drawPicture(macroPic); | 1212 canvas->drawPicture(macroPic); |
| 1209 return ""; | 1213 return ""; |
| 1210 }); | 1214 }); |
| 1211 } | 1215 } |
| 1212 | 1216 |
| 1213 } // namespace DM | 1217 } // namespace DM |
| OLD | NEW |