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 
11 #include "include/core/SkPixmap.h"
12 #include "include/private/SkNoncopyable.h"
13 #include "include/private/SkTemplates.h"
14 
15 class SK_API SkEncoder : SkNoncopyable {
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 
~SkEncoder()25     virtual ~SkEncoder() {}
26 
27 protected:
28 
29     virtual bool onEncodeRows(int numRows) = 0;
30 
SkEncoder(const SkPixmap & src,size_t storageBytes)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
43