| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The Android Open Source Project | 2 * Copyright 2015 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkCodecPriv_DEFINED | 8 #ifndef SkCodecPriv_DEFINED |
| 9 #define SkCodecPriv_DEFINED | 9 #define SkCodecPriv_DEFINED |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 uint8_t zeroAlpha = 0; \ | 24 uint8_t zeroAlpha = 0; \ |
| 25 uint8_t maxAlpha = 0xFF; | 25 uint8_t maxAlpha = 0xFF; |
| 26 | 26 |
| 27 #define UPDATE_RESULT_ALPHA(alpha) \ | 27 #define UPDATE_RESULT_ALPHA(alpha) \ |
| 28 zeroAlpha |= (alpha); \ | 28 zeroAlpha |= (alpha); \ |
| 29 maxAlpha &= (alpha); | 29 maxAlpha &= (alpha); |
| 30 | 30 |
| 31 #define COMPUTE_RESULT_ALPHA \ | 31 #define COMPUTE_RESULT_ALPHA \ |
| 32 SkSwizzler::GetResult(zeroAlpha, maxAlpha); | 32 SkSwizzler::GetResult(zeroAlpha, maxAlpha); |
| 33 | 33 |
| 34 // FIXME: Consider sharing with dm, nanbench, and tools. |
| 35 inline float get_scale_from_sample_size(int sampleSize) { |
| 36 return 1.0f / ((float) sampleSize); |
| 37 } |
| 38 |
| 39 inline bool is_valid_subset(const SkIRect& subset, const SkISize& imageDims) { |
| 40 return SkIRect::MakeSize(imageDims).contains(subset); |
| 41 } |
| 42 |
| 34 /* | 43 /* |
| 35 * returns a scaled dimension based on the original dimension and the sampleSize | 44 * returns a scaled dimension based on the original dimension and the sampleSize |
| 36 * NOTE: we round down here for scaled dimension to match the behavior of SkImag
eDecoder | 45 * NOTE: we round down here for scaled dimension to match the behavior of SkImag
eDecoder |
| 46 * FIXME: I think we should call this get_sampled_dimension(). |
| 37 */ | 47 */ |
| 38 inline int get_scaled_dimension(int srcDimension, int sampleSize) { | 48 inline int get_scaled_dimension(int srcDimension, int sampleSize) { |
| 39 if (sampleSize > srcDimension) { | 49 if (sampleSize > srcDimension) { |
| 40 return 1; | 50 return 1; |
| 41 } | 51 } |
| 42 return srcDimension / sampleSize; | 52 return srcDimension / sampleSize; |
| 43 } | 53 } |
| 44 | 54 |
| 45 /* | 55 /* |
| 46 * Returns the first coordinate that we will keep during a scaled decode. | 56 * Returns the first coordinate that we will keep during a scaled decode. |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 #endif | 247 #endif |
| 238 } | 248 } |
| 239 | 249 |
| 240 #ifdef SK_PRINT_CODEC_MESSAGES | 250 #ifdef SK_PRINT_CODEC_MESSAGES |
| 241 #define SkCodecPrintf SkDebugf | 251 #define SkCodecPrintf SkDebugf |
| 242 #else | 252 #else |
| 243 #define SkCodecPrintf(...) | 253 #define SkCodecPrintf(...) |
| 244 #endif | 254 #endif |
| 245 | 255 |
| 246 #endif // SkCodecPriv_DEFINED | 256 #endif // SkCodecPriv_DEFINED |
| OLD | NEW |