Force linking with image decoders for images project.

Previously, each tool that wanted to use image decoders
but did not specifically reference them had to create a
dummy function that references them in order to ensure
they are not stripped by the linker.

Instead of making each tool reference each image decoder,
do it once in SkImageDecoder.cpp. Now each tool will have
image decoders linked in, assuming it includes the images
project.

This fixes a bug where SKPs with encoded data could not
be read by bench_ or render_pictures.

R=djsollen@google.com, robertphillips@google.com

Review URL: https://codereview.chromium.org/14678003

git-svn-id: http://skia.googlecode.com/svn/trunk@8941 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp
index 16cba64..2c3edc8 100644
--- a/src/images/SkImageDecoder.cpp
+++ b/src/images/SkImageDecoder.cpp
@@ -339,3 +339,28 @@
     }
     return success;
 }
+
+namespace {
+    /**
+     *  This function leaks, but that is okay because it is not intended
+     *  to be called. It is only here so that the linker will include the
+     *  decoders.
+     *  Make sure to keep it in sync with images.gyp, so only the encoders
+     *  which are created on a platform are linked.
+     */
+    void force_linking() {
+        SkASSERT(false);
+        CreateJPEGImageDecoder();
+        CreateWEBPImageDecoder();
+        CreateBMPImageDecoder();
+        CreateICOImageDecoder();
+        CreateWBMPImageDecoder();
+        // Only link GIF and PNG on platforms that build them. See images.gyp
+#if !defined(SK_BUILD_FOR_MAC) && !defined(SK_BUILD_FOR_WIN) && !defined(SK_BUILD_FOR_NACL)
+        CreateGIFImageDecoder();
+#endif
+#if !defined(SK_BUILD_FOR_MAC) && !defined(SK_BUILD_FOR_WIN)
+        CreatePNGImageDecoder();
+#endif
+    }
+}