• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "include/core/SkImageInfo.h"
12 #include "include/core/SkPixmap.h"
13 #include "src/core/SkImageInfoPriv.h"
14 
15 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) || \
16     defined(SK_BUILD_FOR_WIN) || defined(SK_ENABLE_NDK_IMAGES)
17 #include "include/core/SkEncodedImageFormat.h"
18 class SkWStream;
19 #endif
20 
SkPixmapIsValid(const SkPixmap & src)21 static inline bool SkPixmapIsValid(const SkPixmap& src) {
22     if (!SkImageInfoIsValid(src.info())) {
23         return false;
24     }
25 
26     if (!src.addr() || src.rowBytes() < src.info().minRowBytes()) {
27         return false;
28     }
29 
30     return true;
31 }
32 
33 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
34     bool SkEncodeImageWithCG(SkWStream*, const SkPixmap&, SkEncodedImageFormat);
35 #else
36     #define SkEncodeImageWithCG(...) false
37 #endif
38 
39 #ifdef SK_BUILD_FOR_WIN
40     bool SkEncodeImageWithWIC(SkWStream*, const SkPixmap&, SkEncodedImageFormat, int quality);
41 #else
42     #define SkEncodeImageWithWIC(...) false
43 #endif
44 
45 #ifdef SK_ENABLE_NDK_IMAGES
46     bool SkEncodeImageWithNDK(SkWStream*, const SkPixmap&, SkEncodedImageFormat, int quality);
47 #else
48     #define SkEncodeImageWithNDK(...) false
49 #endif
50 
51 #endif // SkImageEncoderPriv_DEFINED
52