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

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

Issue 23477009: Change SkImageDecoders to take an SkStreamRewindable. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Only switch to SkStreamRewindable when necessary. Created 7 years, 2 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_libbmp.cpp ('k') | src/images/SkImageDecoder_libico.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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } while (recType != TERMINATE_RECORD_TYPE); 349 } while (recType != TERMINATE_RECORD_TYPE);
350 350
351 DONE: 351 DONE:
352 return true; 352 return true;
353 } 353 }
354 354
355 /////////////////////////////////////////////////////////////////////////////// 355 ///////////////////////////////////////////////////////////////////////////////
356 DEFINE_DECODER_CREATOR(GIFImageDecoder); 356 DEFINE_DECODER_CREATOR(GIFImageDecoder);
357 /////////////////////////////////////////////////////////////////////////////// 357 ///////////////////////////////////////////////////////////////////////////////
358 358
359 static bool is_gif(SkStream* stream) { 359 static bool is_gif(SkStreamRewindable* stream) {
360 char buf[GIF_STAMP_LEN]; 360 char buf[GIF_STAMP_LEN];
361 if (stream->read(buf, GIF_STAMP_LEN) == GIF_STAMP_LEN) { 361 if (stream->read(buf, GIF_STAMP_LEN) == GIF_STAMP_LEN) {
362 if (memcmp(GIF_STAMP, buf, GIF_STAMP_LEN) == 0 || 362 if (memcmp(GIF_STAMP, buf, GIF_STAMP_LEN) == 0 ||
363 memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 || 363 memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 ||
364 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) { 364 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) {
365 return true; 365 return true;
366 } 366 }
367 } 367 }
368 return false; 368 return false;
369 } 369 }
370 370
371 static SkImageDecoder* sk_libgif_dfactory(SkStream* stream) { 371 static SkImageDecoder* sk_libgif_dfactory(SkStreamRewindable* stream) {
372 if (is_gif(stream)) { 372 if (is_gif(stream)) {
373 return SkNEW(SkGIFImageDecoder); 373 return SkNEW(SkGIFImageDecoder);
374 } 374 }
375 return NULL; 375 return NULL;
376 } 376 }
377 377
378 static SkImageDecoder_DecodeReg gReg(sk_libgif_dfactory); 378 static SkImageDecoder_DecodeReg gReg(sk_libgif_dfactory);
379 379
380 static SkImageDecoder::Format get_format_gif(SkStream* stream) { 380 static SkImageDecoder::Format get_format_gif(SkStreamRewindable* stream) {
381 if (is_gif(stream)) { 381 if (is_gif(stream)) {
382 return SkImageDecoder::kGIF_Format; 382 return SkImageDecoder::kGIF_Format;
383 } 383 }
384 return SkImageDecoder::kUnknown_Format; 384 return SkImageDecoder::kUnknown_Format;
385 } 385 }
386 386
387 static SkImageDecoder_FormatReg gFormatReg(get_format_gif); 387 static SkImageDecoder_FormatReg gFormatReg(get_format_gif);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libbmp.cpp ('k') | src/images/SkImageDecoder_libico.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698