blob: 370cddbf0dd598ea08d97b9428275aa44e5756ca [file] [log] [blame]
msarett4ab9d5f2015-08-06 15:34:42 -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 */
7
Hal Canary03a7f5f2017-02-10 09:06:38 -05008#ifndef SkBmpMaskCodec_DEFINED
9#define SkBmpMaskCodec_DEFINED
10
Leon Scroggins IIId81fed92017-06-01 13:42:28 -040011#include "SkBmpBaseCodec.h"
msarett4ab9d5f2015-08-06 15:34:42 -070012#include "SkImageInfo.h"
13#include "SkMaskSwizzler.h"
14#include "SkTypes.h"
15
16/*
17 * This class implements the decoding for bmp images using bit masks
18 */
Leon Scroggins IIId81fed92017-06-01 13:42:28 -040019class SkBmpMaskCodec : public SkBmpBaseCodec {
msarett4ab9d5f2015-08-06 15:34:42 -070020public:
21
22 /*
23 * Creates an instance of the decoder
24 *
Mike Reedede7bac2017-07-23 15:30:02 -040025 * Called only by SkBmpCodec::MakeFromStream
msarett4ab9d5f2015-08-06 15:34:42 -070026 * There should be no other callers despite this being public
27 *
msarettc30c4182016-04-20 11:53:35 -070028 * @param info contains properties of the encoded data
msarett4ab9d5f2015-08-06 15:34:42 -070029 * @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
33 */
Leon Scroggins III36f7e322018-08-27 11:55:46 -040034 SkBmpMaskCodec(SkEncodedInfo&& info, std::unique_ptr<SkStream>,
msarett5406d6f2015-08-31 06:55:13 -070035 uint16_t bitsPerPixel, SkMasks* masks,
scroggo46c57472015-09-30 08:57:13 -070036 SkCodec::SkScanlineOrder rowOrder);
msarett4ab9d5f2015-08-06 15:34:42 -070037
38protected:
39
40 Result onGetPixels(const SkImageInfo& dstInfo, void* dst,
Leon Scroggins571b30f2017-07-11 17:35:31 +000041 size_t dstRowBytes, const Options&,
42 int*) override;
msarett4ab9d5f2015-08-06 15:34:42 -070043
Matt Sarett1b96c6f2016-11-03 16:15:20 -040044 SkCodec::Result onPrepareToDecode(const SkImageInfo& dstInfo,
Leon Scroggins571b30f2017-07-11 17:35:31 +000045 const SkCodec::Options& options) override;
msarett5406d6f2015-08-31 06:55:13 -070046
msarett4ab9d5f2015-08-06 15:34:42 -070047private:
48
msarette6dd0042015-10-09 11:07:34 -070049 SkSampler* getSampler(bool createIfNecessary) override {
50 SkASSERT(fMaskSwizzler);
Ben Wagner145dbcd2016-11-03 14:40:50 -040051 return fMaskSwizzler.get();
msarette6dd0042015-10-09 11:07:34 -070052 }
msarett4ab9d5f2015-08-06 15:34:42 -070053
msarette6dd0042015-10-09 11:07:34 -070054 int decodeRows(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes,
55 const Options& opts) override;
msarett4ab9d5f2015-08-06 15:34:42 -070056
Ben Wagner145dbcd2016-11-03 14:40:50 -040057 std::unique_ptr<SkMasks> fMasks;
58 std::unique_ptr<SkMaskSwizzler> fMaskSwizzler;
msarett4ab9d5f2015-08-06 15:34:42 -070059
Leon Scroggins IIId81fed92017-06-01 13:42:28 -040060 typedef SkBmpBaseCodec INHERITED;
msarett4ab9d5f2015-08-06 15:34:42 -070061};
Hal Canary03a7f5f2017-02-10 09:06:38 -050062#endif // SkBmpMaskCodec_DEFINED