1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/images/SkForceLinking.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,33 @@ 1.4 +/* 1.5 + * Copyright 2013 Google Inc. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license that can be 1.8 + * found in the LICENSE file. 1.9 + */ 1.10 + 1.11 +#include "SkForceLinking.h" 1.12 +#include "SkImageDecoder.h" 1.13 + 1.14 +// This method is required to fool the linker into not discarding the pre-main 1.15 +// initialization and registration of the decoder classes. Passing true will 1.16 +// cause memory leaks. 1.17 +int SkForceLinking(bool doNotPassTrue) { 1.18 + if (doNotPassTrue) { 1.19 + SkASSERT(false); 1.20 + CreateJPEGImageDecoder(); 1.21 + CreateWEBPImageDecoder(); 1.22 + CreateBMPImageDecoder(); 1.23 + CreateICOImageDecoder(); 1.24 + CreateWBMPImageDecoder(); 1.25 + // Only link GIF and PNG on platforms that build them. See images.gyp 1.26 +#if !defined(SK_BUILD_FOR_MAC) && !defined(SK_BUILD_FOR_WIN) && !defined(SK_BUILD_FOR_NACL) \ 1.27 + && !defined(SK_BUILD_FOR_IOS) 1.28 + CreateGIFImageDecoder(); 1.29 +#endif 1.30 +#if !defined(SK_BUILD_FOR_MAC) && !defined(SK_BUILD_FOR_WIN) && !defined(SK_BUILD_FOR_IOS) 1.31 + CreatePNGImageDecoder(); 1.32 +#endif 1.33 + return -1; 1.34 + } 1.35 + return 0; 1.36 +}