__SK_FORCE_IMAGE_DECODER_LINKING;
+DEFINE_string(config, "None", "Preferred config to decode into. [None|8888|565|A8]");
DEFINE_string(createExpectationsPath, "", "Path to write JSON expectations.");
DEFINE_string(mismatchPath, "", "Folder to write mismatched images to.");
DEFINE_string2(readPath, r, "", "Folder(s) and files to decode images. Required.");
static SkTArray<SkString, false> gMissingExpectations;
static SkTArray<SkString, false> gMissingSubsetExpectations;
+static SkBitmap::Config gPrefConfig(SkBitmap::kNo_Config);
+
// Expections read from a file specified by readExpectationsPath. The expectations must have been
// previously written using createExpectationsPath.
SkAutoTUnref<skiagm::JsonExpectationsSource> gJsonExpectations;
SkString basename = SkOSPath::SkBasename(srcPath);
const char* filename = basename.c_str();
- if (!codec->decode(&stream, &bitmap, SkBitmap::kARGB_8888_Config,
+ if (!codec->decode(&stream, &bitmap, gPrefConfig,
SkImageDecoder::kDecodePixels_Mode)) {
if (expect_to_fail(filename)) {
gSuccessfulDecodes.push_back().appendf(
SkIRect rect = generate_random_rect(&rand, width, height);
SkString subsetDim = SkStringPrintf("[%d,%d,%d,%d]", rect.fLeft, rect.fTop,
rect.fRight, rect.fBottom);
- if (codec->decodeSubset(&bitmapFromDecodeSubset, rect, SkBitmap::kNo_Config)) {
+ if (codec->decodeSubset(&bitmapFromDecodeSubset, rect, gPrefConfig)) {
SkString subsetName = SkStringPrintf("%s_%s", filename, subsetDim.c_str());
if (compare_to_expectations_if_necessary(bitmapFromDecodeSubset,
subsetName.c_str(),
SkMemoryStream memStream(data);
SkBitmap redecodedBitmap;
SkImageDecoder::Format formatOnSecondDecode;
- if (SkImageDecoder::DecodeStream(&memStream, &redecodedBitmap, SkBitmap::kNo_Config,
+ if (SkImageDecoder::DecodeStream(&memStream, &redecodedBitmap, gPrefConfig,
SkImageDecoder::kDecodePixels_Mode,
&formatOnSecondDecode)) {
SkASSERT(format_to_type(formatOnSecondDecode) == type);
outDirPtr = NULL;
}
+ if (FLAGS_config.count() == 1) {
+ // Only consider the first config specified on the command line.
+ const char* config = FLAGS_config[0];
+ if (0 == strcmp(config, "8888")) {
+ gPrefConfig = SkBitmap::kARGB_8888_Config;
+ } else if (0 == strcmp(config, "565")) {
+ gPrefConfig = SkBitmap::kRGB_565_Config;
+ } else if (0 == strcmp(config, "A8")) {
+ gPrefConfig = SkBitmap::kA8_Config;
+ } else if (0 != strcmp(config, "None")) {
+ SkDebugf("Invalid preferred config\n");
+ return -1;
+ }
+ }
+
for (int i = 0; i < FLAGS_readPath.count(); i++) {
const char* readPath = FLAGS_readPath[i];
if (strlen(readPath) < 1) {