blob: 565519acc8daab83112f947472cff340a6cff06d [file] [log] [blame]
scroggo@google.com4c6adf92013-04-17 21:07:55 +00001
2/*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#include "SkImageDecoder.h"
10#include "SkMovie.h"
11#include "SkStream.h"
12#include "SkTRegistry.h"
13
14extern SkImageDecoder* image_decoder_from_stream(SkStream*);
15
16SkImageDecoder* SkImageDecoder::Factory(SkStream* stream) {
17 return image_decoder_from_stream(stream);
18}
19
20/////////////////////////////////////////////////////////////////////////
21
22typedef SkTRegistry<SkMovie*, SkStream*> MovieReg;
23
24SkMovie* SkMovie::DecodeStream(SkStream* stream) {
25 const MovieReg* curr = MovieReg::Head();
26 while (curr) {
27 SkMovie* movie = curr->factory()(stream);
28 if (movie) {
29 return movie;
30 }
31 // we must rewind only if we got NULL, since we gave the stream to the
32 // movie, who may have already started reading from it
33 stream->rewind();
34 curr = curr->next();
35 }
36 return NULL;
37}