OLD | NEW |
| (Empty) |
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 | |
11 #include "SkCodec.h" | |
12 #include "SkSwizzler.h" | |
13 | |
14 class SkWbmpCodec final : public SkCodec { | |
15 public: | |
16 static bool IsWbmp(const void*, size_t); | |
17 | |
18 /* | |
19 * Assumes IsWbmp was called and returned true | |
20 * Creates a wbmp codec | |
21 * Takes ownership of the stream | |
22 */ | |
23 static SkCodec* NewFromStream(SkStream*); | |
24 | |
25 protected: | |
26 SkEncodedFormat onGetEncodedFormat() const override; | |
27 Result onGetPixels(const SkImageInfo&, void*, size_t, | |
28 const Options&, SkPMColor[], int*, int*) override; | |
29 bool onRewind() override; | |
30 private: | |
31 /* | |
32 * Returns a swizzler on success, nullptr on failure | |
33 */ | |
34 SkSwizzler* initializeSwizzler(const SkImageInfo& info, const SkPMColor* cta
ble, | |
35 const Options& opts); | |
36 SkSampler* getSampler(bool createIfNecessary) override { | |
37 SkASSERT(fSwizzler || !createIfNecessary); | |
38 return fSwizzler; | |
39 } | |
40 | |
41 /* | |
42 * Read a src row from the encoded stream | |
43 */ | |
44 bool readRow(uint8_t* row); | |
45 | |
46 SkWbmpCodec(const SkImageInfo&, SkStream*); | |
47 | |
48 const size_t fSrcRowBytes; | |
49 | |
50 // Used for scanline decodes: | |
51 SkAutoTDelete<SkSwizzler> fSwizzler; | |
52 SkAutoTUnref<SkColorTable> fColorTable; | |
53 SkAutoTMalloc<uint8_t> fSrcBuffer; | |
54 | |
55 // FIXME: Override onSkipScanlines to avoid swizzling. | |
56 int onGetScanlines(void* dst, int count, size_t dstRowBytes) override; | |
57 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& opti
ons, | |
58 SkPMColor inputColorTable[], int* inputColorCount) override; | |
59 | |
60 typedef SkCodec INHERITED; | |
61 }; | |
62 | |
63 #endif // SkCodec_wbmp_DEFINED | |
OLD | NEW |