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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 bitmap. If the bitmap colorType cannot be compressed using the | 58 // to the bitmap. If the bitmap colorType cannot be compressed using the |
59 // associated format, then we return NULL. The caller is responsible for | 59 // associated format, then we return NULL. The caller is responsible for |
60 // calling unref() on the returned data. | 60 // calling unref() on the returned data. |
61 SkData* CompressBitmapToFormat(const SkBitmap& bitmap, Format format); | 61 SkData* CompressBitmapToFormat(const SkBitmap& bitmap, Format format); |
62 | 62 |
63 // Compresses the given src data into dst. The src data is assumed to be | 63 // 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 | 64 // 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. | 65 // 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, | 66 bool CompressBufferToFormat(uint8_t* dst, const uint8_t* src, SkColorType sr
cColorType, |
67 int width, int height, int rowBytes, Format form
at, | 67 int width, int height, size_t rowBytes, Format f
ormat, |
68 bool opt = true /* Use optimization if available
*/); | 68 bool opt = true /* Use optimization if available
*/); |
69 | 69 |
70 // Decompresses the given src data from the format specified into the | 70 // Decompresses the given src data from the format specified into the |
71 // destination buffer. The width and height of the data passed corresponds | 71 // destination buffer. The width and height of the data passed corresponds |
72 // to the width and height of the uncompressed image. The destination buffer
(dst) | 72 // to the width and height of the uncompressed image. The destination buffer
(dst) |
73 // is assumed to be large enough to hold the entire decompressed image. The | 73 // is assumed to be large enough to hold the entire decompressed image. The |
74 // decompressed image colors are determined based on the passed format. | 74 // decompressed image colors are determined based on the passed format. |
75 // | 75 // |
76 // Note, CompressBufferToFormat compresses A8 data into ASTC. However, | 76 // Note, CompressBufferToFormat compresses A8 data into ASTC. However, |
77 // general ASTC data encodes RGBA data, so that is what the decompressor | 77 // general ASTC data encodes RGBA data, so that is what the decompressor |
78 // operates on. | 78 // operates on. |
79 // | 79 // |
80 // Returns true if successfully decompresses the src data. | 80 // Returns true if successfully decompresses the src data. |
81 bool DecompressBufferFromFormat(uint8_t* dst, int dstRowBytes, const uint8_t
* src, | 81 bool DecompressBufferFromFormat(uint8_t* dst, int dstRowBytes, const uint8_t
* src, |
82 int width, int height, Format format); | 82 int width, int height, Format format); |
83 | 83 |
84 // This typedef defines what the nominal aspects of a compression function | 84 // This typedef defines what the nominal aspects of a compression function |
85 // are. The typedef is not meant to be used by clients of the API, but rathe
r | 85 // are. The typedef is not meant to be used by clients of the API, but rathe
r |
86 // allows SIMD optimized compression functions to be implemented. | 86 // allows SIMD optimized compression functions to be implemented. |
87 typedef bool (*CompressionProc)(uint8_t* dst, const uint8_t* src, | 87 typedef bool (*CompressionProc)(uint8_t* dst, const uint8_t* src, |
88 int width, int height, int rowBytes); | 88 int width, int height, size_t rowBytes); |
89 | 89 |
90 // Returns true if there exists a blitter for the specified format. | 90 // Returns true if there exists a blitter for the specified format. |
91 inline bool ExistsBlitterForFormat(Format format) { | 91 inline bool ExistsBlitterForFormat(Format format) { |
92 switch (format) { | 92 switch (format) { |
93 case kLATC_Format: | 93 case kLATC_Format: |
94 case kR11_EAC_Format: | 94 case kR11_EAC_Format: |
95 case kASTC_12x12_Format: | 95 case kASTC_12x12_Format: |
96 return true; | 96 return true; |
97 | 97 |
98 default: | 98 default: |
(...skipping 10 matching lines...) Expand all Loading... |
109 // Returns the desired dimensions of the block size for the given format. Th
ese dimensions | 109 // Returns the desired dimensions of the block size for the given format. Th
ese dimensions |
110 // don't necessarily correspond to the specification's dimensions, since the
re may | 110 // don't necessarily correspond to the specification's dimensions, since the
re may |
111 // be specialized algorithms that operate on multiple blocks at once. If the | 111 // be specialized algorithms that operate on multiple blocks at once. If the |
112 // flag 'matchSpec' is true, then the actual dimensions from the specificati
on are | 112 // flag 'matchSpec' is true, then the actual dimensions from the specificati
on are |
113 // returned. If the flag is false, then these dimensions reflect the appropr
iate operable | 113 // returned. If the flag is false, then these dimensions reflect the appropr
iate operable |
114 // dimensions of the compression functions. | 114 // dimensions of the compression functions. |
115 void GetBlockDimensions(Format format, int* dimX, int* dimY, bool matchSpec
= false); | 115 void GetBlockDimensions(Format format, int* dimX, int* dimY, bool matchSpec
= false); |
116 } | 116 } |
117 | 117 |
118 #endif | 118 #endif |
OLD | NEW |