OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef SkBitmapRegionDecoderPriv_DEFINED |
| 9 #define SkBitmapRegionDecoderPriv_DEFINED |
| 10 |
| 11 /* |
| 12 * Chooses the correct image subset offsets and dimensions for the partial decod
e. |
| 13 * |
| 14 * @return true if the subset is completely contained within the image |
| 15 * false otherwise |
| 16 */ |
| 17 inline bool set_subset_region(int inputOffset, int inputDimension, |
| 18 int imageOriginalDimension, int* imageSubsetOffset, int* outOffset, |
| 19 int* imageSubsetDimension) { |
| 20 |
| 21 // This must be at least zero, we can't start decoding the image at a negati
ve coordinate. |
| 22 *imageSubsetOffset = SkTMax(0, inputOffset); |
| 23 |
| 24 // If inputOffset is less than zero, we decode to an offset location in the
output bitmap. |
| 25 *outOffset = *imageSubsetOffset - inputOffset; |
| 26 |
| 27 // Use imageSusetOffset to make sure we don't decode pixels past the edge of
the image. |
| 28 // Use outOffset to make sure we don't decode pixels past the edge of the re
gion. |
| 29 *imageSubsetDimension = SkTMin(imageOriginalDimension - *imageSubsetOffset, |
| 30 inputDimension - *outOffset); |
| 31 |
| 32 return (*outOffset == 0) && (*imageSubsetDimension == inputDimension); |
| 33 } |
| 34 |
| 35 #endif // SkBitmapRegionDecoderPriv_DEFINED |
OLD | NEW |