Matt Sarett | c367d03 | 2017-05-05 11:13:26 -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 | |
| 8 | #ifndef SkEncoder_DEFINED |
| 9 | #define SkEncoder_DEFINED |
| 10 | |
Ben Wagner | d5148e3 | 2018-07-16 17:44:06 -0400 | [diff] [blame] | 11 | #include "../private/SkNoncopyable.h" |
Matt Sarett | 94fd06f | 2017-05-08 17:31:00 -0400 | [diff] [blame] | 12 | #include "../private/SkTemplates.h" |
Ben Wagner | d5148e3 | 2018-07-16 17:44:06 -0400 | [diff] [blame] | 13 | #include "SkPixmap.h" |
Matt Sarett | c367d03 | 2017-05-05 11:13:26 -0400 | [diff] [blame] | 14 | |
Matt Sarett | b1d3b2e | 2017-05-12 08:54:13 -0400 | [diff] [blame] | 15 | class SK_API SkEncoder : SkNoncopyable { |
Matt Sarett | c367d03 | 2017-05-05 11:13:26 -0400 | [diff] [blame] | 16 | public: |
| 17 | |
| 18 | /** |
| 19 | * Encode |numRows| rows of input. If the caller requests more rows than are remaining |
| 20 | * in the src, this will encode all of the remaining rows. |numRows| must be greater |
| 21 | * than zero. |
| 22 | */ |
| 23 | bool encodeRows(int numRows); |
| 24 | |
| 25 | virtual ~SkEncoder() {} |
| 26 | |
| 27 | protected: |
| 28 | |
| 29 | virtual bool onEncodeRows(int numRows) = 0; |
| 30 | |
| 31 | SkEncoder(const SkPixmap& src, size_t storageBytes) |
| 32 | : fSrc(src) |
| 33 | , fCurrRow(0) |
| 34 | , fStorage(storageBytes) |
| 35 | {} |
| 36 | |
| 37 | const SkPixmap& fSrc; |
| 38 | int fCurrRow; |
| 39 | SkAutoTMalloc<uint8_t> fStorage; |
| 40 | }; |
| 41 | |
| 42 | #endif |