aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkMaskSwizzler.h
blob: 9f4dd440aa27e5b5961065f28cd5f0348d6a0524 (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
/*
 * 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 SkMaskSwizzler_DEFINED
#define SkMaskSwizzler_DEFINED

#include "SkMasks.h"
#include "SkSwizzler.h"
#include "SkTypes.h"

/*
 *
 * Used to swizzle images whose pixel components are extracted by bit masks
 * Currently only used by bmp
 *
 */
class SkMaskSwizzler {
public:

    /*
     * Create a new swizzler
     * @param masks Unowned pointer to helper class
     */
    static SkMaskSwizzler* CreateMaskSwizzler(const SkImageInfo& imageInfo,
                                              SkMasks* masks,
                                              uint32_t bitsPerPixel);

    /*
     * Swizzle a row
     */
    SkSwizzler::ResultAlpha swizzle(void* dst, const uint8_t* SK_RESTRICT src);

private:

    /*
     * Row procedure used for swizzle
     */
    typedef SkSwizzler::ResultAlpha (*RowProc)(
            void* dstRow, const uint8_t* srcRow, int width,
            SkMasks* masks);

    /*
     * Constructor for mask swizzler
     */
    SkMaskSwizzler(const SkImageInfo& info, SkMasks* masks, RowProc proc);

    // Fields
    const SkImageInfo& fDstInfo;
    SkMasks*           fMasks;       // unowned
    const RowProc      fRowProc;
};

#endif