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

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

Issue 14298010: Updates to images project. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Name changes Created 7 years, 8 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_FactoryDefault.cpp ('k') | src/ports/SkImageDecoder_CG.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
2 /* 1 /*
3 * Copyright 2006 The Android Open Source Project 2 * Copyright 2013 The Android Open Source Project
4 * 3 *
5 * 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
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9
10 #include "SkImageDecoder.h" 8 #include "SkImageDecoder.h"
11 #include "SkMovie.h"
12 #include "SkStream.h" 9 #include "SkStream.h"
13 #include "SkTRegistry.h" 10 #include "SkTRegistry.h"
14 11
12 // This file is used for registration of SkImageDecoders. It also holds a functi on
13 // for checking all the the registered SkImageDecoders for one that matches an
14 // input SkStream.
15
15 typedef SkTRegistry<SkImageDecoder*, SkStream*> DecodeReg; 16 typedef SkTRegistry<SkImageDecoder*, SkStream*> DecodeReg;
16 17
17 // N.B. You can't use "DecodeReg::gHead here" due to complex C++ 18 // N.B. You can't use "DecodeReg::gHead here" due to complex C++
18 // corner cases. 19 // corner cases.
19 template DecodeReg* SkTRegistry<SkImageDecoder*, SkStream*>::gHead; 20 template DecodeReg* SkTRegistry<SkImageDecoder*, SkStream*>::gHead;
20 21
21 SkImageDecoder* SkImageDecoder::Factory(SkStream* stream) { 22 SkImageDecoder* image_decoder_from_stream(SkStream*);
23
24 SkImageDecoder* image_decoder_from_stream(SkStream* stream) {
22 SkImageDecoder* codec = NULL; 25 SkImageDecoder* codec = NULL;
23 const DecodeReg* curr = DecodeReg::Head(); 26 const DecodeReg* curr = DecodeReg::Head();
24 while (curr) { 27 while (curr) {
25 codec = curr->factory()(stream); 28 codec = curr->factory()(stream);
26 // we rewind here, because we promise later when we call "decode", that 29 // we rewind here, because we promise later when we call "decode", that
27 // the stream will be at its beginning. 30 // the stream will be at its beginning.
28 bool rewindSuceeded = stream->rewind(); 31 bool rewindSuceeded = stream->rewind();
29 32
30 // our image decoder's require that rewind is supported so we fail early 33 // our image decoder's require that rewind is supported so we fail early
31 // if we are given a stream that does not support rewinding. 34 // if we are given a stream that does not support rewinding.
32 if (!rewindSuceeded) { 35 if (!rewindSuceeded) {
33 SkDEBUGF(("Unable to rewind the image stream.")); 36 SkDEBUGF(("Unable to rewind the image stream."));
34 SkDELETE(codec); 37 SkDELETE(codec);
35 return NULL; 38 return NULL;
36 } 39 }
37 40
38 if (codec) { 41 if (codec) {
39 return codec; 42 return codec;
40 } 43 }
41 curr = curr->next(); 44 curr = curr->next();
42 } 45 }
43 return NULL; 46 return NULL;
44 } 47 }
45
46 /////////////////////////////////////////////////////////////////////////
47
48 typedef SkTRegistry<SkMovie*, SkStream*> MovieReg;
49
50 SkMovie* SkMovie::DecodeStream(SkStream* stream) {
51 const MovieReg* curr = MovieReg::Head();
52 while (curr) {
53 SkMovie* movie = curr->factory()(stream);
54 if (movie) {
55 return movie;
56 }
57 // we must rewind only if we got NULL, since we gave the stream to the
58 // movie, who may have already started reading from it
59 stream->rewind();
60 curr = curr->next();
61 }
62 return NULL;
63 }
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_FactoryDefault.cpp ('k') | src/ports/SkImageDecoder_CG.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698