| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkImageEncoder_DEFINED | 8 #ifndef SkImageEncoder_DEFINED |
| 9 #define SkImageEncoder_DEFINED | 9 #define SkImageEncoder_DEFINED |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality) =
0; | 80 virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality) =
0; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 // This macro declares a global (i.e., non-class owned) creation entry point | 83 // This macro declares a global (i.e., non-class owned) creation entry point |
| 84 // for each encoder (e.g., CreateJPEGImageEncoder) | 84 // for each encoder (e.g., CreateJPEGImageEncoder) |
| 85 #define DECLARE_ENCODER_CREATOR(codec) \ | 85 #define DECLARE_ENCODER_CREATOR(codec) \ |
| 86 SkImageEncoder *Create ## codec (); | 86 SkImageEncoder *Create ## codec (); |
| 87 | 87 |
| 88 // This macro defines the global creation entry point for each encoder. Each | 88 // This macro defines the global creation entry point for each encoder. Each |
| 89 // encoder implementation that registers with the encoder factory must call it. | 89 // encoder implementation that registers with the encoder factory must call it. |
| 90 #define DEFINE_ENCODER_CREATOR(codec) \ | 90 #define DEFINE_ENCODER_CREATOR(codec) \ |
| 91 SkImageEncoder *Create ## codec () { \ | 91 SkImageEncoder* Create##codec() { return new Sk##codec; } |
| 92 return SkNEW( Sk ## codec ); \ | |
| 93 } | |
| 94 | 92 |
| 95 // All the encoders known by Skia. Note that, depending on the compiler settings
, | 93 // All the encoders known by Skia. Note that, depending on the compiler settings
, |
| 96 // not all of these will be available | 94 // not all of these will be available |
| 97 /** An ARGBImageEncoder will always write out | 95 /** An ARGBImageEncoder will always write out |
| 98 * bitmap.width() * bitmap.height() * 4 | 96 * bitmap.width() * bitmap.height() * 4 |
| 99 * bytes. | 97 * bytes. |
| 100 */ | 98 */ |
| 101 DECLARE_ENCODER_CREATOR(ARGBImageEncoder); | 99 DECLARE_ENCODER_CREATOR(ARGBImageEncoder); |
| 102 DECLARE_ENCODER_CREATOR(JPEGImageEncoder); | 100 DECLARE_ENCODER_CREATOR(JPEGImageEncoder); |
| 103 DECLARE_ENCODER_CREATOR(PNGImageEncoder); | 101 DECLARE_ENCODER_CREATOR(PNGImageEncoder); |
| 104 DECLARE_ENCODER_CREATOR(KTXImageEncoder); | 102 DECLARE_ENCODER_CREATOR(KTXImageEncoder); |
| 105 DECLARE_ENCODER_CREATOR(WEBPImageEncoder); | 103 DECLARE_ENCODER_CREATOR(WEBPImageEncoder); |
| 106 | 104 |
| 107 #ifdef SK_BUILD_FOR_IOS | 105 #ifdef SK_BUILD_FOR_IOS |
| 108 DECLARE_ENCODER_CREATOR(PNGImageEncoder_IOS); | 106 DECLARE_ENCODER_CREATOR(PNGImageEncoder_IOS); |
| 109 #endif | 107 #endif |
| 110 | 108 |
| 111 // Typedef to make registering encoder callback easier | 109 // Typedef to make registering encoder callback easier |
| 112 // This has to be defined outside SkImageEncoder. :( | 110 // This has to be defined outside SkImageEncoder. :( |
| 113 typedef SkTRegistry<SkImageEncoder*(*)(SkImageEncoder::Type)> SkImageEncoder_Enc
odeReg; | 111 typedef SkTRegistry<SkImageEncoder*(*)(SkImageEncoder::Type)> SkImageEncoder_Enc
odeReg; |
| 114 #endif | 112 #endif |
| OLD | NEW |