Flutter Engine
The Flutter Engine
SkMaskSwizzler.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 SkMaskSwizzler_DEFINED
8#define SkMaskSwizzler_DEFINED
9
12#include "src/codec/SkSampler.h"
13
14#include <cstdint>
15
16class SkMasks;
17struct SkImageInfo;
18
19/*
20 *
21 * Used to swizzle images whose pixel components are extracted by bit masks
22 * Currently only used by bmp
23 *
24 */
25class SkMaskSwizzler : public SkSampler {
26public:
27
28 /*
29 * @param masks Unowned pointer to helper class
30 */
31 static SkMaskSwizzler* CreateMaskSwizzler(const SkImageInfo& dstInfo,
32 bool srcIsOpaque,
33 SkMasks* masks,
34 uint32_t bitsPerPixel,
36
37 /*
38 * Swizzle a row
39 */
40 void swizzle(void* dst, const uint8_t* SK_RESTRICT src);
41
42 int fillWidth() const override {
43 return fDstWidth;
44 }
45
46 /**
47 * Returns the byte offset at which we write to destination memory, taking
48 * scaling, subsetting, and partial frames into account.
49 * A similar function exists on SkSwizzler.
50 */
51 int swizzleWidth() const { return fDstWidth; }
52
53private:
54
55 /*
56 * Row procedure used for swizzle
57 */
58 typedef void (*RowProc)(void* dstRow, const uint8_t* srcRow, int width,
59 SkMasks* masks, uint32_t startX, uint32_t sampleX);
60
61 SkMaskSwizzler(SkMasks* masks, RowProc proc, int subsetWidth, int srcOffset);
62
63 int onSetSampleX(int) override;
64
65 SkMasks* fMasks; // unowned
66 const RowProc fRowProc;
67
68 // FIXME: Can this class share more with SkSwizzler? These variables are all the same.
69 const int fSubsetWidth; // Width of the subset of source before any sampling.
70 int fDstWidth; // Width of dst, which may differ with sampling.
71 int fSampleX;
72 int fSrcOffset;
73 int fX0;
74};
75
76#endif
const char * options
#define SK_RESTRICT
Definition: SkFeatures.h:42
int swizzleWidth() const
void swizzle(void *dst, const uint8_t *SK_RESTRICT src)
int fillWidth() const override
static SkMaskSwizzler * CreateMaskSwizzler(const SkImageInfo &dstInfo, bool srcIsOpaque, SkMasks *masks, uint32_t bitsPerPixel, const SkCodec::Options &options)
dst
Definition: cp.py:12
int32_t width