diff options
author | 2015-08-04 09:24:45 -0700 | |
---|---|---|
committer | 2015-08-04 09:24:45 -0700 | |
commit | 1c005e4a38e29d648ecebada25d3a718155043a3 (patch) | |
tree | ccc10aa351e4c58f9ffcd53b849d9a5afc46c28b /bench | |
parent | ddc726f1de09426557983361a0e7838a83612315 (diff) |
Create a scanline decoder without creating a codec
Prior to this CL, if a client wanted to decode scanlines, they had to
create an SkCodec in order to get an SkScanlineDecoder. This introduces
complications if input data is not easily shared between the two
objects.
Instead, add methods to SkScanlineDecoder for creating a new one from
input data, and remove the creation functions from SkCodec.
Update DM and tests.
Review URL: https://codereview.chromium.org/1267583002
Diffstat (limited to 'bench')
-rw-r--r-- | bench/nanobench.cpp | 7 | ||||
-rw-r--r-- | bench/subset/SubsetSingleBench.cpp | 8 | ||||
-rw-r--r-- | bench/subset/SubsetTranslateBench.cpp | 8 | ||||
-rw-r--r-- | bench/subset/SubsetZoomBench.cpp | 8 |
4 files changed, 16 insertions, 15 deletions
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp index dbf7124555..2720b6f2de 100644 --- a/bench/nanobench.cpp +++ b/bench/nanobench.cpp @@ -513,9 +513,10 @@ static bool valid_subset_bench(const SkString& path, SkColorType colorType, bool int colorCount; const SkImageInfo info = codec->getInfo().makeColorType(colorType); SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowBytes())); - SkAutoTDelete<SkScanlineDecoder> scanlineDecoder(codec->getScanlineDecoder(info, NULL, - colors, &colorCount)); - if (NULL == scanlineDecoder) { + SkAutoTDelete<SkScanlineDecoder> scanlineDecoder(SkScanlineDecoder::NewFromData(encoded)); + if (NULL == scanlineDecoder || scanlineDecoder->start(info, NULL, + colors, &colorCount) != SkCodec::kSuccess) + { SkDebugf("Could not create scanline decoder for %s with color type %s. " "Skipping bench.\n", path.c_str(), get_color_name(colorType)); return false; diff --git a/bench/subset/SubsetSingleBench.cpp b/bench/subset/SubsetSingleBench.cpp index 1828f8771f..303cd556ec 100644 --- a/bench/subset/SubsetSingleBench.cpp +++ b/bench/subset/SubsetSingleBench.cpp @@ -64,11 +64,11 @@ void SubsetSingleBench::onDraw(const int n, SkCanvas* canvas) { SkPMColor colors[256]; if (fUseCodec) { for (int count = 0; count < n; count++) { - SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplicate())); - const SkImageInfo info = codec->getInfo().makeColorType(fColorType); + SkAutoTDelete<SkScanlineDecoder> scanlineDecoder( + SkScanlineDecoder::NewFromStream(fStream->duplicate())); + const SkImageInfo info = scanlineDecoder->getInfo().makeColorType(fColorType); SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowBytes())); - SkAutoTDelete<SkScanlineDecoder> scanlineDecoder(codec->getScanlineDecoder( - info, NULL, colors, &colorCount)); + scanlineDecoder->start(info, NULL, colors, &colorCount); SkBitmap bitmap; SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight); diff --git a/bench/subset/SubsetTranslateBench.cpp b/bench/subset/SubsetTranslateBench.cpp index 708cb553c7..2e66c3807e 100644 --- a/bench/subset/SubsetTranslateBench.cpp +++ b/bench/subset/SubsetTranslateBench.cpp @@ -60,11 +60,11 @@ void SubsetTranslateBench::onDraw(const int n, SkCanvas* canvas) { SkPMColor colors[256]; if (fUseCodec) { for (int count = 0; count < n; count++) { - SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplicate())); - const SkImageInfo info = codec->getInfo().makeColorType(fColorType); + SkAutoTDelete<SkScanlineDecoder> scanlineDecoder( + SkScanlineDecoder::NewFromStream(fStream->duplicate())); + const SkImageInfo info = scanlineDecoder->getInfo().makeColorType(fColorType); SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowBytes())); - SkAutoTDelete<SkScanlineDecoder> scanlineDecoder(codec->getScanlineDecoder( - info, NULL, colors, &colorCount)); + scanlineDecoder->start(info, NULL, colors, &colorCount); SkBitmap bitmap; // Note that we use the same bitmap for all of the subsets. diff --git a/bench/subset/SubsetZoomBench.cpp b/bench/subset/SubsetZoomBench.cpp index 22bca23318..84d50aa478 100644 --- a/bench/subset/SubsetZoomBench.cpp +++ b/bench/subset/SubsetZoomBench.cpp @@ -60,11 +60,11 @@ void SubsetZoomBench::onDraw(const int n, SkCanvas* canvas) { SkPMColor colors[256]; if (fUseCodec) { for (int count = 0; count < n; count++) { - SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplicate())); - const SkImageInfo info = codec->getInfo().makeColorType(fColorType); + SkAutoTDelete<SkScanlineDecoder> scanlineDecoder( + SkScanlineDecoder::NewFromStream(fStream->duplicate())); + const SkImageInfo info = scanlineDecoder->getInfo().makeColorType(fColorType); SkAutoTDeleteArray<uint8_t> row(SkNEW_ARRAY(uint8_t, info.minRowBytes())); - SkAutoTDelete<SkScanlineDecoder> scanlineDecoder(codec->getScanlineDecoder( - info, NULL, colors, &colorCount)); + scanlineDecoder->start(info, NULL, colors, &colorCount); const int centerX = info.width() / 2; const int centerY = info.height() / 2; |