diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-23 18:13:47 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-23 18:13:47 +0000 |
commit | ec51cb863409e238b40c5beef458669d9a824481 (patch) | |
tree | 224efaf870e226bf8f95612ab3dda9bc03284ae8 /include | |
parent | 34f10260adb55301572d4e67414b747c83ee015a (diff) |
Improved codec link-forcing system by adding Encoder/Decoder creation entry points
http://codereview.appspot.com/5881055/
git-svn-id: http://skia.googlecode.com/svn/trunk@3481 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/images/SkImageDecoder.h | 20 | ||||
-rw-r--r-- | include/images/SkImageEncoder.h | 17 |
2 files changed, 37 insertions, 0 deletions
diff --git a/include/images/SkImageDecoder.h b/include/images/SkImageDecoder.h index cbae8b1721..d0c4d21ddc 100644 --- a/include/images/SkImageDecoder.h +++ b/include/images/SkImageDecoder.h @@ -332,5 +332,25 @@ public: } }; +// This macro declares a global (i.e., non-class owned) creation entry point +// for each decoder (e.g., CreateJPEGImageDecoder) +#define DECLARE_DECODER_CREATOR(codec) \ + SkImageDecoder *Create ## codec (); + +// This macro defines the global creation entry point for each decoder. Each +// decoder implementation that registers with the decoder factory must call it. +#define DEFINE_DECODER_CREATOR(codec) \ + SkImageDecoder *Create ## codec () { \ + return SkNEW( Sk ## codec ); \ + } + +// All the decoders known by Skia. Note that, depending on the compiler settings, +// not all of these will be available +DECLARE_DECODER_CREATOR(BMPImageDecoder); +DECLARE_DECODER_CREATOR(GIFImageDecoder); +DECLARE_DECODER_CREATOR(ICOImageDecoder); +DECLARE_DECODER_CREATOR(JPEGImageDecoder); +DECLARE_DECODER_CREATOR(PNGImageDecoder); +DECLARE_DECODER_CREATOR(WBMPImageDecoder); #endif diff --git a/include/images/SkImageEncoder.h b/include/images/SkImageEncoder.h index b2f8cb67cc..907e28b9de 100644 --- a/include/images/SkImageEncoder.h +++ b/include/images/SkImageEncoder.h @@ -40,4 +40,21 @@ protected: virtual bool onEncode(SkWStream*, const SkBitmap&, int quality) = 0; }; +// This macro declares a global (i.e., non-class owned) creation entry point +// for each encoder (e.g., CreateJPEGImageEncoder) +#define DECLARE_ENCODER_CREATOR(codec) \ + SkImageEncoder *Create ## codec (); + +// This macro defines the global creation entry point for each encoder. Each +// encoder implementation that registers with the encoder factory must call it. +#define DEFINE_ENCODER_CREATOR(codec) \ + SkImageEncoder *Create ## codec () { \ + return SkNEW( Sk ## codec ); \ + } + +// All the encoders known by Skia. Note that, depending on the compiler settings, +// not all of these will be available +DECLARE_ENCODER_CREATOR(JPEGImageEncoder); +DECLARE_ENCODER_CREATOR(PNGImageEncoder); + #endif |