blob: f6430faadd4b17165e2144e481e648dd07bde123 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@android.com8a1c16f2008-12-17 15:59:43 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2008 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00004 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00005 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
reed@android.com8a1c16f2008-12-17 15:59:43 +000010#ifndef SkPackBits_DEFINED
11#define SkPackBits_DEFINED
12
13#include "SkTypes.h"
14
15class SkPackBits {
16public:
reed@android.com8a1c16f2008-12-17 15:59:43 +000017 /** Given the number of 8bit values that will be passed to Pack8,
18 returns the worst-case size needed for the dst[] buffer.
19 */
bungemanccb74b82016-02-23 12:55:20 -080020 static size_t ComputeMaxSize8(size_t srcSize);
reed@android.com8a1c16f2008-12-17 15:59:43 +000021
22 /** Write the src array into a packed format. The packing process may end
23 up writing more bytes than it read, so dst[] must be large enough.
reed@android.com8a1c16f2008-12-17 15:59:43 +000024 @param src Input array of 8bit values
jschuh699b8522015-06-04 15:10:37 -070025 @param srcSize Number of entries in src[]
reed@android.com8a1c16f2008-12-17 15:59:43 +000026 @param dst Buffer (allocated by caller) to write the packed data
27 into
jschuh699b8522015-06-04 15:10:37 -070028 @param dstSize Number of bytes in the output buffer.
reed@android.com8a1c16f2008-12-17 15:59:43 +000029 @return the number of bytes written to dst[]
30 */
jschuh699b8522015-06-04 15:10:37 -070031 static size_t Pack8(const uint8_t src[], size_t srcSize, uint8_t dst[],
32 size_t dstSize);
reed@android.com8a1c16f2008-12-17 15:59:43 +000033
34 /** Unpack the data in src[], and expand it into dst[]. The src[] data was
35 written by a previous call to Pack8.
36 @param src Input data to unpack, previously created by Pack8.
37 @param srcSize Number of bytes of src to unpack
38 @param dst Buffer (allocated by caller) to expand the src[] into.
jschuh699b8522015-06-04 15:10:37 -070039 @param dstSize Number of bytes in the output buffer.
reed@android.com8a1c16f2008-12-17 15:59:43 +000040 @return the number of bytes written into dst.
41 */
jschuh699b8522015-06-04 15:10:37 -070042 static int Unpack8(const uint8_t src[], size_t srcSize, uint8_t dst[],
43 size_t dstSize);
reed@android.com8a1c16f2008-12-17 15:59:43 +000044};
45
46#endif