Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkBmpStandardCodec.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 SkBmpStandardCodec_DEFINED
8#define SkBmpStandardCodec_DEFINED
9
17
18#include <cstddef>
19#include <cstdint>
20#include <memory>
21
22class SkSampler;
23class SkStream;
24enum SkAlphaType : int;
25enum SkColorType : int;
26struct SkImageInfo;
27
28/*
29 * This class implements the decoding for bmp images that use "standard" modes,
30 * which essentially means they do not contain bit masks or RLE codes.
31 */
33public:
34
35 /*
36 * Creates an instance of the decoder
37 *
38 * Called only by SkBmpCodec::MakeFromStream
39 * There should be no other callers despite this being public
40 *
41 * @param info contains properties of the encoded data
42 * @param stream the stream of encoded image data
43 * @param bitsPerPixel the number of bits used to store each pixel
44 * @param numColors the number of colors in the color table
45 * @param bytesPerColor the number of bytes in the stream used to represent
46 each color in the color table
47 * @param offset the offset of the image pixel data from the end of the
48 * headers
49 * @param rowOrder indicates whether rows are ordered top-down or bottom-up
50 * @param isOpaque indicates if the bmp itself is opaque (before applying
51 * the icp mask, if there is one)
52 * @param inIco indicates if the bmp is embedded in an ico file
53 */
54 SkBmpStandardCodec(SkEncodedInfo&& info, std::unique_ptr<SkStream> stream,
55 uint16_t bitsPerPixel, uint32_t numColors, uint32_t bytesPerColor,
56 uint32_t offset, SkCodec::SkScanlineOrder rowOrder,
57 bool isOpaque, bool inIco);
58
59protected:
60
61 Result onGetPixels(const SkImageInfo& dstInfo, void* dst,
62 size_t dstRowBytes, const Options&,
63 int*) override;
64
65 bool onInIco() const override {
66 return fInIco;
67 }
68
70 const SkCodec::Options& options) override;
71
72 SkSampler* getSampler(bool createIfNecessary) override {
73 SkASSERT(fSwizzler);
74 return fSwizzler.get();
75 }
76
77private:
78 bool createColorTable(SkColorType colorType, SkAlphaType alphaType);
79 SkEncodedInfo swizzlerInfo() const;
80 void initializeSwizzler(const SkImageInfo& dstInfo, const Options& opts);
81
82 int decodeRows(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes,
83 const Options& opts) override;
84
85 /*
86 * @param stream This may be a pointer to the stream owned by the parent SkCodec
87 * or a sub-stream of the stream owned by the parent SkCodec.
88 * Either way, this stream is unowned.
89 */
90 void decodeIcoMask(SkStream* stream, const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes);
91
92 sk_sp<SkColorPalette> fColorTable;
93 // fNumColors is the number specified in the header, or 0 if not present in the header.
94 const uint32_t fNumColors;
95 const uint32_t fBytesPerColor;
96 const uint32_t fOffset;
97 std::unique_ptr<SkSwizzler> fSwizzler;
98 const bool fIsOpaque;
99 const bool fInIco;
100 const size_t fAndMaskRowBytes; // only used for fInIco decodes
101
102 using INHERITED = SkBmpBaseCodec;
103};
104#endif // SkBmpStandardCodec_DEFINED
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
SkAlphaType
Definition SkAlphaType.h:26
#define SkASSERT(cond)
Definition SkAssert.h:116
SkColorType
Definition SkColorType.h:19
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
Type::kYUV Type::kRGBA() int(0.7 *637)
uint16_t bitsPerPixel() const
Definition SkBmpCodec.h:87
bool inIco() const
Definition SkBmpCodec.h:63
int decodeRows(const SkImageInfo &dstInfo, void *dst, size_t dstRowBytes, const Options &opts) override
SkCodec::Result onPrepareToDecode(const SkImageInfo &dstInfo, const SkCodec::Options &options) override
SkSampler * getSampler(bool createIfNecessary) override
Result onGetPixels(const SkImageInfo &dstInfo, void *dst, size_t dstRowBytes, const Options &, int *) override
bool onInIco() const override
const SkImageInfo & dstInfo() const
Definition SkCodec.h:878
SkStream * stream()
Definition SkCodec.h:865
SkScanlineOrder
Definition SkCodec.h:575
const Options & options() const
Definition SkCodec.h:880
Point offset