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 | 14 |
13 class SkWbmpCodec final : public SkCodec { | 15 class SkWbmpCodec final : public SkCodec { |
14 public: | 16 public: |
15 static bool IsWbmp(SkStream*); | 17 static bool IsWbmp(SkStream*); |
| 18 |
| 19 /* |
| 20 * Assumes IsWbmp was called and returned true |
| 21 * Creates a wbmp codec |
| 22 * Takes ownership of the stream |
| 23 */ |
16 static SkCodec* NewFromStream(SkStream*); | 24 static SkCodec* NewFromStream(SkStream*); |
| 25 |
| 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*); |
17 protected: | 32 protected: |
18 SkEncodedFormat onGetEncodedFormat() const override; | 33 SkEncodedFormat onGetEncodedFormat() const override; |
19 Result onGetPixels(const SkImageInfo&, void*, size_t, | 34 Result onGetPixels(const SkImageInfo&, void*, size_t, |
20 const Options&, SkPMColor[], int*) override; | 35 const Options&, SkPMColor[], int*) override; |
21 private: | 36 private: |
| 37 |
| 38 /* |
| 39 * Calls rewindIfNeeded and returns true if the decoder can continue |
| 40 */ |
| 41 bool handleRewind(); |
| 42 |
| 43 /* |
| 44 * Returns a swizzler on success, NULL on failure |
| 45 */ |
| 46 SkSwizzler* initializeSwizzler(const SkImageInfo& info, const SkPMColor* cta
ble, |
| 47 const Options& opts); |
| 48 |
| 49 /* |
| 50 * Read a src row from the encoded stream |
| 51 */ |
| 52 Result readRow(uint8_t* row); |
| 53 |
22 SkWbmpCodec(const SkImageInfo&, SkStream*); | 54 SkWbmpCodec(const SkImageInfo&, SkStream*); |
| 55 |
| 56 const size_t fSrcRowBytes; |
| 57 |
| 58 friend class SkWbmpScanlineDecoder; |
23 typedef SkCodec INHERITED; | 59 typedef SkCodec INHERITED; |
24 }; | 60 }; |
25 | 61 |
26 #endif // SkCodec_wbmp_DEFINED | 62 #endif // SkCodec_wbmp_DEFINED |
OLD | NEW |