OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkPackBits_DEFINED | 10 #ifndef SkPackBits_DEFINED |
11 #define SkPackBits_DEFINED | 11 #define SkPackBits_DEFINED |
12 | 12 |
13 #include "SkTypes.h" | 13 #include "SkTypes.h" |
14 | 14 |
15 class SkPackBits { | 15 class SkPackBits { |
16 public: | 16 public: |
17 /** Given the number of 16bit values that will be passed to Pack16, | |
18 returns the worst-case size needed for the dst[] buffer. | |
19 */ | |
20 static size_t ComputeMaxSize16(int count); | |
21 | |
22 /** Given the number of 8bit values that will be passed to Pack8, | 17 /** Given the number of 8bit values that will be passed to Pack8, |
23 returns the worst-case size needed for the dst[] buffer. | 18 returns the worst-case size needed for the dst[] buffer. |
24 */ | 19 */ |
25 static size_t ComputeMaxSize8(int count); | 20 static size_t ComputeMaxSize8(int count); |
26 | 21 |
27 /** Write the src array into a packed format. The packing process may end | 22 /** Write the src array into a packed format. The packing process may end |
28 up writing more bytes than it read, so dst[] must be large enough. | 23 up writing more bytes than it read, so dst[] must be large enough. |
29 @param src Input array of 16bit values | |
30 @param count Number of entries in src[] | |
31 @param dst Buffer (allocated by caller) to write the packed data | |
32 into | |
33 @return the number of bytes written to dst[] | |
34 */ | |
35 static size_t Pack16(const uint16_t src[], int count, uint8_t dst[]); | |
36 | |
37 /** Write the src array into a packed format. The packing process may end | |
38 up writing more bytes than it read, so dst[] must be large enough. | |
39 @param src Input array of 8bit values | 24 @param src Input array of 8bit values |
40 @param count Number of entries in src[] | 25 @param srcSize Number of entries in src[] |
41 @param dst Buffer (allocated by caller) to write the packed data | 26 @param dst Buffer (allocated by caller) to write the packed data |
42 into | 27 into |
| 28 @param dstSize Number of bytes in the output buffer. |
43 @return the number of bytes written to dst[] | 29 @return the number of bytes written to dst[] |
44 */ | 30 */ |
45 static size_t Pack8(const uint8_t src[], int count, uint8_t dst[]); | 31 static size_t Pack8(const uint8_t src[], size_t srcSize, uint8_t dst[], |
46 | 32 size_t dstSize); |
47 /** Unpack the data in src[], and expand it into dst[]. The src[] data was | |
48 written by a previous call to Pack16. | |
49 @param src Input data to unpack, previously created by Pack16. | |
50 @param srcSize Number of bytes of src to unpack | |
51 @param dst Buffer (allocated by caller) to expand the src[] into. | |
52 @return the number of dst elements (not bytes) written into dst. | |
53 */ | |
54 static int Unpack16(const uint8_t src[], size_t srcSize, uint16_t dst[]); | |
55 | 33 |
56 /** Unpack the data in src[], and expand it into dst[]. The src[] data was | 34 /** Unpack the data in src[], and expand it into dst[]. The src[] data was |
57 written by a previous call to Pack8. | 35 written by a previous call to Pack8. |
58 @param src Input data to unpack, previously created by Pack8. | 36 @param src Input data to unpack, previously created by Pack8. |
59 @param srcSize Number of bytes of src to unpack | 37 @param srcSize Number of bytes of src to unpack |
60 @param dst Buffer (allocated by caller) to expand the src[] into. | 38 @param dst Buffer (allocated by caller) to expand the src[] into. |
| 39 @param dstSize Number of bytes in the output buffer. |
61 @return the number of bytes written into dst. | 40 @return the number of bytes written into dst. |
62 */ | 41 */ |
63 static int Unpack8(const uint8_t src[], size_t srcSize, uint8_t dst[]); | 42 static int Unpack8(const uint8_t src[], size_t srcSize, uint8_t dst[], |
64 | 43 size_t dstSize); |
65 /** Unpack the data from src[], skip the first dstSkip bytes, then write | |
66 dstWrite bytes into dst[]. The src[] data was written by a previous | |
67 call to Pack8. Return the number of bytes actually writtten into dst[] | |
68 @param src Input data to unpack, previously created by Pack8. | |
69 @param dst Buffer (allocated by caller) to expand the src[] into. | |
70 @param dstSkip Number of bytes of unpacked src to skip before writing | |
71 into dst | |
72 @param dstWrite Number of bytes of unpacked src to write into dst (after | |
73 skipping dstSkip bytes) | |
74 */ | |
75 static void Unpack8(uint8_t dst[], size_t dstSkip, size_t dstWrite, | |
76 const uint8_t src[]); | |
77 }; | 44 }; |
78 | 45 |
79 #endif | 46 #endif |
OLD | NEW |