blob: 1b4f5594f52fe2ab23cd64ae6fd92949a09eab91 [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
Ben Wagnerd5148e32018-07-16 17:44:06 -040011#include "../private/SkNoncopyable.h"
Matt Sarett94fd06f2017-05-08 17:31:00 -040012#include "../private/SkTemplates.h"
Ben Wagnerd5148e32018-07-16 17:44:06 -040013#include "SkPixmap.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