blob: 794dcd16e498e8948a1065ba6e29bb31bdc8361a [file] [log] [blame]
msarett74114382015-03-16 11:55:18 -07001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
msarett4ab9d5f2015-08-06 15:34:42 -07007#ifndef SkMaskSwizzler_DEFINED
8#define SkMaskSwizzler_DEFINED
msarett74114382015-03-16 11:55:18 -07009
10#include "SkMasks.h"
11#include "SkSwizzler.h"
12#include "SkTypes.h"
13
14/*
15 *
16 * Used to swizzle images whose pixel components are extracted by bit masks
17 * Currently only used by bmp
18 *
19 */
20class SkMaskSwizzler {
21public:
22
23 /*
msarett74114382015-03-16 11:55:18 -070024 * Create a new swizzler
25 * @param masks Unowned pointer to helper class
msarett74114382015-03-16 11:55:18 -070026 */
msarett5406d6f2015-08-31 06:55:13 -070027 static SkMaskSwizzler* CreateMaskSwizzler(const SkImageInfo& dstInfo,
28 const SkImageInfo& srcInfo,
msarett74114382015-03-16 11:55:18 -070029 SkMasks* masks,
30 uint32_t bitsPerPixel);
31
32 /*
msarett614aa072015-07-27 15:13:17 -070033 * Swizzle a row
msarett74114382015-03-16 11:55:18 -070034 */
msarett614aa072015-07-27 15:13:17 -070035 SkSwizzler::ResultAlpha swizzle(void* dst, const uint8_t* SK_RESTRICT src);
msarett74114382015-03-16 11:55:18 -070036
37private:
38
39 /*
msarett74114382015-03-16 11:55:18 -070040 * Row procedure used for swizzle
msarett74114382015-03-16 11:55:18 -070041 */
42 typedef SkSwizzler::ResultAlpha (*RowProc)(
43 void* dstRow, const uint8_t* srcRow, int width,
msarett5406d6f2015-08-31 06:55:13 -070044 SkMasks* masks, uint32_t startX, uint32_t sampleX);
msarett74114382015-03-16 11:55:18 -070045
46 /*
msarett74114382015-03-16 11:55:18 -070047 * Constructor for mask swizzler
msarett74114382015-03-16 11:55:18 -070048 */
msarett5406d6f2015-08-31 06:55:13 -070049 SkMaskSwizzler(const SkImageInfo& info, SkMasks* masks, RowProc proc,
50 uint32_t sampleX);
msarett74114382015-03-16 11:55:18 -070051
52 // Fields
msaretteed039b2015-03-18 11:11:19 -070053 const SkImageInfo& fDstInfo;
msaretteed039b2015-03-18 11:11:19 -070054 SkMasks* fMasks; // unowned
msarett74114382015-03-16 11:55:18 -070055 const RowProc fRowProc;
msarett5406d6f2015-08-31 06:55:13 -070056 const uint32_t fSampleX;
57 const uint32_t fStartX;
msarett74114382015-03-16 11:55:18 -070058};
msarett4ab9d5f2015-08-06 15:34:42 -070059
60#endif