Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Unified Diff: tools/debugger/SkDrawCommand.cpp

Issue 1774313003: Remove usage of SkImageDecoder in debugger (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/debugger/SkDrawCommand.cpp
diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp
index 1790536b5c34b8a4493a0dd60bd5720423b2a19e..df338247d5fad07c28e1b83c6d06960515078103 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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698