aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-03-09 06:16:55 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-09 06:16:55 -0800
commit790f99ae729803ddf827251bbbb9bb21fc165e35 (patch)
treee4e451b3406ddd64b3aac1e0e862c82ae0ffb095 /tools
parent18bbd00190623fb6cdb119df4a118ac3c1aed52a (diff)
Remove usage of SkImageDecoder in debugger
Diffstat (limited to 'tools')
-rw-r--r--tools/debugger/SkDrawCommand.cpp21
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;