| 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 26 matching lines...) Expand all Loading... |
| 37 // calling unref() on the returned data. | 37 // calling unref() on the returned data. |
| 38 SkData* CompressBitmapToFormat(const SkBitmap& bitmap, Format format); | 38 SkData* CompressBitmapToFormat(const SkBitmap& bitmap, Format format); |
| 39 | 39 |
| 40 // Compresses the given src data into dst. The src data is assumed to be | 40 // Compresses the given src data into dst. The src data is assumed to be |
| 41 // large enough to hold width*height pixels. The dst data is expected to | 41 // large enough to hold width*height pixels. The dst data is expected to |
| 42 // be large enough to hold the compressed data according to the format. | 42 // be large enough to hold the compressed data according to the format. |
| 43 bool CompressBufferToFormat(uint8_t* dst, const uint8_t* src, SkColorType sr
cColorType, | 43 bool CompressBufferToFormat(uint8_t* dst, const uint8_t* src, SkColorType sr
cColorType, |
| 44 int width, int height, int rowBytes, Format form
at, | 44 int width, int height, int rowBytes, Format form
at, |
| 45 bool opt = true /* Use optimization if available
*/); | 45 bool opt = true /* Use optimization if available
*/); |
| 46 | 46 |
| 47 // Decompresses the given src data from the format specified into the | |
| 48 // destination buffer. The width and height of the data passed corresponds | |
| 49 // to the width and height of the uncompressed image. The destination buffer
(dst) | |
| 50 // is assumed to be large enough to hold the entire decompressed image. The | |
| 51 // decompressed image colors are determined based on the passed format: | |
| 52 // | |
| 53 // LATC -> Alpha 8 | |
| 54 // R11_EAC -> Alpha 8 | |
| 55 // ASTC -> RGBA | |
| 56 // | |
| 57 // Note, CompressBufferToFormat compresses A8 data into ASTC. However, | |
| 58 // general ASTC data encodes RGBA data, so that is what the decompressor | |
| 59 // operates on. | |
| 60 // | |
| 61 // Returns true if successfully decompresses the src data. | |
| 62 bool DecompressBufferFromFormat(uint8_t* dst, int dstRowBytes, const uint8_t
* src, | |
| 63 int width, int height, Format format); | |
| 64 | |
| 65 // This typedef defines what the nominal aspects of a compression function | 47 // This typedef defines what the nominal aspects of a compression function |
| 66 // are. The typedef is not meant to be used by clients of the API, but rathe
r | 48 // are. The typedef is not meant to be used by clients of the API, but rathe
r |
| 67 // allows SIMD optimized compression functions to be implemented. | 49 // allows SIMD optimized compression functions to be implemented. |
| 68 typedef bool (*CompressionProc)(uint8_t* dst, const uint8_t* src, | 50 typedef bool (*CompressionProc)(uint8_t* dst, const uint8_t* src, |
| 69 int width, int height, int rowBytes); | 51 int width, int height, int rowBytes); |
| 70 | 52 |
| 71 // Returns the blitter for the given compression format. Note, the blitter | 53 // Returns the blitter for the given compression format. Note, the blitter |
| 72 // is intended to be used with the proper input. I.e. if you try to blit | 54 // is intended to be used with the proper input. I.e. if you try to blit |
| 73 // RGB source data into an R11 EAC texture, you're gonna have a bad time. | 55 // RGB source data into an R11 EAC texture, you're gonna have a bad time. |
| 74 SkBlitter* CreateBlitterForFormat(int width, int height, void* compressedBuf
fer, | 56 SkBlitter* CreateBlitterForFormat(int width, int height, void* compressedBuf
fer, |
| 75 Format format); | 57 Format format); |
| 76 | 58 |
| 77 // Returns the desired dimensions of the block size for the given format. Th
ese dimensions | 59 // Returns the desired dimensions of the block size for the given format. Th
ese dimensions |
| 78 // don't necessarily correspond to the specification's dimensions, since the
re may | 60 // don't necessarily correspond to the hardware-specified dimensions, since
there may |
| 79 // be specialized algorithms that operate on multiple blocks at once. If the | 61 // be specialized algorithms that operate on multiple blocks at once. These
dimensions |
| 80 // flag 'matchSpec' is true, then the actual dimensions from the specificati
on are | 62 // reflect that optimization and return the appropriate operable dimensions. |
| 81 // returned. If the flag is false, then these dimensions reflect the appropr
iate operable | 63 void GetBlockDimensions(Format format, int* dimX, int* dimY); |
| 82 // dimensions of the compression functions. | |
| 83 void GetBlockDimensions(Format format, int* dimX, int* dimY, bool matchSpec
= false); | |
| 84 } | 64 } |
| 85 | 65 |
| 86 #endif | 66 #endif |
| OLD | NEW |