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

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

Issue 670453002: Remove image decoder and encoder autoregistration (Closed) Base URL: https://skia.googlesource.com/skia.git@separate-image-decoder-01-skpicture
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « src/images/SkImageDecoder_libpng.h ('k') | src/images/SkImageDecoder_libwebp.h » ('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 2006 The Android Open Source Project 2 * Copyright 2006 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 #include "SkImageDecoder.h" 8 #include "SkImageDecoder_libpng.h"
9 #include "SkImageEncoder.h"
10 #include "SkColor.h" 9 #include "SkColor.h"
11 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
12 #include "SkDither.h" 11 #include "SkDither.h"
13 #include "SkMath.h" 12 #include "SkMath.h"
14 #include "SkRTConf.h" 13 #include "SkRTConf.h"
15 #include "SkScaledBitmapSampler.h" 14 #include "SkScaledBitmapSampler.h"
16 #include "SkStream.h" 15 #include "SkStream.h"
17 #include "SkTemplates.h" 16 #include "SkTemplates.h"
18 #include "SkUtils.h" 17 #include "SkUtils.h"
19 #include "transform_scanline.h" 18 #include "transform_scanline.h"
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 srcImage += bitmap.rowBytes(); 1240 srcImage += bitmap.rowBytes();
1242 } 1241 }
1243 1242
1244 png_write_end(png_ptr, info_ptr); 1243 png_write_end(png_ptr, info_ptr);
1245 1244
1246 /* clean up after the write, and free any memory allocated */ 1245 /* clean up after the write, and free any memory allocated */
1247 png_destroy_write_struct(&png_ptr, &info_ptr); 1246 png_destroy_write_struct(&png_ptr, &info_ptr);
1248 return true; 1247 return true;
1249 } 1248 }
1250 1249
1251 /////////////////////////////////////////////////////////////////////////////// 1250 SkImageDecoder::Format SkDetectFormatPNGImageDecoder(SkStreamRewindable* stream) {
1252 DEFINE_DECODER_CREATOR(PNGImageDecoder);
1253 DEFINE_ENCODER_CREATOR(PNGImageEncoder);
1254 ///////////////////////////////////////////////////////////////////////////////
1255
1256 static bool is_png(SkStreamRewindable* stream) {
1257 char buf[PNG_BYTES_TO_CHECK]; 1251 char buf[PNG_BYTES_TO_CHECK];
1258 if (stream->read(buf, PNG_BYTES_TO_CHECK) == PNG_BYTES_TO_CHECK && 1252 if (stream->read(buf, PNG_BYTES_TO_CHECK) == PNG_BYTES_TO_CHECK) {
1259 !png_sig_cmp((png_bytep) buf, (png_size_t)0, PNG_BYTES_TO_CHECK)) { 1253 if (0 == png_sig_cmp((png_bytep) buf, (png_size_t)0, PNG_BYTES_TO_CHECK) ) {
1260 return true; 1254 return SkImageDecoder::kPNG_Format;
1261 } 1255 }
1262 return false;
1263 }
1264
1265 SkImageDecoder* sk_libpng_dfactory(SkStreamRewindable* stream) {
1266 if (is_png(stream)) {
1267 return SkNEW(SkPNGImageDecoder);
1268 }
1269 return NULL;
1270 }
1271
1272 static SkImageDecoder::Format get_format_png(SkStreamRewindable* stream) {
1273 if (is_png(stream)) {
1274 return SkImageDecoder::kPNG_Format;
1275 } 1256 }
1276 return SkImageDecoder::kUnknown_Format; 1257 return SkImageDecoder::kUnknown_Format;
1277 } 1258 }
1278 1259
1279 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { 1260 SkImageDecoder* SkCreatePNGImageDecoder(SkImageDecoder::Format format) {
1261 SkASSERT(SkImageDecoder::kPNG_Format == format);
1262 return SkNEW(SkPNGImageDecoder);
1263 }
1264
1265 SkImageEncoder* SkCreatePNGImageEncoder(SkImageEncoder::Type t) {
1280 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; 1266 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL;
1281 } 1267 }
1282 1268
1283 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory);
1284 static SkImageDecoder_FormatReg gFormatReg(get_format_png);
1285 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libpng.h ('k') | src/images/SkImageDecoder_libwebp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698