blob: 81d485c882fef80dfa1227e2eb5273579226a71d [file] [log] [blame]
scroggo@google.com7def5e12013-05-31 14:00:10 +00001/*
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
msarette8597a42016-03-24 10:41:47 -07008#include "SkImageEncoder.h"
scroggo@google.com7def5e12013-05-31 14:00:10 +00009#include "SkForceLinking.h"
scroggo@google.com7def5e12013-05-31 14:00:10 +000010
11// This method is required to fool the linker into not discarding the pre-main
msarettc1d03122016-03-25 08:58:55 -070012// initialization and registration of the encoder classes. Passing true will
scroggo@google.com7def5e12013-05-31 14:00:10 +000013// cause memory leaks.
14int SkForceLinking(bool doNotPassTrue) {
15 if (doNotPassTrue) {
16 SkASSERT(false);
msarett36931c22016-08-16 15:11:24 -070017#if defined(SK_HAS_JPEG_LIBRARY) && !defined(SK_USE_CG_ENCODER) && !defined(SK_USE_WIC_ENCODER)
msarette8597a42016-03-24 10:41:47 -070018 CreateJPEGImageEncoder();
msarettad3a5c62016-05-06 07:21:26 -070019#endif
msarett36931c22016-08-16 15:11:24 -070020#if defined(SK_HAS_WEBP_LIBRARY) && !defined(SK_USE_CG_ENCODER) && !defined(SK_USE_WIC_ENCODER)
msarette8597a42016-03-24 10:41:47 -070021 CreateWEBPImageEncoder();
msarettad3a5c62016-05-06 07:21:26 -070022#endif
msarett36931c22016-08-16 15:11:24 -070023#if defined(SK_HAS_PNG_LIBRARY) && !defined(SK_USE_CG_ENCODER) && !defined(SK_USE_WIC_ENCODER)
24 CreatePNGImageEncoder();
25#endif
msarette8597a42016-03-24 10:41:47 -070026
djsollen748783d2014-08-28 12:04:41 -070027 // Only link hardware texture codecs on platforms that build them. See images.gyp
28#ifndef SK_BUILD_FOR_ANDROID_FRAMEWORK
msarette8597a42016-03-24 10:41:47 -070029 CreateKTXImageEncoder();
djsollen748783d2014-08-28 12:04:41 -070030#endif
msarette8597a42016-03-24 10:41:47 -070031
msarett36931c22016-08-16 15:11:24 -070032#if defined (SK_USE_CG_ENCODER)
33 CreateImageEncoder_CG(SkImageEncoder::kPNG_Type);
msarett39b54952016-03-23 12:26:29 -070034#endif
msarett36931c22016-08-16 15:11:24 -070035#if defined (SK_USE_WIC_ENCODER)
36 CreateImageEncoder_WIC(SkImageEncoder::kPNG_Type);
caryclark936b7342014-07-11 12:14:51 -070037#endif
scroggo@google.com7def5e12013-05-31 14:00:10 +000038 return -1;
39 }
40 return 0;
41}