Home | History | Annotate | Download | only in images
      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"
     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 }
     33 
     34 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
     35     bool SkEncodeImageWithCG(SkWStream*, const SkPixmap&, SkEncodedImageFormat);
     36 #else
     37     #define SkEncodeImageWithCG(...) false
     38 #endif
     39 
     40 #ifdef SK_BUILD_FOR_WIN
     41     bool SkEncodeImageWithWIC(SkWStream*, const SkPixmap&, SkEncodedImageFormat, int quality);
     42 #else
     43     #define SkEncodeImageWithWIC(...) false
     44 #endif
     45 
     46 #endif // SkImageEncoderPriv_DEFINED
     47