OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkCodec_wbmp_DEFINED | 8 #ifndef SkCodec_wbmp_DEFINED |
9 #define SkCodec_wbmp_DEFINED | 9 #define SkCodec_wbmp_DEFINED |
10 | 10 |
11 #include "SkCodec.h" | 11 #include "SkCodec.h" |
12 #include "SkScanlineDecoder.h" | |
13 #include "SkSwizzler.h" | 12 #include "SkSwizzler.h" |
14 | 13 |
15 class SkWbmpCodec final : public SkCodec { | 14 class SkWbmpCodec final : public SkCodec { |
16 public: | 15 public: |
17 static bool IsWbmp(SkStream*); | 16 static bool IsWbmp(SkStream*); |
18 | 17 |
19 /* | 18 /* |
20 * Assumes IsWbmp was called and returned true | 19 * Assumes IsWbmp was called and returned true |
21 * Creates a wbmp codec | 20 * Creates a wbmp codec |
22 * Takes ownership of the stream | 21 * Takes ownership of the stream |
23 */ | 22 */ |
24 static SkCodec* NewFromStream(SkStream*); | 23 static SkCodec* NewFromStream(SkStream*); |
25 | 24 |
26 /* | |
27 * Assumes IsWbmp was called and returned true | |
28 * Creates a wbmp scanline decoder | |
29 * Takes ownership of the stream | |
30 */ | |
31 static SkScanlineDecoder* NewSDFromStream(SkStream*); | |
32 protected: | 25 protected: |
33 SkEncodedFormat onGetEncodedFormat() const override; | 26 SkEncodedFormat onGetEncodedFormat() const override; |
34 Result onGetPixels(const SkImageInfo&, void*, size_t, | 27 Result onGetPixels(const SkImageInfo&, void*, size_t, |
35 const Options&, SkPMColor[], int*) override; | 28 const Options&, SkPMColor[], int*) override; |
36 bool onRewind() override; | 29 bool onRewind() override; |
37 private: | 30 private: |
38 /* | 31 /* |
39 * Returns a swizzler on success, nullptr on failure | 32 * Returns a swizzler on success, nullptr on failure |
40 */ | 33 */ |
41 SkSwizzler* initializeSwizzler(const SkImageInfo& info, const SkPMColor* cta
ble, | 34 SkSwizzler* initializeSwizzler(const SkImageInfo& info, const SkPMColor* cta
ble, |
42 const Options& opts); | 35 const Options& opts); |
43 | 36 |
44 /* | 37 /* |
45 * Read a src row from the encoded stream | 38 * Read a src row from the encoded stream |
46 */ | 39 */ |
47 Result readRow(uint8_t* row); | 40 Result readRow(uint8_t* row); |
48 | 41 |
49 SkWbmpCodec(const SkImageInfo&, SkStream*); | 42 SkWbmpCodec(const SkImageInfo&, SkStream*); |
50 | 43 |
51 const size_t fSrcRowBytes; | 44 const size_t fSrcRowBytes; |
52 | 45 |
53 friend class SkWbmpScanlineDecoder; | 46 // Used for scanline decodes: |
| 47 SkAutoTUnref<SkColorTable> fColorTable; |
| 48 SkAutoTDelete<SkSwizzler> fSwizzler; |
| 49 SkAutoTMalloc<uint8_t> fSrcBuffer; |
| 50 |
| 51 Result onGetScanlines(void* dst, int count, size_t dstRowBytes) override; |
| 52 Result onStart(const SkImageInfo& dstInfo, const Options& options, |
| 53 SkPMColor inputColorTable[], int* inputColorCount) override; |
| 54 |
54 typedef SkCodec INHERITED; | 55 typedef SkCodec INHERITED; |
55 }; | 56 }; |
56 | 57 |
57 #endif // SkCodec_wbmp_DEFINED | 58 #endif // SkCodec_wbmp_DEFINED |
OLD | NEW |