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

Side by Side Diff: src/images/SkImageDecoder_libgif.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_libgif.h ('k') | src/images/SkImageDecoder_libico.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_libgif.h"
8 #include "SkColor.h" 9 #include "SkColor.h"
9 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
10 #include "SkColorTable.h" 11 #include "SkColorTable.h"
11 #include "SkImageDecoder.h"
12 #include "SkRTConf.h" 12 #include "SkRTConf.h"
13 #include "SkScaledBitmapSampler.h" 13 #include "SkScaledBitmapSampler.h"
14 #include "SkStream.h" 14 #include "SkStream.h"
15 #include "SkTemplates.h" 15 #include "SkTemplates.h"
16 #include "SkUtils.h" 16 #include "SkUtils.h"
17 17
18 #include "gif_lib.h" 18 #include "gif_lib.h"
19 19
20 class SkGIFImageDecoder : public SkImageDecoder { 20 class SkGIFImageDecoder : public SkImageDecoder {
21 public: 21 public:
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 495
496 default: /* Should be trapped by DGifGetRecordType */ 496 default: /* Should be trapped by DGifGetRecordType */
497 break; 497 break;
498 } 498 }
499 } while (recType != TERMINATE_RECORD_TYPE); 499 } while (recType != TERMINATE_RECORD_TYPE);
500 500
501 sanitize_indexed_bitmap(bm); 501 sanitize_indexed_bitmap(bm);
502 return kSuccess; 502 return kSuccess;
503 } 503 }
504 504
505 /////////////////////////////////////////////////////////////////////////////// 505 SkImageDecoder::Format SkDetectFormatGIFImageDecoder(SkStreamRewindable* stream) {
506 DEFINE_DECODER_CREATOR(GIFImageDecoder);
507 ///////////////////////////////////////////////////////////////////////////////
508
509 static bool is_gif(SkStreamRewindable* stream) {
510 char buf[GIF_STAMP_LEN]; 506 char buf[GIF_STAMP_LEN];
511 if (stream->read(buf, GIF_STAMP_LEN) == GIF_STAMP_LEN) { 507 if (stream->read(buf, GIF_STAMP_LEN) == GIF_STAMP_LEN) {
512 if (memcmp(GIF_STAMP, buf, GIF_STAMP_LEN) == 0 || 508 if (memcmp(GIF_STAMP, buf, GIF_STAMP_LEN) == 0 ||
513 memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 || 509 memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 ||
514 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) { 510 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) {
515 return true; 511 return SkImageDecoder::kGIF_Format;
516 } 512 }
517 } 513 }
518 return false;
519 }
520
521 static SkImageDecoder* sk_libgif_dfactory(SkStreamRewindable* stream) {
522 if (is_gif(stream)) {
523 return SkNEW(SkGIFImageDecoder);
524 }
525 return NULL;
526 }
527
528 static SkImageDecoder_DecodeReg gReg(sk_libgif_dfactory);
529
530 static SkImageDecoder::Format get_format_gif(SkStreamRewindable* stream) {
531 if (is_gif(stream)) {
532 return SkImageDecoder::kGIF_Format;
533 }
534 return SkImageDecoder::kUnknown_Format; 514 return SkImageDecoder::kUnknown_Format;
535 } 515 }
536 516
537 static SkImageDecoder_FormatReg gFormatReg(get_format_gif); 517 SkImageDecoder* SkCreateGIFImageDecoder(SkImageDecoder::Format format) {
518 SkASSERT(SkImageDecoder::kGIF_Format == format);
519 return SkNEW(SkGIFImageDecoder);
520 }
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libgif.h ('k') | src/images/SkImageDecoder_libico.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698