Home | History | Annotate | Download | only in encode
      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 "SkPixmap.h"
     12 #include "../private/SkTemplates.h"
     13 
     14 class SK_API SkEncoder : SkNoncopyable {
     15 public:
     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 
     26 protected:
     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
     42