File indexing completed on 2024-12-22 04:10:30

0001 /*
0002  *  SPDX-FileCopyrightText: 2010 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef __KIS_TILE_COMPRESSOR_2_H
0008 #define __KIS_TILE_COMPRESSOR_2_H
0009 
0010 #include "kis_abstract_tile_compressor.h"
0011 
0012 class KisAbstractCompression;
0013 
0014 class KRITAIMAGE_EXPORT KisTileCompressor2 : public KisAbstractTileCompressor
0015 {
0016 public:
0017     KisTileCompressor2();
0018     ~KisTileCompressor2() override;
0019 
0020     bool writeTile(KisTileSP tile, KisPaintDeviceWriter &store) override;
0021     bool readTile(QIODevice *io, KisTiledDataManager *dm) override;
0022 
0023 
0024     void compressTileData(KisTileData *tileData,quint8 *buffer,
0025                           qint32 bufferSize, qint32 &bytesWritten) override;
0026     bool decompressTileData(quint8 *buffer, qint32 bufferSize, KisTileData *tileData) override;
0027     qint32 tileDataBufferSize(KisTileData *tileData) override;
0028 
0029 private:
0030     /**
0031      * Quite self describing
0032      */
0033     qint32 maxHeaderLength();
0034 
0035     QString getHeader(KisTileSP tile, qint32 compressedSize);
0036 
0037     void prepareWorkBuffers(qint32 tileDataSize);
0038     void prepareStreamingBuffer(qint32 tileDataSize);
0039 
0040 private:
0041     static const qint8 RAW_DATA_FLAG = 0;
0042     static const qint8 COMPRESSED_DATA_FLAG = 1;
0043 
0044 private:
0045     QByteArray m_linearizationBuffer;
0046     QByteArray m_compressionBuffer;
0047     QByteArray m_streamingBuffer;
0048     KisAbstractCompression *m_compression;
0049     static const QString m_compressionName;
0050 };
0051 
0052 #endif /* __KIS_TILE_COMPRESSOR_2_H */
0053