| Index: tools/SkBitmapRegionDecoderPriv.h
|
| diff --git a/tools/SkBitmapRegionDecoderPriv.h b/tools/SkBitmapRegionDecoderPriv.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0e706dede270d405f1172cd9bf04926d21b6a98f
|
| --- /dev/null
|
| +++ b/tools/SkBitmapRegionDecoderPriv.h
|
| @@ -0,0 +1,35 @@
|
| +/*
|
| + * Copyright 2015 Google Inc.
|
| + *
|
| + * Use of this source code is governed by a BSD-style license that can be
|
| + * found in the LICENSE file.
|
| + */
|
| +
|
| +#ifndef SkBitmapRegionDecoderPriv_DEFINED
|
| +#define SkBitmapRegionDecoderPriv_DEFINED
|
| +
|
| +/*
|
| + * Chooses the correct image subset offsets and dimensions for the partial decode.
|
| + *
|
| + * @return true if the subset is completely contained within the image
|
| + * false otherwise
|
| + */
|
| +inline 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);
|
| +}
|
| +
|
| +#endif // SkBitmapRegionDecoderPriv_DEFINED
|
|
|