From 164d302ebf182a2db0044ba46126f9ed1e6cf138 Mon Sep 17 00:00:00 2001 From: msarett Date: Tue, 10 Nov 2015 15:09:03 -0800 Subject: [PATCH] Delete dead subset test code from dm This approach to subset decoding is no longer supported. We have replaced it with an implementation that does not depend on forked libraries. https://codereview.chromium.org/1406153015/ BUG=skia: Review URL: https://codereview.chromium.org/1416673010 --- dm/DM.cpp | 15 -------------- dm/DMSrcSink.cpp | 63 ++++++++++---------------------------------------------- dm/DMSrcSink.h | 5 +---- 3 files changed, 12 insertions(+), 71 deletions(-) diff --git a/dm/DM.cpp b/dm/DM.cpp index 34513dd..444584d 100644 --- a/dm/DM.cpp +++ b/dm/DM.cpp @@ -385,15 +385,6 @@ static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy, return true; } return false; - case SkBitmapRegionDecoder::kOriginal_Strategy: - switch (dstColorType) { - case CodecSrc::kGetFromCanvas_DstColorType: - case CodecSrc::kIndex8_Always_DstColorType: - case CodecSrc::kGrayscale_Always_DstColorType: - return true; - default: - return false; - } case SkBitmapRegionDecoder::kAndroidCodec_Strategy: switch (dstColorType) { case CodecSrc::kGetFromCanvas_DstColorType: @@ -416,9 +407,6 @@ static void push_brd_src(Path path, SkBitmapRegionDecoder::Strategy strategy, case SkBitmapRegionDecoder::kCanvas_Strategy: folder.append("brd_canvas"); break; - case SkBitmapRegionDecoder::kOriginal_Strategy: - folder.append("brd_sample"); - break; case SkBitmapRegionDecoder::kAndroidCodec_Strategy: folder.append("brd_android_codec"); break; @@ -464,7 +452,6 @@ static void push_brd_srcs(Path path) { const SkBitmapRegionDecoder::Strategy strategies[] = { SkBitmapRegionDecoder::kCanvas_Strategy, - SkBitmapRegionDecoder::kOriginal_Strategy, SkBitmapRegionDecoder::kAndroidCodec_Strategy, }; @@ -559,7 +546,6 @@ static void gather_srcs() { for (SkString file; it.next(&file); ) { SkString path = SkOSPath::Join(flag, file.c_str()); push_src("image", "decode", new ImageSrc(path)); // Decode entire image - push_src("image", "subset", new ImageSrc(path, 2)); // Decode into 2x2 subsets push_codec_srcs(path); if (brd_supported(exts[j])) { push_brd_srcs(path); @@ -569,7 +555,6 @@ static void gather_srcs() { } else if (sk_exists(flag)) { // assume that FLAGS_images[i] is a valid image if it is a file. push_src("image", "decode", new ImageSrc(flag)); // Decode entire image. - push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2 x 2 subsets push_codec_srcs(flag); push_brd_srcs(flag); } diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 0945d83..fb546dc 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -766,7 +766,7 @@ Name AndroidCodecSrc::name() const { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ -ImageSrc::ImageSrc(Path path, int divisor) : fPath(path), fDivisor(divisor) {} +ImageSrc::ImageSrc(Path path) : fPath(path) {} bool ImageSrc::veto(SinkFlags flags) const { // No need to test decoding to non-raster or indirect backend. @@ -781,60 +781,19 @@ Error ImageSrc::draw(SkCanvas* canvas) const { return SkStringPrintf("Couldn't read %s.", fPath.c_str()); } const SkColorType dstColorType = canvas->imageInfo().colorType(); - if (fDivisor == 0) { - // Decode the full image. - SkBitmap bitmap; - if (!SkImageDecoder::DecodeMemory(encoded->data(), encoded->size(), &bitmap, - dstColorType, SkImageDecoder::kDecodePixels_Mode)) { - return SkStringPrintf("Couldn't decode %s.", fPath.c_str()); - } - if (kRGB_565_SkColorType == dstColorType && !bitmap.isOpaque()) { - // Do not draw a bitmap with alpha to a destination without alpha. - return Error::Nonfatal("Uninteresting to decode image with alpha into 565."); - } - encoded.reset((SkData*)nullptr); // Might as well drop this when we're done with it. - canvas->drawBitmap(bitmap, 0,0); - return ""; - } - // Decode subsets. This is a little involved. - SkAutoTDelete stream(new SkMemoryStream(encoded)); - SkAutoTDelete decoder(SkImageDecoder::Factory(stream.get())); - if (!decoder) { - return SkStringPrintf("Can't find a good decoder for %s.", fPath.c_str()); - } - stream->rewind(); - int w,h; - if (!decoder->buildTileIndex(stream.detach(), &w, &h)) { - return Error::Nonfatal("Subset decoding not supported."); - } - // Divide the image into subsets that cover the entire image. - if (fDivisor > w || fDivisor > h) { - return Error::Nonfatal(SkStringPrintf("Cannot decode subset: divisor %d is too big" - "for %s with dimensions (%d x %d)", fDivisor, fPath.c_str(), w, h)); + // Decode the full image. + SkBitmap bitmap; + if (!SkImageDecoder::DecodeMemory(encoded->data(), encoded->size(), &bitmap, + dstColorType, SkImageDecoder::kDecodePixels_Mode)) { + return SkStringPrintf("Couldn't decode %s.", fPath.c_str()); } - const int subsetWidth = w / fDivisor, - subsetHeight = h / fDivisor; - for (int y = 0; y < h; y += subsetHeight) { - for (int x = 0; x < w; x += subsetWidth) { - SkBitmap subset; - SkIRect rect = SkIRect::MakeXYWH(x, y, subsetWidth, subsetHeight); - if (!decoder->decodeSubset(&subset, rect, dstColorType)) { - return SkStringPrintf("Could not decode subset (%d, %d, %d, %d).", - x, y, x+subsetWidth, y+subsetHeight); - } - if (kRGB_565_SkColorType == dstColorType && !subset.isOpaque()) { - // Do not draw a bitmap with alpha to a destination without alpha. - // This is not an error, but there is nothing interesting to show. - - // This should only happen on the first iteration through the loop. - SkASSERT(0 == x && 0 == y); - - return Error::Nonfatal("Uninteresting to decode image with alpha into 565."); - } - canvas->drawBitmap(subset, SkIntToScalar(x), SkIntToScalar(y)); - } + if (kRGB_565_SkColorType == dstColorType && !bitmap.isOpaque()) { + // Do not draw a bitmap with alpha to a destination without alpha. + return Error::Nonfatal("Uninteresting to decode image with alpha into 565."); } + encoded.reset((SkData*)nullptr); // Might as well drop this when we're done with it. + canvas->drawBitmap(bitmap, 0,0); return ""; } diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h index 78c6b5c..6371a90 100644 --- a/dm/DMSrcSink.h +++ b/dm/DMSrcSink.h @@ -179,9 +179,7 @@ private: class ImageSrc : public Src { public: - // divisor == 0 means decode the whole image - // divisor > 0 means decode in subsets, dividing into a divisor x divisor grid. - explicit ImageSrc(Path path, int divisor = 0); + explicit ImageSrc(Path path); Error draw(SkCanvas*) const override; SkISize size() const override; @@ -189,7 +187,6 @@ public: bool veto(SinkFlags) const override; private: Path fPath; - const int fDivisor; }; class SKPSrc : public Src { -- 2.7.4