Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkMasks.h
Go to the documentation of this file.
1/*
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 */
7#ifndef SkMasks_DEFINED
8#define SkMasks_DEFINED
9
11
12#include <cstdint>
13
14class SkMasks {
15public:
16 // Contains all of the information for a single mask
17 struct MaskInfo {
18 uint32_t mask;
19 uint32_t shift; // To the left
20 uint32_t size; // Of mask width
21 };
22
23 constexpr SkMasks(const MaskInfo red,
24 const MaskInfo green,
25 const MaskInfo blue,
26 const MaskInfo alpha)
27 : fRed(red), fGreen(green), fBlue(blue), fAlpha(alpha) {}
28
29 // Input bit masks format
30 struct InputMasks {
31 uint32_t red;
32 uint32_t green;
33 uint32_t blue;
34 uint32_t alpha;
35 };
36
37 // Create the masks object
38 static SkMasks* CreateMasks(InputMasks masks, int bytesPerPixel);
39
40 // Get a color component
41 uint8_t getRed(uint32_t pixel) const;
42 uint8_t getGreen(uint32_t pixel) const;
43 uint8_t getBlue(uint32_t pixel) const;
44 uint8_t getAlpha(uint32_t pixel) const;
45
46 // Getter for the alpha mask
47 // The alpha mask may be used in other decoding modes
48 uint32_t getAlphaMask() const { return fAlpha.mask; }
49
50private:
51 const MaskInfo fRed;
52 const MaskInfo fGreen;
53 const MaskInfo fBlue;
54 const MaskInfo fAlpha;
55};
56
57#endif
constexpr SkMasks(const MaskInfo red, const MaskInfo green, const MaskInfo blue, const MaskInfo alpha)
Definition SkMasks.h:23
uint8_t getAlpha(uint32_t pixel) const
Definition SkMasks.cpp:79
uint32_t getAlphaMask() const
Definition SkMasks.h:48
static SkMasks * CreateMasks(InputMasks masks, int bytesPerPixel)
Definition SkMasks.cpp:126
uint8_t getBlue(uint32_t pixel) const
Definition SkMasks.cpp:76
uint8_t getGreen(uint32_t pixel) const
Definition SkMasks.cpp:73
uint8_t getRed(uint32_t pixel) const
Definition SkMasks.cpp:70
uint32_t mask
Definition SkMasks.h:18
uint32_t size
Definition SkMasks.h:20
uint32_t shift
Definition SkMasks.h:19