OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkTextureCompressor_DEFINED | 8 #ifndef SkTextureCompressor_DEFINED |
9 #define SkTextureCompressor_DEFINED | 9 #define SkTextureCompressor_DEFINED |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 }; | 49 }; |
50 static const int kFormatCnt = kLast_Format + 1; | 50 static const int kFormatCnt = kLast_Format + 1; |
51 | 51 |
52 // Returns the size of the compressed data given the width, height, and | 52 // Returns the size of the compressed data given the width, height, and |
53 // desired compression format. If the width and height are not an appropriat
e | 53 // desired compression format. If the width and height are not an appropriat
e |
54 // multiple of the block size, then this function returns an error (-1). | 54 // multiple of the block size, then this function returns an error (-1). |
55 int GetCompressedDataSize(Format fmt, int width, int height); | 55 int GetCompressedDataSize(Format fmt, int width, int height); |
56 | 56 |
57 // Returns an SkData holding a blob of compressed data that corresponds | 57 // Returns an SkData holding a blob of compressed data that corresponds |
58 // to the pixmap. If the pixmap colorType cannot be compressed using the | 58 // to the pixmap. If the pixmap colorType cannot be compressed using the |
59 // associated format, then we return nullptr. The caller is responsible for | 59 // associated format, then we return nullptr. |
60 // calling unref() on the returned data. | 60 sk_sp<SkData> CompressBitmapToFormat(const SkPixmap&, Format format); |
61 SkData* CompressBitmapToFormat(const SkPixmap&, Format format); | |
62 | 61 |
63 // Compresses the given src data into dst. The src data is assumed to be | 62 // Compresses the given src data into dst. The src data is assumed to be |
64 // large enough to hold width*height pixels. The dst data is expected to | 63 // large enough to hold width*height pixels. The dst data is expected to |
65 // be large enough to hold the compressed data according to the format. | 64 // be large enough to hold the compressed data according to the format. |
66 bool CompressBufferToFormat(uint8_t* dst, const uint8_t* src, SkColorType sr
cColorType, | 65 bool CompressBufferToFormat(uint8_t* dst, const uint8_t* src, SkColorType sr
cColorType, |
67 int width, int height, size_t rowBytes, Format f
ormat); | 66 int width, int height, size_t rowBytes, Format f
ormat); |
68 | 67 |
69 // Decompresses the given src data from the format specified into the | 68 // Decompresses the given src data from the format specified into the |
70 // destination buffer. The width and height of the data passed corresponds | 69 // destination buffer. The width and height of the data passed corresponds |
71 // to the width and height of the uncompressed image. The destination buffer
(dst) | 70 // to the width and height of the uncompressed image. The destination buffer
(dst) |
(...skipping 30 matching lines...) Expand all Loading... |
102 // Returns the desired dimensions of the block size for the given format. Th
ese dimensions | 101 // Returns the desired dimensions of the block size for the given format. Th
ese dimensions |
103 // don't necessarily correspond to the specification's dimensions, since the
re may | 102 // don't necessarily correspond to the specification's dimensions, since the
re may |
104 // be specialized algorithms that operate on multiple blocks at once. If the | 103 // be specialized algorithms that operate on multiple blocks at once. If the |
105 // flag 'matchSpec' is true, then the actual dimensions from the specificati
on are | 104 // flag 'matchSpec' is true, then the actual dimensions from the specificati
on are |
106 // returned. If the flag is false, then these dimensions reflect the appropr
iate operable | 105 // returned. If the flag is false, then these dimensions reflect the appropr
iate operable |
107 // dimensions of the compression functions. | 106 // dimensions of the compression functions. |
108 void GetBlockDimensions(Format format, int* dimX, int* dimY, bool matchSpec
= false); | 107 void GetBlockDimensions(Format format, int* dimX, int* dimY, bool matchSpec
= false); |
109 } | 108 } |
110 | 109 |
111 #endif | 110 #endif |
OLD | NEW |