OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2007 The Android Open Source Project | 2 * Copyright 2007 The Android Open Source Project |
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 | 8 |
9 #include "SkImageDecoder.h" | 9 #include "SkImageDecoder.h" |
10 #include "SkImageEncoder.h" | 10 #include "SkImageEncoder.h" |
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 | 1129 |
1130 if (len != HEADER_SIZE) { | 1130 if (len != HEADER_SIZE) { |
1131 return false; // can't read enough | 1131 return false; // can't read enough |
1132 } | 1132 } |
1133 if (memcmp(buffer, gHeader, HEADER_SIZE)) { | 1133 if (memcmp(buffer, gHeader, HEADER_SIZE)) { |
1134 return false; | 1134 return false; |
1135 } | 1135 } |
1136 return true; | 1136 return true; |
1137 } | 1137 } |
1138 | 1138 |
1139 #include "SkTRegistry.h" | |
1140 | |
1141 static SkImageDecoder* sk_libjpeg_dfactory(SkStream* stream) { | 1139 static SkImageDecoder* sk_libjpeg_dfactory(SkStream* stream) { |
1142 if (is_jpeg(stream)) { | 1140 if (is_jpeg(stream)) { |
1143 return SkNEW(SkJPEGImageDecoder); | 1141 return SkNEW(SkJPEGImageDecoder); |
1144 } | 1142 } |
1145 return NULL; | 1143 return NULL; |
1146 } | 1144 } |
1147 | 1145 |
1148 static SkImageDecoder::Format get_format_jpeg(SkStream* stream) { | 1146 static SkImageDecoder::Format get_format_jpeg(SkStream* stream) { |
1149 if (is_jpeg(stream)) { | 1147 if (is_jpeg(stream)) { |
1150 return SkImageDecoder::kJPEG_Format; | 1148 return SkImageDecoder::kJPEG_Format; |
1151 } | 1149 } |
1152 return SkImageDecoder::kUnknown_Format; | 1150 return SkImageDecoder::kUnknown_Format; |
1153 } | 1151 } |
1154 | 1152 |
1155 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { | 1153 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { |
1156 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; | 1154 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; |
1157 } | 1155 } |
1158 | 1156 |
1159 | 1157 |
1160 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libjpeg_dfactory); | 1158 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory); |
1161 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_jpeg
); | 1159 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg); |
1162 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libjpeg_efact
ory); | 1160 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory); |
OLD | NEW |