diff options
author | scroggo <scroggo@chromium.org> | 2016-05-16 09:04:13 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-16 09:04:14 -0700 |
commit | f8dc9df9ab0a90b74d56df9583752a1c38ee20f4 (patch) | |
tree | 7dee1c73a7bce2303dfa5ecdbcb5a188e69f301f | |
parent | c99b8f0351850cc1901fe359feb4ca357141346f (diff) |
Drop AndroidCodecSrc::kDivisor_Mode
This is redundant with BRD tests.
BUG=skia:5307
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1976303002
Review-Url: https://codereview.chromium.org/1976303002
-rw-r--r-- | dm/DM.cpp | 37 | ||||
-rw-r--r-- | dm/DMSrcSink.cpp | 88 | ||||
-rw-r--r-- | dm/DMSrcSink.h | 10 |
3 files changed, 16 insertions, 119 deletions
@@ -394,17 +394,10 @@ static void push_codec_src(Path path, CodecSrc::Mode mode, CodecSrc::DstColorTyp push_src("image", folder, src); } -static void push_android_codec_src(Path path, AndroidCodecSrc::Mode mode, - CodecSrc::DstColorType dstColorType, SkAlphaType dstAlphaType, int sampleSize) { +static void push_android_codec_src(Path path, CodecSrc::DstColorType dstColorType, + SkAlphaType dstAlphaType, int sampleSize) { SkString folder; - switch (mode) { - case AndroidCodecSrc::kFullImage_Mode: - folder.append("scaled_codec"); - break; - case AndroidCodecSrc::kDivisor_Mode: - folder.append("scaled_codec_divisor"); - break; - } + folder.append("scaled_codec"); switch (dstColorType) { case CodecSrc::kGrayscale_Always_DstColorType: @@ -438,7 +431,7 @@ static void push_android_codec_src(Path path, AndroidCodecSrc::Mode mode, folder.appendf("_%.3f", 1.0f / (float) sampleSize); } - AndroidCodecSrc* src = new AndroidCodecSrc(path, mode, dstColorType, dstAlphaType, sampleSize); + AndroidCodecSrc* src = new AndroidCodecSrc(path, dstColorType, dstAlphaType, sampleSize); push_src("image", folder, src); } @@ -564,21 +557,6 @@ static void push_codec_srcs(Path path) { return; } - // https://bug.skia.org/4428 - bool subset = false; - // The following image types are supported by BitmapRegionDecoder, - // so we will test full image decodes and subset decodes. - static const char* const exts[] = { - "jpg", "jpeg", "png", "webp", - "JPG", "JPEG", "PNG", "WEBP", - }; - for (const char* ext : exts) { - if (path.endsWith(ext)) { - subset = true; - break; - } - } - const int sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; for (int sampleSize : sampleSizes) { @@ -590,12 +568,7 @@ static void push_codec_srcs(Path path) { continue; } - push_android_codec_src(path, AndroidCodecSrc::kFullImage_Mode, colorType, - alphaType, sampleSize); - if (subset) { - push_android_codec_src(path, AndroidCodecSrc::kDivisor_Mode, colorType, - alphaType, sampleSize); - } + push_android_codec_src(path, colorType, alphaType, sampleSize); } } } diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index b1e280d289..69c1e0ba48 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -642,10 +642,9 @@ Name CodecSrc::name() const { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ -AndroidCodecSrc::AndroidCodecSrc(Path path, Mode mode, CodecSrc::DstColorType dstColorType, +AndroidCodecSrc::AndroidCodecSrc(Path path, CodecSrc::DstColorType dstColorType, SkAlphaType dstAlphaType, int sampleSize) : fPath(path) - , fMode(mode) , fDstColorType(dstColorType) , fDstAlphaType(dstAlphaType) , fSampleSize(sampleSize) @@ -712,84 +711,17 @@ Error AndroidCodecSrc::draw(SkCanvas* canvas) const { options.fColorCount = colorCountPtr; options.fSampleSize = fSampleSize; - switch (fMode) { - case kFullImage_Mode: { - switch (codec->getAndroidPixels(decodeInfo, bitmap.getPixels(), bitmap.rowBytes(), - &options)) { - case SkCodec::kSuccess: - case SkCodec::kIncompleteInput: - break; - default: - return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str()); - } - premultiply_if_necessary(bitmap); - swap_rb_if_necessary(bitmap, fDstColorType); - canvas->drawBitmap(bitmap, 0, 0); - return ""; - } - case kDivisor_Mode: { - const int width = codec->getInfo().width(); - const int height = codec->getInfo().height(); - const int divisor = 2; - if (width < divisor || height < divisor) { - return Error::Nonfatal("Divisor is larger than image dimension."); - } - - // Keep track of the final decoded dimensions. - int finalScaledWidth = 0; - int finalScaledHeight = 0; - for (int x = 0; x < divisor; x++) { - for (int y = 0; y < divisor; y++) { - // Calculate the subset dimensions - int subsetWidth = width / divisor; - int subsetHeight = height / divisor; - const int left = x * subsetWidth; - const int top = y * subsetHeight; - - // Increase the size of the last subset in each row or column, when the - // divisor does not divide evenly into the image dimensions - subsetWidth += (x + 1 == divisor) ? (width % divisor) : 0; - subsetHeight += (y + 1 == divisor) ? (height % divisor) : 0; - SkIRect subset = SkIRect::MakeXYWH(left, top, subsetWidth, subsetHeight); - if (!codec->getSupportedSubset(&subset)) { - return "Could not get supported subset to decode."; - } - options.fSubset = ⊂ - const int scaledWidthOffset = subset.left() / fSampleSize; - const int scaledHeightOffset = subset.top() / fSampleSize; - void* pixels = bitmap.getAddr(scaledWidthOffset, scaledHeightOffset); - SkISize scaledSubsetSize = codec->getSampledSubsetDimensions(fSampleSize, - subset); - SkImageInfo subsetDecodeInfo = decodeInfo.makeWH(scaledSubsetSize.width(), - scaledSubsetSize.height()); - - if (x + 1 == divisor && y + 1 == divisor) { - finalScaledWidth = scaledWidthOffset + scaledSubsetSize.width(); - finalScaledHeight = scaledHeightOffset + scaledSubsetSize.height(); - } - - switch (codec->getAndroidPixels(subsetDecodeInfo, pixels, bitmap.rowBytes(), - &options)) { - case SkCodec::kSuccess: - case SkCodec::kIncompleteInput: - break; - default: - return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str()); - } - } - } - - SkRect rect = SkRect::MakeXYWH(0, 0, (SkScalar) finalScaledWidth, - (SkScalar) finalScaledHeight); - premultiply_if_necessary(bitmap); - swap_rb_if_necessary(bitmap, fDstColorType); - canvas->drawBitmapRect(bitmap, rect, rect, nullptr); - return ""; - } + switch (codec->getAndroidPixels(decodeInfo, bitmap.getPixels(), bitmap.rowBytes(), &options)) { + case SkCodec::kSuccess: + case SkCodec::kIncompleteInput: + break; default: - SkASSERT(false); - return "Error: Should not be reached."; + return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str()); } + premultiply_if_necessary(bitmap); + swap_rb_if_necessary(bitmap, fDstColorType); + canvas->drawBitmap(bitmap, 0, 0); + return ""; } SkISize AndroidCodecSrc::size() const { diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h index 5a734a6f3c..b4866426f1 100644 --- a/dm/DMSrcSink.h +++ b/dm/DMSrcSink.h @@ -137,14 +137,7 @@ private: class AndroidCodecSrc : public Src { public: - enum Mode { - kFullImage_Mode, - // Splits the image into multiple subsets using a divisor and decodes the subsets - // separately. - kDivisor_Mode, - }; - - AndroidCodecSrc(Path, Mode, CodecSrc::DstColorType, SkAlphaType, int sampleSize); + AndroidCodecSrc(Path, CodecSrc::DstColorType, SkAlphaType, int sampleSize); Error draw(SkCanvas*) const override; SkISize size() const override; @@ -153,7 +146,6 @@ public: bool serial() const override { return fRunSerially; } private: Path fPath; - Mode fMode; CodecSrc::DstColorType fDstColorType; SkAlphaType fDstAlphaType; int fSampleSize; |