blob: 9606cbfbeb9760a64ad33e7656f50ea59fe20a15 [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 SkMasks_DEFINED
8#define SkMasks_DEFINED
9
msarett74114382015-03-16 11:55:18 -070010#include "SkTypes.h"
11
12/*
13 *
14 * Contains useful mask routines for SkMaskSwizzler
15 *
16 */
17class SkMasks {
18public:
19
20 /*
21 *
22 * Input bit masks format
23 *
24 */
25 struct InputMasks {
26 uint32_t red;
27 uint32_t green;
28 uint32_t blue;
29 uint32_t alpha;
30 };
31
32 /*
33 *
34 * Contains all of the information for a single mask
35 *
36 */
37 struct MaskInfo {
38 uint32_t mask;
39 uint32_t shift;
40 uint32_t size;
41 };
42
43 /*
44 *
45 * Create the masks object
46 *
47 */
48 static SkMasks* CreateMasks(InputMasks masks, uint32_t bpp);
49
50 /*
51 *
52 * Get a color component
53 *
54 */
scroggo8b17dcb2015-09-30 12:26:49 -070055 uint8_t getRed(uint32_t pixel) const;
56 uint8_t getGreen(uint32_t pixel) const;
57 uint8_t getBlue(uint32_t pixel) const;
58 uint8_t getAlpha(uint32_t pixel) const;
msarett74114382015-03-16 11:55:18 -070059
60 /*
61 *
62 * Getter for the alpha mask
63 * The alpha mask may be used in other decoding modes
64 *
65 */
scroggo8b17dcb2015-09-30 12:26:49 -070066 uint32_t getAlphaMask() const {
msarett74114382015-03-16 11:55:18 -070067 return fAlpha.mask;
68 }
69
70private:
71
72 /*
73 *
scroggo8b17dcb2015-09-30 12:26:49 -070074 * Constructor
msarett74114382015-03-16 11:55:18 -070075 *
76 */
scroggo8b17dcb2015-09-30 12:26:49 -070077 SkMasks(const MaskInfo& red, const MaskInfo& green, const MaskInfo& blue,
78 const MaskInfo& alpha);
msarett74114382015-03-16 11:55:18 -070079
80 const MaskInfo fRed;
81 const MaskInfo fGreen;
82 const MaskInfo fBlue;
83 const MaskInfo fAlpha;
84};
msarett4ab9d5f2015-08-06 15:34:42 -070085
86#endif