Index: dm/DM.cpp |
diff --git a/dm/DM.cpp b/dm/DM.cpp |
index 2ecba1da7a5d5b086e3a7bd821d9f31e8c146608..94fb0b77867803526a0a2f21516192be19f004f6 100644 |
--- a/dm/DM.cpp |
+++ b/dm/DM.cpp |
@@ -292,12 +292,125 @@ static void push_codec_srcs(Path path) { |
} |
} |
-static bool codec_supported(const char* ext) { |
- // FIXME: Once other versions of SkCodec are available, we can add them to this |
- // list (and eventually we can remove this check once they are all supported). |
+static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy, |
+ SkColorType colorType) { |
+ switch (strategy) { |
+ case SkBitmapRegionDecoder::kCanvas_Strategy: |
+ switch (colorType) { |
+ case kN32_SkColorType: |
+ case kRGB_565_SkColorType: |
+ return true; |
+ default: |
+ return false; |
+ } |
+ case SkBitmapRegionDecoder::kOriginal_Strategy: |
+ switch (colorType) { |
+ case kN32_SkColorType: |
+ case kRGB_565_SkColorType: |
+ case kIndex_8_SkColorType: |
+ case kAlpha_8_SkColorType: |
+ return true; |
+ default: |
+ return false; |
+ } |
+ default: |
+ SkASSERT(false); |
+ return false; |
+ } |
+} |
+ |
+static void push_brd_src(Path path, SkBitmapRegionDecoder::Strategy strategy, SkColorType colorType, |
+ BRDSrc::Mode mode, uint32_t sampleSize) { |
+ SkString folder; |
+ switch (strategy) { |
+ case SkBitmapRegionDecoder::kCanvas_Strategy: |
+ folder.append("brd_canvas"); |
+ break; |
+ case SkBitmapRegionDecoder::kOriginal_Strategy: |
+ folder.append("brd_sample"); |
+ break; |
+ default: |
+ SkASSERT(false); |
+ return; |
+ } |
+ |
+ switch (mode) { |
+ case BRDSrc::kFullImage_Mode: |
+ break; |
+ case BRDSrc::kDivisor_Mode: |
+ folder.append("_divisor"); |
+ break; |
+ default: |
+ SkASSERT(false); |
+ return; |
+ } |
+ |
+ switch (colorType) { |
+ case kN32_SkColorType: |
+ folder.append("_kN32"); |
+ break; |
+ case kRGB_565_SkColorType: |
+ folder.append("_k565"); |
+ break; |
+ case kIndex_8_SkColorType: |
+ folder.append("_kIndex"); |
+ break; |
+ case kAlpha_8_SkColorType: |
+ folder.append("_kAlpha"); |
+ break; |
+ default: |
+ SkASSERT(false); |
+ return; |
+ } |
+ |
+ if (1 != sampleSize) { |
+ folder.appendf("_%.3f", BRDSrc::GetScale(sampleSize)); |
+ } |
+ |
+ BRDSrc* src = new BRDSrc(path, strategy, mode, colorType, sampleSize); |
+ push_src("image", folder, src); |
+} |
+ |
+static void push_brd_srcs(Path path) { |
+ |
+ const SkBitmapRegionDecoder::Strategy strategies[] = { |
+ SkBitmapRegionDecoder::kCanvas_Strategy, |
+ SkBitmapRegionDecoder::kOriginal_Strategy |
+ }; |
+ |
+ // We will only test to one backend (8888), but we will test all of the |
+ // color types that we need to decode to on this backend. |
+ const SkColorType colorTypes[] = { |
+ kN32_SkColorType, |
+ kRGB_565_SkColorType, |
+ kAlpha_8_SkColorType, |
+ kIndex_8_SkColorType |
+ }; |
+ |
+ const BRDSrc::Mode modes[] = { |
+ BRDSrc::kFullImage_Mode, |
+ BRDSrc::kDivisor_Mode |
+ }; |
+ |
+ const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
+ |
+ for (SkBitmapRegionDecoder::Strategy strategy : strategies) { |
+ for (SkColorType colorType : colorTypes) { |
+ if (brd_color_type_supported(strategy, colorType)) { |
+ for (BRDSrc::Mode mode : modes) { |
+ for (uint32_t sampleSize : sampleSizes) { |
+ push_brd_src(path, strategy, colorType, mode, sampleSize); |
+ } |
+ } |
+ } |
+ } |
+ } |
+} |
+ |
+static bool brd_supported(const char* ext) { |
static const char* const exts[] = { |
- "bmp", "gif", "jpg", "jpeg", "png", "ico", "wbmp", "webp", |
- "BMP", "GIF", "JPG", "JPEG", "PNG", "ICO", "WBMP", "WEBP", |
+ "jpg", "jpeg", "png", "webp", |
+ "JPG", "JPEG", "PNG", "WEBP", |
}; |
for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { |
@@ -336,8 +449,9 @@ static void gather_srcs() { |
SkString path = SkOSPath::Join(flag, file.c_str()); |
push_src("image", "decode", new ImageSrc(path)); // Decode entire image |
push_src("image", "subset", new ImageSrc(path, 2)); // Decode into 2x2 subsets |
- if (codec_supported(exts[j])) { |
- push_codec_srcs(path); |
+ push_codec_srcs(path); |
+ if (brd_supported(exts[j])) { |
+ push_brd_srcs(path); |
} |
} |
} |
@@ -346,6 +460,7 @@ static void gather_srcs() { |
push_src("image", "decode", new ImageSrc(flag)); // Decode entire image. |
push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2 x 2 subsets |
push_codec_srcs(flag); |
+ push_brd_srcs(flag); |
} |
} |
} |