diff options
author | 2014-06-12 17:40:00 -0700 | |
---|---|---|
committer | 2014-06-12 17:40:00 -0700 | |
commit | bfefc7c95fc0e8ebd5000c68f6d16e1a3ea0e71e (patch) | |
tree | 9e68e04fa38c4e28ac478786bfe6d402a3bff239 /tools | |
parent | 9a8699f45c2bd8dac0c06829a06b6b244d19b6b2 (diff) |
hide Config in SkImageDecoder -- use SkColorType instead
patch from issue 334613003
TBR=scroggo
Author: reed@chromium.org
Review URL: https://codereview.chromium.org/334793002
Diffstat (limited to 'tools')
-rw-r--r-- | tools/render_pictures_main.cpp | 2 | ||||
-rw-r--r-- | tools/skdiff_utils.cpp | 2 | ||||
-rw-r--r-- | tools/skimage_main.cpp | 23 |
3 files changed, 13 insertions, 14 deletions
diff --git a/tools/render_pictures_main.cpp b/tools/render_pictures_main.cpp index ec21cb7da3..850053cfc6 100644 --- a/tools/render_pictures_main.cpp +++ b/tools/render_pictures_main.cpp @@ -130,7 +130,7 @@ static bool write_image_to_file(const void* buffer, size_t size, SkBitmap* bitma SkDebugf("Failed to write encoded data to \"%s\"\n", outPath.c_str()); } // Put in a dummy bitmap. - return SkImageDecoder::DecodeStream(&memStream, bitmap, SkBitmap::kNo_Config, + return SkImageDecoder::DecodeStream(&memStream, bitmap, kUnknown_SkColorType, SkImageDecoder::kDecodeBounds_Mode); } diff --git a/tools/skdiff_utils.cpp b/tools/skdiff_utils.cpp index 5c9aae275a..9157ac6b91 100644 --- a/tools/skdiff_utils.cpp +++ b/tools/skdiff_utils.cpp @@ -63,7 +63,7 @@ bool get_bitmap(SkData* fileBits, DiffResource& resource, SkImageDecoder::Mode m SkAutoTDelete<SkImageDecoder> ad(codec); stream.rewind(); - if (!codec->decode(&stream, &resource.fBitmap, SkBitmap::kARGB_8888_Config, mode)) { + if (!codec->decode(&stream, &resource.fBitmap, kN32_SkColorType, mode)) { SkDebugf("ERROR: codec failed for basePath <%s>\n", resource.fFullPath.c_str()); resource.fStatus = DiffResource::kCouldNotDecode_Status; return false; diff --git a/tools/skimage_main.cpp b/tools/skimage_main.cpp index 3740f0fa07..a488aa7e2f 100644 --- a/tools/skimage_main.cpp +++ b/tools/skimage_main.cpp @@ -117,7 +117,7 @@ static SkTArray<SkString, false> gMissingSubsetExpectations; static SkTArray<SkString, false> gKnownFailures; static SkTArray<SkString, false> gKnownSubsetFailures; -static SkBitmap::Config gPrefConfig(SkBitmap::kNo_Config); +static SkColorType gPrefColorType(kUnknown_SkColorType); // Expections read from a file specified by readExpectationsPath. The expectations must have been // previously written using createExpectationsPath. @@ -445,7 +445,7 @@ static void test_stream_without_length(const char srcPath[], SkImageDecoder* cod // path should never fail. SkASSERT(stream.isValid()); SkBitmap bm; - if (!codec->decode(&stream, &bm, gPrefConfig, SkImageDecoder::kDecodePixels_Mode)) { + if (!codec->decode(&stream, &bm, gPrefColorType, SkImageDecoder::kDecodePixels_Mode)) { gDecodeFailures.push_back().appendf("Without using getLength, %s failed to decode\n", srcPath); return; @@ -510,8 +510,7 @@ static void decodeFileAndWrite(const char srcPath[], const SkString* writePath) replace_char(&basename, '.', '-'); const char* filename = basename.c_str(); - if (!codec->decode(&stream, &bitmap, gPrefConfig, - SkImageDecoder::kDecodePixels_Mode)) { + if (!codec->decode(&stream, &bitmap, gPrefColorType, SkImageDecoder::kDecodePixels_Mode)) { if (NULL != gJsonExpectations.get()) { const SkString name_config = create_json_key(filename); skiagm::Expectations jsExpectations = gJsonExpectations->get(name_config.c_str()); @@ -597,7 +596,7 @@ static void decodeFileAndWrite(const char srcPath[], const SkString* writePath) 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, gPrefConfig)) { + if (codec->decodeSubset(&bitmapFromDecodeSubset, rect, gPrefColorType)) { SkString subsetName = SkStringPrintf("%s-%s", filename, subsetDim.c_str()); skiagm::BitmapAndDigest subsetBitmapAndDigest(bitmapFromDecodeSubset); if (compare_to_expectations_if_necessary(subsetBitmapAndDigest.fDigest, @@ -627,7 +626,7 @@ static void decodeFileAndWrite(const char srcPath[], const SkString* writePath) } // Do not attempt to re-encode A8, since our image encoders do not support encoding to A8. - if (FLAGS_reencode && bitmap.config() != SkBitmap::kA8_Config) { + if (FLAGS_reencode && bitmap.colorType() != kAlpha_8_SkColorType) { // Encode to the format the file was originally in, or PNG if the encoder for the same // format is unavailable. SkImageDecoder::Format format = codec->getFormat(); @@ -684,9 +683,9 @@ static void decodeFileAndWrite(const char srcPath[], const SkString* writePath) SkMemoryStream memStream(data); SkBitmap redecodedBitmap; SkImageDecoder::Format formatOnSecondDecode; - if (SkImageDecoder::DecodeStream(&memStream, &redecodedBitmap, gPrefConfig, - SkImageDecoder::kDecodePixels_Mode, - &formatOnSecondDecode)) { + if (SkImageDecoder::DecodeStream(&memStream, &redecodedBitmap, gPrefColorType, + SkImageDecoder::kDecodePixels_Mode, + &formatOnSecondDecode)) { SkASSERT(format_to_type(formatOnSecondDecode) == type); } else { gDecodeFailures.push_back().printf("Failed to redecode %s after reencoding to '%s'", @@ -772,11 +771,11 @@ int tool_main(int argc, char** argv) { // 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; + gPrefColorType = kN32_SkColorType; } else if (0 == strcmp(config, "565")) { - gPrefConfig = SkBitmap::kRGB_565_Config; + gPrefColorType = kRGB_565_SkColorType; } else if (0 == strcmp(config, "A8")) { - gPrefConfig = SkBitmap::kA8_Config; + gPrefColorType = kAlpha_8_SkColorType; } else if (0 != strcmp(config, "None")) { SkDebugf("Invalid preferred config\n"); return -1; |