| Index: src/codec/SkCodecPriv.h
|
| diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h
|
| index 0442625dd20b858ee7e9cd84877f3417124fcbd1..a9f11091590764c9efb8c0cde124faa5d581f078 100644
|
| --- a/src/codec/SkCodecPriv.h
|
| +++ b/src/codec/SkCodecPriv.h
|
| @@ -31,9 +31,19 @@
|
| #define COMPUTE_RESULT_ALPHA \
|
| SkSwizzler::GetResult(zeroAlpha, maxAlpha);
|
|
|
| +// FIXME: Consider sharing with dm, nanbench, and tools.
|
| +inline float get_scale_from_sample_size(int sampleSize) {
|
| + return 1.0f / ((float) sampleSize);
|
| +}
|
| +
|
| +inline bool is_valid_subset(const SkIRect& subset, const SkISize& imageDims) {
|
| + return SkIRect::MakeSize(imageDims).contains(subset);
|
| +}
|
| +
|
| /*
|
| * 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
|
| + * FIXME: I think we should call this get_sampled_dimension().
|
| */
|
| inline int get_scaled_dimension(int srcDimension, int sampleSize) {
|
| if (sampleSize > srcDimension) {
|
| @@ -64,21 +74,29 @@ inline int get_dst_coord(int srcCoord, int sampleFactor) { return srcCoord / sam
|
| * When scaling, we will discard certain y-coordinates (rows) and
|
| * x-coordinates (columns). This function returns true if we should keep the
|
| * coordinate and false otherwise.
|
| - * The inputs may be x-coordinates or y-coordinates.
|
| + *
|
| + * The inputs may be x-coordinates or y-coordinates, but for clarity, it helps
|
| + * to name variables using y-coordinate naming conventions. This is an
|
| + * arbitrary choice.
|
| *
|
| * This does not need to be called and is not called when sampleFactor == 1.
|
| + *
|
| + * @param srcY Unscaled, original y-coordinate
|
| + * @param sampleY Sampling factor used in the y-dimension
|
| + * @param scaledSubsetHeight Height of the final output, after any scaling or subsetting
|
| + * @param subsetY Top of the subset as an unscaled, original y-coordinate
|
| */
|
| -inline bool is_coord_necessary(int srcCoord, int sampleFactor, int scaledDim) {
|
| +inline bool is_coord_necessary(int srcY, int sampleY, int scaledSubsetHeight, int subsetY) {
|
| // Get the first coordinate that we want to keep
|
| - int startCoord = get_start_coord(sampleFactor);
|
| + int startY = get_start_coord(sampleY) + subsetY;
|
|
|
| // Return false on edge cases
|
| - if (srcCoord < startCoord || get_dst_coord(srcCoord, sampleFactor) >= scaledDim) {
|
| + if (srcY < startY || get_dst_coord(srcY - subsetY, sampleY) >= scaledSubsetHeight) {
|
| return false;
|
| }
|
|
|
| - // Every sampleFactor rows are necessary
|
| - return ((srcCoord - startCoord) % sampleFactor) == 0;
|
| + // Every sampleY rows are necessary
|
| + return ((srcY - startY) % sampleY) == 0;
|
| }
|
|
|
| inline bool valid_alpha(SkAlphaType dstAlpha, SkAlphaType srcAlpha) {
|
|
|