blob: 3acfb97108e04f6017fc18c1091d39d0098ffe24 [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
11#include "SkPixmap.h"
Matt Sarett94fd06f2017-05-08 17:31:00 -040012#include "../private/SkTemplates.h"
Matt Sarettc367d032017-05-05 11:13:26 -040013
Matt Sarettb1d3b2e2017-05-12 08:54:13 -040014class SK_API SkEncoder : SkNoncopyable {
Matt Sarettc367d032017-05-05 11:13:26 -040015public:
16
17 /**
18 * Encode |numRows| rows of input. If the caller requests more rows than are remaining
19 * in the src, this will encode all of the remaining rows. |numRows| must be greater
20 * than zero.
21 */
22 bool encodeRows(int numRows);
23
24 virtual ~SkEncoder() {}
25
26protected:
27
28 virtual bool onEncodeRows(int numRows) = 0;
29
30 SkEncoder(const SkPixmap& src, size_t storageBytes)
31 : fSrc(src)
32 , fCurrRow(0)
33 , fStorage(storageBytes)
34 {}
35
36 const SkPixmap& fSrc;
37 int fCurrRow;
38 SkAutoTMalloc<uint8_t> fStorage;
39};
40
41#endif