Chromium Code Reviews| Index: tools/SkBitmapRegionCanvas.cpp |
| diff --git a/tools/SkBitmapRegionCanvas.cpp b/tools/SkBitmapRegionCanvas.cpp |
| index 7226e044e75c82a77b908a39d33d9d3281bcc50a..f7083e623d643924be4eea6cb5cb20c50ac10216 100644 |
| --- a/tools/SkBitmapRegionCanvas.cpp |
| +++ b/tools/SkBitmapRegionCanvas.cpp |
| @@ -16,30 +16,6 @@ SkBitmapRegionCanvas::SkBitmapRegionCanvas(SkCodec* decoder) |
| {} |
| /* |
| - * Chooses the correct image subset offsets and dimensions for the partial decode. |
|
msarett
2015/10/12 18:42:36
Moved to SkCodecTools.h
The only change is that t
|
| - * |
| - * @return true if the subset is completely contained within the image |
| - * false otherwise |
| - */ |
| -static bool set_subset_region(int inputOffset, int inputDimension, |
| - int imageOriginalDimension, int* imageSubsetOffset, int* outOffset, |
| - int* imageSubsetDimension) { |
| - |
| - // This must be at least zero, we can't start decoding the image at a negative coordinate. |
| - *imageSubsetOffset = SkTMax(0, inputOffset); |
| - |
| - // If inputOffset is less than zero, we decode to an offset location in the output bitmap. |
| - *outOffset = *imageSubsetOffset - inputOffset; |
| - |
| - // Use imageSusetOffset to make sure we don't decode pixels past the edge of the image. |
| - // Use outOffset to make sure we don't decode pixels past the edge of the region. |
| - *imageSubsetDimension = SkTMin(imageOriginalDimension - *imageSubsetOffset, |
| - inputDimension - *outOffset); |
| - |
| - return (*outOffset == 0) && (*imageSubsetDimension == inputDimension); |
| -} |
| - |
| -/* |
| * Three differences from the Android version: |
| * Returns a Skia bitmap instead of an Android bitmap. |
| * Android version attempts to reuse a recycled bitmap. |
| @@ -56,6 +32,11 @@ SkBitmap* SkBitmapRegionCanvas::decodeRegion(int inputX, int inputY, |
| return nullptr; |
| } |
| + // Fix the input sampleSize if necessary. |
|
msarett
2015/10/12 18:42:36
Android does not set a default sampleSize. We sho
|
| + if (sampleSize < 1) { |
| + sampleSize = 1; |
| + } |
| + |
| // The client may not necessarily request a region that is fully within |
| // the image. We may need to do some calculation to determine what part |
| // of the image to decode. |
| @@ -108,7 +89,7 @@ SkBitmap* SkBitmapRegionCanvas::decodeRegion(int inputX, int inputY, |
| } |
| SkImageInfo decodeInfo = SkImageInfo::Make(this->width(), this->height(), |
| dstColorType, dstAlphaType); |
| - |
| + |
| // Start the scanline decoder |
| SkCodec::Result r = fDecoder->startScanlineDecode(decodeInfo); |
| if (SkCodec::kSuccess != r) { |
| @@ -152,7 +133,7 @@ SkBitmap* SkBitmapRegionCanvas::decodeRegion(int inputX, int inputY, |
| // TODO (msarett): This could be skipped if memory is zero initialized. |
| // This would matter if this code is moved to Android and |
| // uses Android bitmaps. |
| - if (imageContainsEntireSubset) { |
| + if (!imageContainsEntireSubset) { |
|
msarett
2015/10/12 18:42:36
Oops.
|
| bitmap->eraseColor(0); |
| } |