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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/*
* 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 "SkSampler.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 SkSampler {
public:
/*
* Create a new swizzler
* @param masks Unowned pointer to helper class
*/
static SkMaskSwizzler* CreateMaskSwizzler(const SkImageInfo& dstInfo,
const SkImageInfo& srcInfo,
SkMasks* masks,
uint32_t bitsPerPixel,
const SkCodec::Options& options);
/*
* Swizzle a row
*/
void swizzle(void* dst, const uint8_t* SK_RESTRICT src);
/**
* Implement fill using a custom width.
*/
void fill(const SkImageInfo& info, void* dst, size_t rowBytes, uint64_t colorOrIndex,
SkCodec::ZeroInitialized zeroInit) override {
const SkImageInfo fillInfo = info.makeWH(fDstWidth, info.height());
SkSampler::Fill(fillInfo, dst, rowBytes, colorOrIndex, zeroInit);
}
private:
/*
* Row procedure used for swizzle
*/
typedef void (*RowProc)(void* dstRow, const uint8_t* srcRow, int width,
SkMasks* masks, uint32_t startX, uint32_t sampleX);
SkMaskSwizzler(SkMasks* masks, RowProc proc, int subsetWidth, int srcOffset);
int onSetSampleX(int) override;
SkMasks* fMasks; // unowned
const RowProc fRowProc;
// FIXME: Can this class share more with SkSwizzler? These variables are all the same.
const int fSubsetWidth; // Width of the subset of source before any sampling.
int fDstWidth; // Width of dst, which may differ with sampling.
int fSampleX;
int fSrcOffset;
int fX0;
};
#endif
|