Chromium Code Reviews| Index: src/codec/SkCodecPriv.h |
| diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h |
| index 1bad7b3028af46ac2289289980c42f3a601d84f8..d20878bd9ac95cf2dae644bd1000f0de8d04f0d7 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) { |
|
scroggo
2015/10/02 18:27:03
Why not:
return SkIRect::MakeSize(imageDims).cont
|
| + 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) { |
|
scroggo
2015/10/02 18:27:03
I assume scaledDim now means scaled version of sub
|
| // 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; |
| } |