2 * Copyright 2015 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkBmpMaskCodec_DEFINED
9 #define SkBmpMaskCodec_DEFINED
11 #include "include/core/SkImageInfo.h"
12 #include "include/core/SkTypes.h"
13 #include "src/codec/SkBmpBaseCodec.h"
14 #include "src/codec/SkMaskSwizzler.h"
17 * This class implements the decoding for bmp images using bit masks
19 class SkBmpMaskCodec : public SkBmpBaseCodec {
23 * Creates an instance of the decoder
25 * Called only by SkBmpCodec::MakeFromStream
26 * There should be no other callers despite this being public
28 * @param info contains properties of the encoded data
29 * @param stream the stream of encoded image data
30 * @param bitsPerPixel the number of bits used to store each pixel
31 * @param masks color masks for certain bmp formats
32 * @param rowOrder indicates whether rows are ordered top-down or bottom-up
34 SkBmpMaskCodec(SkEncodedInfo&& info, std::unique_ptr<SkStream>,
35 uint16_t bitsPerPixel, SkMasks* masks,
36 SkCodec::SkScanlineOrder rowOrder);
40 Result onGetPixels(const SkImageInfo& dstInfo, void* dst,
41 size_t dstRowBytes, const Options&,
44 SkCodec::Result onPrepareToDecode(const SkImageInfo& dstInfo,
45 const SkCodec::Options& options) override;
49 SkSampler* getSampler(bool createIfNecessary) override {
50 SkASSERT(fMaskSwizzler);
51 return fMaskSwizzler.get();
54 int decodeRows(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes,
55 const Options& opts) override;
57 std::unique_ptr<SkMasks> fMasks;
58 std::unique_ptr<SkMaskSwizzler> fMaskSwizzler;
60 using INHERITED = SkBmpBaseCodec;
62 #endif // SkBmpMaskCodec_DEFINED