| Index: src/codec/SkCodecPriv.h
|
| diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h
|
| index ea4aa0e092197429e183aac9bf83461c50210301..b4ccf369d4004327982e03f633bbe0d0653e7a3e 100644
|
| --- a/src/codec/SkCodecPriv.h
|
| +++ b/src/codec/SkCodecPriv.h
|
| @@ -31,6 +31,18 @@
|
| #define COMPUTE_RESULT_ALPHA \
|
| SkSwizzler::GetResult(zeroAlpha, maxAlpha);
|
|
|
| +inline bool is_valid_subset(const SkIRect* subset, const SkISize& imageDims) {
|
| + if (0 > subset->left() || subset->left() >= imageDims.width() ||
|
| + 0 > subset->top() || subset->top() >= imageDims.height() ||
|
| + 0 > subset->width() || subset->left() + subset->width() > imageDims.width() ||
|
| + 0 > subset->height() || subset->top() + subset->height() > imageDims.height()) {
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +inline float get_scale(uint32_t sampleSize) { return 1.0f / (float) sampleSize; }
|
| +
|
| /*
|
| * returns a scaled dimension based on the original dimension and the sampleSize
|
| * NOTE: we round down here for scaled dimension to match the behavior of SkImageDecoder
|
| @@ -68,12 +80,13 @@ inline int get_dst_coord(int srcCoord, int sampleFactor) { return srcCoord / sam
|
| *
|
| * This does not need to be called and is not called when sampleFactor == 1.
|
| */
|
| -inline bool is_coord_necessary(int srcCoord, int sampleFactor, int scaledDim) {
|
| +inline bool is_coord_necessary(int srcCoord, int sampleFactor, int scaledDim, int subsetOffset) {
|
| // Get the first coordinate that we want to keep
|
| - int startCoord = get_start_coord(sampleFactor);
|
| + int startCoord = get_start_coord(sampleFactor) + subsetOffset;
|
|
|
| // Return false on edge cases
|
| - if (srcCoord < startCoord || get_dst_coord(srcCoord, sampleFactor) >= scaledDim) {
|
| + if (srcCoord < startCoord ||
|
| + get_dst_coord(srcCoord - subsetOffset, sampleFactor) >= scaledDim) {
|
| return false;
|
| }
|
|
|
|
|