aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/images/SkImageEncoder_Factory.cpp
blob: 10f8d64decffaa6bad6af71bd6d6fa4ba697e162 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

/*
 * Copyright 2009 The Android Open Source Project
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */


#include "SkImageEncoder.h"
#include "SkTRegistry.h"

typedef SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> EncodeReg;

// Can't use the typedef here because of complex C++ corner cases
template EncodeReg* SkTRegistry<SkImageEncoder*, SkImageEncoder::Type>::gHead;

SkImageEncoder* SkImageEncoder::Create(Type t) {
    SkImageEncoder* codec = NULL;
    const EncodeReg* curr = EncodeReg::Head();
    while (curr) {
        if ((codec = curr->factory()(t)) != NULL) {
            return codec;
        }
        curr = curr->next();
    }
    return NULL;
}