gfx/skia/trunk/include/core/SkPackBits.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/core/SkPackBits.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,79 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2008 The Android Open Source Project
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +
    1.12 +
    1.13 +#ifndef SkPackBits_DEFINED
    1.14 +#define SkPackBits_DEFINED
    1.15 +
    1.16 +#include "SkTypes.h"
    1.17 +
    1.18 +class SkPackBits {
    1.19 +public:
    1.20 +    /** Given the number of 16bit values that will be passed to Pack16,
    1.21 +        returns the worst-case size needed for the dst[] buffer.
    1.22 +    */
    1.23 +    static size_t ComputeMaxSize16(int count);
    1.24 +
    1.25 +    /** Given the number of 8bit values that will be passed to Pack8,
    1.26 +        returns the worst-case size needed for the dst[] buffer.
    1.27 +    */
    1.28 +    static size_t ComputeMaxSize8(int count);
    1.29 +
    1.30 +    /** Write the src array into a packed format. The packing process may end
    1.31 +        up writing more bytes than it read, so dst[] must be large enough.
    1.32 +        @param src      Input array of 16bit values
    1.33 +        @param count    Number of entries in src[]
    1.34 +        @param dst      Buffer (allocated by caller) to write the packed data
    1.35 +                        into
    1.36 +        @return the number of bytes written to dst[]
    1.37 +    */
    1.38 +    static size_t Pack16(const uint16_t src[], int count, uint8_t dst[]);
    1.39 +
    1.40 +    /** Write the src array into a packed format. The packing process may end
    1.41 +        up writing more bytes than it read, so dst[] must be large enough.
    1.42 +        @param src      Input array of 8bit values
    1.43 +        @param count    Number of entries in src[]
    1.44 +        @param dst      Buffer (allocated by caller) to write the packed data
    1.45 +                        into
    1.46 +        @return the number of bytes written to dst[]
    1.47 +    */
    1.48 +    static size_t Pack8(const uint8_t src[], int count, uint8_t dst[]);
    1.49 +
    1.50 +    /** Unpack the data in src[], and expand it into dst[]. The src[] data was
    1.51 +        written by a previous call to Pack16.
    1.52 +        @param src  Input data to unpack, previously created by Pack16.
    1.53 +        @param srcSize  Number of bytes of src to unpack
    1.54 +        @param dst  Buffer (allocated by caller) to expand the src[] into.
    1.55 +        @return the number of dst elements (not bytes) written into dst.
    1.56 +    */
    1.57 +    static int Unpack16(const uint8_t src[], size_t srcSize, uint16_t dst[]);
    1.58 +
    1.59 +    /** Unpack the data in src[], and expand it into dst[]. The src[] data was
    1.60 +        written by a previous call to Pack8.
    1.61 +        @param src      Input data to unpack, previously created by Pack8.
    1.62 +        @param srcSize  Number of bytes of src to unpack
    1.63 +        @param dst      Buffer (allocated by caller) to expand the src[] into.
    1.64 +        @return the number of bytes written into dst.
    1.65 +    */
    1.66 +    static int Unpack8(const uint8_t src[], size_t srcSize, uint8_t dst[]);
    1.67 +
    1.68 +    /** Unpack the data from src[], skip the first dstSkip bytes, then write
    1.69 +        dstWrite bytes into dst[]. The src[] data was written by a previous
    1.70 +        call to Pack8. Return the number of bytes actually writtten into dst[]
    1.71 +        @param src      Input data to unpack, previously created by Pack8.
    1.72 +        @param dst      Buffer (allocated by caller) to expand the src[] into.
    1.73 +        @param dstSkip  Number of bytes of unpacked src to skip before writing
    1.74 +                        into dst
    1.75 +        @param dstWrite Number of bytes of unpacked src to write into dst (after
    1.76 +                        skipping dstSkip bytes)
    1.77 +    */
    1.78 +    static void Unpack8(uint8_t dst[], size_t dstSkip, size_t dstWrite,
    1.79 +                        const uint8_t src[]);
    1.80 +};
    1.81 +
    1.82 +#endif

mercurial