Hal Canary | db68301 | 2016-11-23 08:55:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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 SkImageEncoderPriv_DEFINED |
| 9 | #define SkImageEncoderPriv_DEFINED |
| 10 | |
| 11 | #include "SkImageEncoder.h" |
Matt Sarett | c367d03 | 2017-05-05 11:13:26 -0400 | [diff] [blame] | 12 | #include "SkImageInfoPriv.h" |
| 13 | |
| 14 | static inline bool SkPixmapIsValid(const SkPixmap& src, |
| 15 | SkTransferFunctionBehavior unpremulBehavior) |
| 16 | { |
| 17 | if (SkTransferFunctionBehavior::kRespect == unpremulBehavior) { |
| 18 | if (!SkImageInfoIsValidRenderingCS(src.info())) { |
| 19 | return false; |
| 20 | } |
| 21 | } else { |
| 22 | if (!SkImageInfoIsValidAllowNumericalCS(src.info())) { |
| 23 | return false; |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | if (!src.addr() || src.rowBytes() < src.info().minRowBytes()) { |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | return true; |
| 32 | } |
Hal Canary | db68301 | 2016-11-23 08:55:18 -0700 | [diff] [blame] | 33 | |
Hal Canary | db68301 | 2016-11-23 08:55:18 -0700 | [diff] [blame] | 34 | #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) |
Hal Canary | 1fcc404 | 2016-11-30 17:07:59 -0500 | [diff] [blame] | 35 | bool SkEncodeImageWithCG(SkWStream*, const SkPixmap&, SkEncodedImageFormat); |
| 36 | #else |
| 37 | #define SkEncodeImageWithCG(...) false |
Hal Canary | db68301 | 2016-11-23 08:55:18 -0700 | [diff] [blame] | 38 | #endif |
| 39 | |
Hal Canary | 1fcc404 | 2016-11-30 17:07:59 -0500 | [diff] [blame] | 40 | #ifdef SK_BUILD_FOR_WIN |
| 41 | bool SkEncodeImageWithWIC(SkWStream*, const SkPixmap&, SkEncodedImageFormat, int quality); |
| 42 | #else |
| 43 | #define SkEncodeImageWithWIC(...) false |
Hal Canary | db68301 | 2016-11-23 08:55:18 -0700 | [diff] [blame] | 44 | #endif |
| 45 | |
Hal Canary | db68301 | 2016-11-23 08:55:18 -0700 | [diff] [blame] | 46 | #endif // SkImageEncoderPriv_DEFINED |