From d1227a7417922ce26252d55815d0d1e98f0eb070 Mon Sep 17 00:00:00 2001 From: msarett Date: Wed, 18 May 2016 06:23:57 -0700 Subject: Delete SkBitmapRegionCanvas This was an approach we considered for implementing Android's BitmapRegionDecoder. It was useful for testing and comparison, but now is no longer worth maintaining and testing. The approach to subset/scaled decodes (clipped decode, then scale) may be worth reconsidering at some point. BUG=skia:5307 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1990543002 Review-Url: https://codereview.chromium.org/1990543002 --- dm/DM.cpp | 61 ++++++++------------------------------------------------ dm/DMSrcSink.cpp | 13 +++++------- dm/DMSrcSink.h | 3 +-- 3 files changed, 14 insertions(+), 63 deletions(-) (limited to 'dm') diff --git a/dm/DM.cpp b/dm/DM.cpp index 4f03befcd1..8685ec5567 100644 --- a/dm/DM.cpp +++ b/dm/DM.cpp @@ -609,44 +609,9 @@ static void push_codec_srcs(Path path) { } } -static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy, - CodecSrc::DstColorType dstColorType) { - switch (strategy) { - case SkBitmapRegionDecoder::kCanvas_Strategy: - if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) { - return true; - } - return false; - case SkBitmapRegionDecoder::kAndroidCodec_Strategy: - switch (dstColorType) { - case CodecSrc::kGetFromCanvas_DstColorType: - case CodecSrc::kIndex8_Always_DstColorType: - case CodecSrc::kGrayscale_Always_DstColorType: - return true; - default: - return false; - } - default: - SkASSERT(false); - return false; - } -} - -static void push_brd_src(Path path, SkBitmapRegionDecoder::Strategy strategy, - CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode, uint32_t sampleSize) { - SkString folder; - switch (strategy) { - case SkBitmapRegionDecoder::kCanvas_Strategy: - folder.append("brd_canvas"); - break; - case SkBitmapRegionDecoder::kAndroidCodec_Strategy: - folder.append("brd_android_codec"); - break; - default: - SkASSERT(false); - return; - } - +static void push_brd_src(Path path, CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode, + uint32_t sampleSize) { + SkString folder("brd_android_codec"); switch (mode) { case BRDSrc::kFullImage_Mode: break; @@ -676,17 +641,11 @@ static void push_brd_src(Path path, SkBitmapRegionDecoder::Strategy strategy, folder.appendf("_%.3f", 1.0f / (float) sampleSize); } - BRDSrc* src = new BRDSrc(path, strategy, mode, dstColorType, sampleSize); + BRDSrc* src = new BRDSrc(path, mode, dstColorType, sampleSize); push_src("image", folder, src); } static void push_brd_srcs(Path path) { - - const SkBitmapRegionDecoder::Strategy strategies[] = { - SkBitmapRegionDecoder::kCanvas_Strategy, - SkBitmapRegionDecoder::kAndroidCodec_Strategy, - }; - // Test on a variety of sampleSizes, making sure to include: // - 2, 4, and 8, which are natively supported by jpeg // - multiples of 2 which are not divisible by 4 (analogous for 4) @@ -707,14 +666,10 @@ static void push_brd_srcs(Path path) { BRDSrc::kDivisor_Mode, }; - for (SkBitmapRegionDecoder::Strategy strategy : strategies) { - for (uint32_t sampleSize : sampleSizes) { - for (CodecSrc::DstColorType dstColorType : dstColorTypes) { - if (brd_color_type_supported(strategy, dstColorType)) { - for (BRDSrc::Mode mode : modes) { - push_brd_src(path, strategy, dstColorType, mode, sampleSize); - } - } + for (uint32_t sampleSize : sampleSizes) { + for (CodecSrc::DstColorType dstColorType : dstColorTypes) { + for (BRDSrc::Mode mode : modes) { + push_brd_src(path, dstColorType, mode, sampleSize); } } } diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 1155395f40..028dff886b 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -71,10 +71,8 @@ void GMSrc::modifyGrContextOptions(GrContextOptions* options) const { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ -BRDSrc::BRDSrc(Path path, SkBitmapRegionDecoder::Strategy strategy, Mode mode, - CodecSrc::DstColorType dstColorType, uint32_t sampleSize) +BRDSrc::BRDSrc(Path path, Mode mode, CodecSrc::DstColorType dstColorType, uint32_t sampleSize) : fPath(path) - , fStrategy(strategy) , fMode(mode) , fDstColorType(dstColorType) , fSampleSize(sampleSize) @@ -86,13 +84,12 @@ bool BRDSrc::veto(SinkFlags flags) const { || flags.approach != SinkFlags::kDirect; } -static SkBitmapRegionDecoder* create_brd(Path path, - SkBitmapRegionDecoder::Strategy strategy) { +static SkBitmapRegionDecoder* create_brd(Path path) { SkAutoTUnref encoded(SkData::NewFromFileName(path.c_str())); if (!encoded) { return NULL; } - return SkBitmapRegionDecoder::Create(encoded, strategy); + return SkBitmapRegionDecoder::Create(encoded, SkBitmapRegionDecoder::kAndroidCodec_Strategy); } Error BRDSrc::draw(SkCanvas* canvas) const { @@ -115,7 +112,7 @@ Error BRDSrc::draw(SkCanvas* canvas) const { break; } - SkAutoTDelete brd(create_brd(fPath, fStrategy)); + SkAutoTDelete brd(create_brd(fPath)); if (nullptr == brd.get()) { return Error::Nonfatal(SkStringPrintf("Could not create brd for %s.", fPath.c_str())); } @@ -217,7 +214,7 @@ Error BRDSrc::draw(SkCanvas* canvas) const { } SkISize BRDSrc::size() const { - SkAutoTDelete brd(create_brd(fPath, fStrategy)); + SkAutoTDelete brd(create_brd(fPath)); if (brd) { return SkISize::Make(SkTMax(1, brd->width() / (int) fSampleSize), SkTMax(1, brd->height() / (int) fSampleSize)); diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h index b4866426f1..b0f67dbb29 100644 --- a/dm/DMSrcSink.h +++ b/dm/DMSrcSink.h @@ -165,7 +165,7 @@ public: kDivisor_Mode, }; - BRDSrc(Path, SkBitmapRegionDecoder::Strategy, Mode, CodecSrc::DstColorType, uint32_t); + BRDSrc(Path, Mode, CodecSrc::DstColorType, uint32_t); Error draw(SkCanvas*) const override; SkISize size() const override; @@ -173,7 +173,6 @@ public: bool veto(SinkFlags) const override; private: Path fPath; - SkBitmapRegionDecoder::Strategy fStrategy; Mode fMode; CodecSrc::DstColorType fDstColorType; uint32_t fSampleSize; -- cgit v1.2.3