Leon Scroggins III | d81fed9 | 2017-06-01 13:42:28 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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 SkBmpBaseCodec_DEFINED |
| 8 | #define SkBmpBaseCodec_DEFINED |
| 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "include/private/SkTemplates.h" |
| 11 | #include "src/codec/SkBmpCodec.h" |
Leon Scroggins III | d81fed9 | 2017-06-01 13:42:28 -0400 | [diff] [blame] | 12 | |
| 13 | /* |
| 14 | * Common base class for SkBmpStandardCodec and SkBmpMaskCodec. |
| 15 | */ |
| 16 | class SkBmpBaseCodec : public SkBmpCodec { |
| 17 | public: |
| 18 | ~SkBmpBaseCodec() override; |
| 19 | |
| 20 | /* |
| 21 | * Whether fSrcBuffer was successfully created. |
| 22 | * |
| 23 | * If false, this Codec must not be used. |
| 24 | */ |
| 25 | bool didCreateSrcBuffer() const { return fSrcBuffer != nullptr; } |
| 26 | |
| 27 | protected: |
Leon Scroggins III | 36f7e32 | 2018-08-27 11:55:46 -0400 | [diff] [blame] | 28 | SkBmpBaseCodec(SkEncodedInfo&& info, std::unique_ptr<SkStream>, |
Leon Scroggins III | d81fed9 | 2017-06-01 13:42:28 -0400 | [diff] [blame] | 29 | uint16_t bitsPerPixel, SkCodec::SkScanlineOrder rowOrder); |
| 30 | |
| 31 | uint8_t* srcBuffer() { return reinterpret_cast<uint8_t*>(fSrcBuffer.get()); } |
| 32 | |
| 33 | private: |
| 34 | SkAutoFree fSrcBuffer; |
| 35 | |
| 36 | typedef SkBmpCodec INHERITED; |
| 37 | }; |
| 38 | #endif // SkBmpBaseCodec_DEFINED |