scroggo@google.com | 7def5e1 | 2013-05-31 14:00:10 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 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 | |
msarett | e8597a4 | 2016-03-24 10:41:47 -0700 | [diff] [blame] | 8 | #include "SkImageEncoder.h" |
scroggo@google.com | 7def5e1 | 2013-05-31 14:00:10 +0000 | [diff] [blame] | 9 | #include "SkForceLinking.h" |
scroggo@google.com | 7def5e1 | 2013-05-31 14:00:10 +0000 | [diff] [blame] | 10 | |
| 11 | // This method is required to fool the linker into not discarding the pre-main |
msarett | c1d0312 | 2016-03-25 08:58:55 -0700 | [diff] [blame] | 12 | // initialization and registration of the encoder classes. Passing true will |
scroggo@google.com | 7def5e1 | 2013-05-31 14:00:10 +0000 | [diff] [blame] | 13 | // cause memory leaks. |
| 14 | int SkForceLinking(bool doNotPassTrue) { |
| 15 | if (doNotPassTrue) { |
| 16 | SkASSERT(false); |
msarett | 36931c2 | 2016-08-16 15:11:24 -0700 | [diff] [blame] | 17 | #if defined(SK_HAS_JPEG_LIBRARY) && !defined(SK_USE_CG_ENCODER) && !defined(SK_USE_WIC_ENCODER) |
msarett | e8597a4 | 2016-03-24 10:41:47 -0700 | [diff] [blame] | 18 | CreateJPEGImageEncoder(); |
msarett | ad3a5c6 | 2016-05-06 07:21:26 -0700 | [diff] [blame] | 19 | #endif |
msarett | 36931c2 | 2016-08-16 15:11:24 -0700 | [diff] [blame] | 20 | #if defined(SK_HAS_WEBP_LIBRARY) && !defined(SK_USE_CG_ENCODER) && !defined(SK_USE_WIC_ENCODER) |
msarett | e8597a4 | 2016-03-24 10:41:47 -0700 | [diff] [blame] | 21 | CreateWEBPImageEncoder(); |
msarett | ad3a5c6 | 2016-05-06 07:21:26 -0700 | [diff] [blame] | 22 | #endif |
msarett | 36931c2 | 2016-08-16 15:11:24 -0700 | [diff] [blame] | 23 | #if defined(SK_HAS_PNG_LIBRARY) && !defined(SK_USE_CG_ENCODER) && !defined(SK_USE_WIC_ENCODER) |
| 24 | CreatePNGImageEncoder(); |
| 25 | #endif |
msarett | e8597a4 | 2016-03-24 10:41:47 -0700 | [diff] [blame] | 26 | |
djsollen | 748783d | 2014-08-28 12:04:41 -0700 | [diff] [blame] | 27 | // Only link hardware texture codecs on platforms that build them. See images.gyp |
| 28 | #ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK |
msarett | e8597a4 | 2016-03-24 10:41:47 -0700 | [diff] [blame] | 29 | CreateKTXImageEncoder(); |
djsollen | 748783d | 2014-08-28 12:04:41 -0700 | [diff] [blame] | 30 | #endif |
msarett | e8597a4 | 2016-03-24 10:41:47 -0700 | [diff] [blame] | 31 | |
msarett | 36931c2 | 2016-08-16 15:11:24 -0700 | [diff] [blame] | 32 | #if defined (SK_USE_CG_ENCODER) |
| 33 | CreateImageEncoder_CG(SkImageEncoder::kPNG_Type); |
msarett | 39b5495 | 2016-03-23 12:26:29 -0700 | [diff] [blame] | 34 | #endif |
msarett | 36931c2 | 2016-08-16 15:11:24 -0700 | [diff] [blame] | 35 | #if defined (SK_USE_WIC_ENCODER) |
| 36 | CreateImageEncoder_WIC(SkImageEncoder::kPNG_Type); |
caryclark | 936b734 | 2014-07-11 12:14:51 -0700 | [diff] [blame] | 37 | #endif |
scroggo@google.com | 7def5e1 | 2013-05-31 14:00:10 +0000 | [diff] [blame] | 38 | return -1; |
| 39 | } |
| 40 | return 0; |
| 41 | } |