Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkWbmpCodec.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
8#ifndef SkCodec_wbmp_DEFINED
9#define SkCodec_wbmp_DEFINED
10
15
16#include <cstddef>
17#include <cstdint>
18#include <memory>
19
20class SkSampler;
21class SkStream;
22enum class SkEncodedImageFormat;
23struct SkEncodedInfo;
24struct SkImageInfo;
25
26class SkWbmpCodec final : public SkCodec {
27public:
28 static bool IsWbmp(const void*, size_t);
29
30 /*
31 * Assumes IsWbmp was called and returned true
32 * Creates a wbmp codec
33 * Takes ownership of the stream
34 */
35 static std::unique_ptr<SkCodec> MakeFromStream(std::unique_ptr<SkStream>, Result*);
36
37protected:
39 Result onGetPixels(const SkImageInfo&, void*, size_t,
40 const Options&, int*) override;
41 bool onRewind() override;
42 bool conversionSupported(const SkImageInfo& dst, bool srcIsOpaque,
43 bool needsXform) override;
44 // No need to Xform; all pixels are either black or white.
45 bool usesColorXform() const override { return false; }
46private:
47 SkSampler* getSampler(bool createIfNecessary) override {
48 SkASSERT(fSwizzler || !createIfNecessary);
49 return fSwizzler.get();
50 }
51
52 /*
53 * Read a src row from the encoded stream
54 */
55 bool readRow(uint8_t* row);
56
57 SkWbmpCodec(SkEncodedInfo&&, std::unique_ptr<SkStream>);
58
59 const size_t fSrcRowBytes;
60
61 // Used for scanline decodes:
62 std::unique_ptr<SkSwizzler> fSwizzler;
64
65 int onGetScanlines(void* dst, int count, size_t dstRowBytes) override;
66 bool onSkipScanlines(int count) override;
68 const Options& options) override;
69
70 using INHERITED = SkCodec;
71};
72
73#endif // SkCodec_wbmp_DEFINED
int count
#define SkASSERT(cond)
Definition SkAssert.h:116
SkEncodedImageFormat
const SkImageInfo & dstInfo() const
Definition SkCodec.h:878
const Options & options() const
Definition SkCodec.h:880
SkEncodedImageFormat onGetEncodedFormat() const override
Result onStartScanlineDecode(const SkImageInfo &dstInfo, const Options &options) override
static bool IsWbmp(const void *, size_t)
bool conversionSupported(const SkImageInfo &dst, bool srcIsOpaque, bool needsXform) override
bool usesColorXform() const override
Definition SkWbmpCodec.h:45
bool onRewind() override
bool onSkipScanlines(int count) override
int onGetScanlines(void *dst, int count, size_t dstRowBytes) override
SkSampler * getSampler(bool createIfNecessary) override
Definition SkWbmpCodec.h:47
Result onGetPixels(const SkImageInfo &, void *, size_t, const Options &, int *) override
static std::unique_ptr< SkCodec > MakeFromStream(std::unique_ptr< SkStream >, Result *)