blob: 1a9c37e7f5da764a68d65740687b89ea741c2178 [file] [log] [blame]
Matt Sarettc367d032017-05-05 11:13:26 -04001/*
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkPixmap.h"
12#include "include/private/SkNoncopyable.h"
13#include "include/private/SkTemplates.h"
Matt Sarettc367d032017-05-05 11:13:26 -040014
Matt Sarettb1d3b2e2017-05-12 08:54:13 -040015class SK_API SkEncoder : SkNoncopyable {
Matt Sarettc367d032017-05-05 11:13:26 -040016public:
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
27protected:
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