Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: src/images/SkImageDecoder_libjpeg.cpp

Issue 23453031: Rewrite SkTRegistry to take any trivially-copyable type. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: reed+scroggo Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/images/SkImageDecoder_libico.cpp ('k') | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libico.cpp ('k') | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698