Chromium Code Reviews| Index: tools/SkBitmapRegionSampler.cpp |
| diff --git a/tools/SkBitmapRegionSampler.cpp b/tools/SkBitmapRegionSampler.cpp |
| index 514af108593ffa6113233fe9cf807e376d8169fe..cdcee9946a42df80d663b1e9c9fc901538483805 100644 |
| --- a/tools/SkBitmapRegionSampler.cpp |
| +++ b/tools/SkBitmapRegionSampler.cpp |
| @@ -14,38 +14,18 @@ SkBitmapRegionSampler::SkBitmapRegionSampler(SkImageDecoder* decoder, int width, |
| , fDecoder(decoder) |
| {} |
| -/* |
| - * Three differences from the Android version: |
| - * Returns a Skia bitmap instead of an Android bitmap. |
| - * Android version attempts to reuse a recycled bitmap. |
| - * Removed the options object and used parameters for color type and |
| - * sample size. |
| - */ |
| -SkBitmap* SkBitmapRegionSampler::decodeRegion(int start_x, int start_y, |
| - int width, int height, |
| - int sampleSize, |
| - SkColorType prefColorType) { |
| - // Match Android's default settings |
| +bool SkBitmapRegionSampler::decodeRegion(SkBitmap* bitmap, SkBitmap::Allocator* allocator, |
| + const SkIRect& desiredSubset, int sampleSize, SkColorType colorType, bool requireUnpremul) { |
| fDecoder->setDitherImage(true); |
| fDecoder->setPreferQualityOverSpeed(false); |
| fDecoder->setRequireUnpremultipliedColors(false); |
| fDecoder->setSampleSize(sampleSize); |
| + fDecoder->setAllocator(allocator); |
|
scroggo
2015/10/27 18:53:55
I think you need to undo this - setAllocator will
msarett
2015/10/27 19:06:16
Nice catch!
|
| // kAlpha8 is the legacy representation of kGray8 used by SkImageDecoder |
| - if (kGray_8_SkColorType == prefColorType) { |
| - prefColorType = kAlpha_8_SkColorType; |
| + if (kGray_8_SkColorType == colorType) { |
| + colorType = kAlpha_8_SkColorType; |
| } |
| - SkIRect region; |
| - region.fLeft = start_x; |
| - region.fTop = start_y; |
| - region.fRight = start_x + width; |
| - region.fBottom = start_y + height; |
| - |
| - SkAutoTDelete<SkBitmap> bitmap(new SkBitmap()); |
| - if (!fDecoder->decodeSubset(bitmap.get(), region, prefColorType)) { |
| - SkCodecPrintf("Error: decodeRegion failed.\n"); |
| - return nullptr; |
| - } |
| - return bitmap.detach(); |
| + return fDecoder->decodeSubset(bitmap, desiredSubset, colorType); |
| } |