epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@android.com | b08eb2b | 2009-01-06 20:16:26 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2009 The Android Open Source Project |
reed@android.com | b08eb2b | 2009-01-06 20:16:26 +0000 | [diff] [blame] | 4 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
reed@android.com | b08eb2b | 2009-01-06 20:16:26 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
reed@android.com | b08eb2b | 2009-01-06 20:16:26 +0000 | [diff] [blame] | 10 | #include "SkImageEncoder.h" |
reed@android.com | 00bf85a | 2009-01-22 13:04:56 +0000 | [diff] [blame] | 11 | #include "SkTRegistry.h" |
reed@android.com | b08eb2b | 2009-01-06 20:16:26 +0000 | [diff] [blame] | 12 | |
reed@android.com | 00bf85a | 2009-01-22 13:04:56 +0000 | [diff] [blame] | 13 | typedef SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> EncodeReg; |
reed@android.com | b08eb2b | 2009-01-06 20:16:26 +0000 | [diff] [blame] | 14 | |
tomhudson@google.com | a87cd2a | 2011-06-15 16:50:27 +0000 | [diff] [blame] | 15 | // Can't use the typedef here because of complex C++ corner cases |
| 16 | template EncodeReg* SkTRegistry<SkImageEncoder*, SkImageEncoder::Type>::gHead; |
reed@android.com | 3c2b7e8 | 2009-01-27 01:43:36 +0000 | [diff] [blame] | 17 | |
reed@android.com | dfee579 | 2010-04-15 14:24:50 +0000 | [diff] [blame] | 18 | #ifdef SK_ENABLE_LIBPNG |
| 19 | extern SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type); |
| 20 | #endif |
| 21 | |
reed@android.com | b08eb2b | 2009-01-06 20:16:26 +0000 | [diff] [blame] | 22 | SkImageEncoder* SkImageEncoder::Create(Type t) { |
reed@android.com | dfee579 | 2010-04-15 14:24:50 +0000 | [diff] [blame] | 23 | SkImageEncoder* codec = NULL; |
reed@android.com | 00bf85a | 2009-01-22 13:04:56 +0000 | [diff] [blame] | 24 | const EncodeReg* curr = EncodeReg::Head(); |
| 25 | while (curr) { |
reed@android.com | dfee579 | 2010-04-15 14:24:50 +0000 | [diff] [blame] | 26 | if ((codec = curr->factory()(t)) != NULL) { |
reed@android.com | 00bf85a | 2009-01-22 13:04:56 +0000 | [diff] [blame] | 27 | return codec; |
| 28 | } |
| 29 | curr = curr->next(); |
reed@android.com | b08eb2b | 2009-01-06 20:16:26 +0000 | [diff] [blame] | 30 | } |
reed@android.com | dfee579 | 2010-04-15 14:24:50 +0000 | [diff] [blame] | 31 | #ifdef SK_ENABLE_LIBPNG |
| 32 | if ((codec = sk_libpng_efactory(t)) != NULL) { |
| 33 | return codec; |
| 34 | } |
| 35 | #endif |
reed@android.com | 00bf85a | 2009-01-22 13:04:56 +0000 | [diff] [blame] | 36 | return NULL; |
reed@android.com | b08eb2b | 2009-01-06 20:16:26 +0000 | [diff] [blame] | 37 | } |