aboutsummaryrefslogtreecommitdiffstats
path: root/src/codec/SkCodec_wbmp.h
blob: 8c5466105cfecfab422f9ab843acc8030cba50ee (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
 * Copyright 2015 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkCodec_wbmp_DEFINED
#define SkCodec_wbmp_DEFINED

#include "SkCodec.h"
#include "SkScanlineDecoder.h"
#include "SkSwizzler.h"

class SkWbmpCodec final : public SkCodec {
public:
    static bool IsWbmp(SkStream*);

    /*
     * Assumes IsWbmp was called and returned true
     * Creates a wbmp codec
     * Takes ownership of the stream
     */
    static SkCodec* NewFromStream(SkStream*);

    /*
     * Assumes IsWbmp was called and returned true
     * Creates a wbmp scanline decoder
     * Takes ownership of the stream
     */
    static SkScanlineDecoder* NewSDFromStream(SkStream*);
protected:
    SkEncodedFormat onGetEncodedFormat() const override;
    Result onGetPixels(const SkImageInfo&, void*, size_t,
                       const Options&, SkPMColor[], int*) override;
    bool onRewind() override;
private:
    /*
     * Returns a swizzler on success, NULL on failure
     */
    SkSwizzler* initializeSwizzler(const SkImageInfo& info, const SkPMColor* ctable,
                                   const Options& opts);

    /*
     * Read a src row from the encoded stream
     */
    Result readRow(uint8_t* row);

    SkWbmpCodec(const SkImageInfo&, SkStream*);

    const size_t fSrcRowBytes;

    friend class SkWbmpScanlineDecoder;
    typedef SkCodec INHERITED;
};

#endif  // SkCodec_wbmp_DEFINED