blob: 2dc7677afc76d2f0cefa3abc24a5027f812eedf3 [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2008 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00003 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00004 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00006 */
7
epoger@google.comec3ed6a2011-07-28 14:26:00 +00008
reed@android.com8a1c16f2008-12-17 15:59:43 +00009#ifndef SkPackBits_DEFINED
10#define SkPackBits_DEFINED
11
12#include "SkTypes.h"
13
14class SkPackBits {
15public:
reed@android.com8a1c16f2008-12-17 15:59:43 +000016 /** Given the number of 8bit values that will be passed to Pack8,
17 returns the worst-case size needed for the dst[] buffer.
18 */
bungemanccb74b82016-02-23 12:55:20 -080019 static size_t ComputeMaxSize8(size_t srcSize);
reed@android.com8a1c16f2008-12-17 15:59:43 +000020
21 /** Write the src array into a packed format. The packing process may end
22 up writing more bytes than it read, so dst[] must be large enough.
reed@android.com8a1c16f2008-12-17 15:59:43 +000023 @param src Input array of 8bit values
jschuh699b8522015-06-04 15:10:37 -070024 @param srcSize Number of entries in src[]
reed@android.com8a1c16f2008-12-17 15:59:43 +000025 @param dst Buffer (allocated by caller) to write the packed data
26 into
jschuh699b8522015-06-04 15:10:37 -070027 @param dstSize Number of bytes in the output buffer.
reed@android.com8a1c16f2008-12-17 15:59:43 +000028 @return the number of bytes written to dst[]
29 */
jschuh699b8522015-06-04 15:10:37 -070030 static size_t Pack8(const uint8_t src[], size_t srcSize, uint8_t dst[],
31 size_t dstSize);
reed@android.com8a1c16f2008-12-17 15:59:43 +000032
33 /** Unpack the data in src[], and expand it into dst[]. The src[] data was
34 written by a previous call to Pack8.
35 @param src Input data to unpack, previously created by Pack8.
36 @param srcSize Number of bytes of src to unpack
37 @param dst Buffer (allocated by caller) to expand the src[] into.
jschuh699b8522015-06-04 15:10:37 -070038 @param dstSize Number of bytes in the output buffer.
reed@android.com8a1c16f2008-12-17 15:59:43 +000039 @return the number of bytes written into dst.
40 */
jschuh699b8522015-06-04 15:10:37 -070041 static int Unpack8(const uint8_t src[], size_t srcSize, uint8_t dst[],
42 size_t dstSize);
reed@android.com8a1c16f2008-12-17 15:59:43 +000043};
44
45#endif