diff options
author | msarett <msarett@google.com> | 2016-03-09 06:16:55 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-09 06:16:55 -0800 |
commit | 790f99ae729803ddf827251bbbb9bb21fc165e35 (patch) | |
tree | e4e451b3406ddd64b3aac1e0e862c82ae0ffb095 /tools | |
parent | 18bbd00190623fb6cdb119df4a118ac3c1aed52a (diff) |
Remove usage of SkImageDecoder in debugger
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1774313003
Review URL: https://codereview.chromium.org/1774313003
Diffstat (limited to 'tools')
-rw-r--r-- | tools/debugger/SkDrawCommand.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp index 1790536b5c..df338247d5 100644 --- a/tools/debugger/SkDrawCommand.cpp +++ b/tools/debugger/SkDrawCommand.cpp @@ -754,21 +754,24 @@ static SkBitmap* load_bitmap(const Json::Value& jsonBitmap, UrlDataManager& urlD } const void* data; int size = decode_data(jsonBitmap[SKDEBUGCANVAS_ATTRIBUTE_DATA], urlDataManager, &data); - SkMemoryStream stream(data, size); - SkImageDecoder* decoder = SkImageDecoder::Factory(&stream); - SkBitmap* bitmap = new SkBitmap(); - SkImageDecoder::Result result = decoder->decode(&stream, bitmap, - SkImageDecoder::kDecodePixels_Mode); - sk_free(decoder); - if (result != SkImageDecoder::kFailure) { + SkAutoTUnref<SkData> encoded(SkData::NewWithoutCopy(data, size)); + SkAutoTDelete<SkImage> image(SkImage::NewFromEncoded(encoded, nullptr)); + + SkAutoTDelete<SkBitmap> bitmap(new SkBitmap()); + if (nullptr != image) { + if (!image->asLegacyBitmap(bitmap, SkImage::kRW_LegacyBitmapMode)) { + SkDebugf("image decode failed\n"); + return nullptr; + } + if (jsonBitmap.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLOR)) { const char* ctName = jsonBitmap[SKDEBUGCANVAS_ATTRIBUTE_COLOR].asCString(); SkColorType ct = colortype_from_name(ctName); if (ct != kIndex_8_SkColorType) { - bitmap = convert_colortype(bitmap, ct); + bitmap.reset(convert_colortype(bitmap.detach(), ct)); } } - return bitmap; + return bitmap.detach(); } SkDebugf("image decode failed\n"); return nullptr; |