epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2008 The Android Open Source Project |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 4 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 10 | #ifndef SkPackBits_DEFINED |
| 11 | #define SkPackBits_DEFINED |
| 12 | |
| 13 | #include "SkTypes.h" |
| 14 | |
| 15 | class SkPackBits { |
| 16 | public: |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 17 | /** Given the number of 8bit values that will be passed to Pack8, |
| 18 | returns the worst-case size needed for the dst[] buffer. |
| 19 | */ |
bungeman | ccb74b8 | 2016-02-23 12:55:20 -0800 | [diff] [blame^] | 20 | static size_t ComputeMaxSize8(size_t srcSize); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 21 | |
| 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.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 24 | @param src Input array of 8bit values |
jschuh | 699b852 | 2015-06-04 15:10:37 -0700 | [diff] [blame] | 25 | @param srcSize Number of entries in src[] |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 26 | @param dst Buffer (allocated by caller) to write the packed data |
| 27 | into |
jschuh | 699b852 | 2015-06-04 15:10:37 -0700 | [diff] [blame] | 28 | @param dstSize Number of bytes in the output buffer. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 29 | @return the number of bytes written to dst[] |
| 30 | */ |
jschuh | 699b852 | 2015-06-04 15:10:37 -0700 | [diff] [blame] | 31 | static size_t Pack8(const uint8_t src[], size_t srcSize, uint8_t dst[], |
| 32 | size_t dstSize); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 33 | |
| 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. |
jschuh | 699b852 | 2015-06-04 15:10:37 -0700 | [diff] [blame] | 39 | @param dstSize Number of bytes in the output buffer. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 40 | @return the number of bytes written into dst. |
| 41 | */ |
jschuh | 699b852 | 2015-06-04 15:10:37 -0700 | [diff] [blame] | 42 | static int Unpack8(const uint8_t src[], size_t srcSize, uint8_t dst[], |
| 43 | size_t dstSize); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | #endif |