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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/images/SkImageDecoder_libpng.h ('k') | src/images/SkImageDecoder_libwebp.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_libpng.cpp
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp
index 0890eaacaffacf8e4af3af71d38726c493294ba4..cff9d8bc655b65e0c8197a99d3febd450ef574dd 100644
--- a/src/images/SkImageDecoder_libpng.cpp
+++ b/src/images/SkImageDecoder_libpng.cpp
@@ -5,8 +5,7 @@
* found in the LICENSE file.
*/
-#include "SkImageDecoder.h"
-#include "SkImageEncoder.h"
+#include "SkImageDecoder_libpng.h"
#include "SkColor.h"
#include "SkColorPriv.h"
#include "SkDither.h"
@@ -1248,38 +1247,22 @@ bool SkPNGImageEncoder::doEncode(SkWStream* stream, const SkBitmap& bitmap,
return true;
}
-///////////////////////////////////////////////////////////////////////////////
-DEFINE_DECODER_CREATOR(PNGImageDecoder);
-DEFINE_ENCODER_CREATOR(PNGImageEncoder);
-///////////////////////////////////////////////////////////////////////////////
-
-static bool is_png(SkStreamRewindable* stream) {
+SkImageDecoder::Format SkDetectFormatPNGImageDecoder(SkStreamRewindable* stream) {
char buf[PNG_BYTES_TO_CHECK];
- if (stream->read(buf, PNG_BYTES_TO_CHECK) == PNG_BYTES_TO_CHECK &&
- !png_sig_cmp((png_bytep) buf, (png_size_t)0, PNG_BYTES_TO_CHECK)) {
- return true;
- }
- return false;
-}
-
-SkImageDecoder* sk_libpng_dfactory(SkStreamRewindable* stream) {
- if (is_png(stream)) {
- return SkNEW(SkPNGImageDecoder);
+ if (stream->read(buf, PNG_BYTES_TO_CHECK) == PNG_BYTES_TO_CHECK) {
+ if (0 == png_sig_cmp((png_bytep) buf, (png_size_t)0, PNG_BYTES_TO_CHECK)) {
+ return SkImageDecoder::kPNG_Format;
+ }
}
- return NULL;
+ return SkImageDecoder::kUnknown_Format;
}
-static SkImageDecoder::Format get_format_png(SkStreamRewindable* stream) {
- if (is_png(stream)) {
- return SkImageDecoder::kPNG_Format;
- }
- return SkImageDecoder::kUnknown_Format;
+SkImageDecoder* SkCreatePNGImageDecoder(SkImageDecoder::Format format) {
+ SkASSERT(SkImageDecoder::kPNG_Format == format);
+ return SkNEW(SkPNGImageDecoder);
}
-SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) {
+SkImageEncoder* SkCreatePNGImageEncoder(SkImageEncoder::Type t) {
return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL;
}
-static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory);
-static SkImageDecoder_FormatReg gFormatReg(get_format_png);
-static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory);
« 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