Chromium Code Reviews| Index: src/utils/SkTextureCompressor.cpp |
| diff --git a/src/utils/SkTextureCompressor.cpp b/src/utils/SkTextureCompressor.cpp |
| index 4034615b37f389a024547be0116574eb3e580f7a..05181425276b1371571be6ed6b7570babe4bb63b 100644 |
| --- a/src/utils/SkTextureCompressor.cpp |
| +++ b/src/utils/SkTextureCompressor.cpp |
| @@ -44,24 +44,31 @@ void GetBlockDimensions(Format format, int* dimX, int* dimY, bool matchSpec) { |
| } |
| // No specialized arguments, return the dimensions as they are in the spec. |
| - switch(format) { |
| - // These formats are 64 bits per 4x4 block. |
| - default: |
| - SkDEBUGFAIL("Unknown compression format!"); |
| - // fall through |
| - case kLATC_Format: |
| - case kR11_EAC_Format: |
| - case kETC1_Format: |
| - *dimX = 4; |
| - *dimY = 4; |
| - break; |
| - |
| - // This format is 12x12 blocks to 128 bits. |
| - case kASTC_12x12_Format: |
| - *dimX = 12; |
| - *dimY = 12; |
| - break; |
| - } |
| + static const struct FormatDimensions { |
| + const int fBlockSizeX; |
| + const int fBlockSizeY; |
| + } kFormatDimensions[kFormatCnt] = { |
| + { 4, 4 }, // kLATC_Format |
| + { 4, 4 }, // kR11_EAC_Format |
| + { 4, 4 }, // kETC1_Format |
| + { 4, 4 }, // kASTC_4x4_Format |
| + { 5, 4 }, // kASTC_5x4_Format |
| + { 5, 5 }, // kASTC_5x5_Format |
| + { 6, 5 }, // kASTC_6x5_Format |
| + { 6, 6 }, // kASTC_6x6_Format |
| + { 8, 5 }, // kASTC_8x5_Format |
| + { 8, 6 }, // kASTC_8x6_Format |
| + { 8, 8 }, // kASTC_8x8_Format |
| + { 10, 5 }, // kASTC_10x5_Format |
| + { 10, 6 }, // kASTC_10x6_Format |
| + { 10, 8 }, // kASTC_10x8_Format |
| + { 10, 10 }, // kASTC_10x10_Format |
| + { 12, 10 }, // kASTC_12x10_Format |
| + { 12, 12 }, // kASTC_12x12_Format |
| + }; |
| + |
| + *dimX = kFormatDimensions[format].fBlockSizeX; |
| + *dimY = kFormatDimensions[format].fBlockSizeY; |
| } |
| int GetCompressedDataSize(Format fmt, int width, int height) { |
| @@ -78,7 +85,20 @@ int GetCompressedDataSize(Format fmt, int width, int height) { |
| encodedBlockSize = 8; |
| break; |
| - // This format is 12x12 blocks to 128 bits. |
| + // This format is 128 bits. |
| + case kASTC_4x4_Format: |
| + case kASTC_5x4_Format: |
| + case kASTC_5x5_Format: |
| + case kASTC_6x5_Format: |
| + case kASTC_6x6_Format: |
| + case kASTC_8x5_Format: |
| + case kASTC_8x6_Format: |
| + case kASTC_8x8_Format: |
| + case kASTC_10x5_Format: |
| + case kASTC_10x6_Format: |
| + case kASTC_10x8_Format: |
| + case kASTC_10x10_Format: |
| + case kASTC_12x10_Format: |
| case kASTC_12x12_Format: |
| encodedBlockSize = 16; |
| break; |
| @@ -212,9 +232,62 @@ bool DecompressBufferFromFormat(uint8_t* dst, int dstRowBytes, const uint8_t* sr |
| case kETC1_Format: |
| return 0 == etc1_decode_image(src, dst, width, height, 3, dstRowBytes); |
| #endif |
| + |
|
robertphillips
2014/08/06 21:13:15
Can we not have all these fall through and call Ge
krajcevski
2014/08/06 22:31:00
Can't believe I didn't think of that.
|
| + case kASTC_4x4_Format: |
| + DecompressASTC(dst, dstRowBytes, src, width, height, 4, 4); |
| + return true; |
| + |
| + case kASTC_5x4_Format: |
| + DecompressASTC(dst, dstRowBytes, src, width, height, 5, 4); |
| + return true; |
| + |
| + case kASTC_5x5_Format: |
| + DecompressASTC(dst, dstRowBytes, src, width, height, 5, 5); |
| + return true; |
| + |
| + case kASTC_6x5_Format: |
| + DecompressASTC(dst, dstRowBytes, src, width, height, 6, 5); |
| + return true; |
| + |
| + case kASTC_6x6_Format: |
| + DecompressASTC(dst, dstRowBytes, src, width, height, 6, 6); |
| + return true; |
| + |
| + case kASTC_8x5_Format: |
| + DecompressASTC(dst, dstRowBytes, src, width, height, 8, 5); |
| + return true; |
| + |
| + case kASTC_8x6_Format: |
| + DecompressASTC(dst, dstRowBytes, src, width, height, 8, 6); |
| + return true; |
| + |
| + case kASTC_8x8_Format: |
| + DecompressASTC(dst, dstRowBytes, src, width, height, 8, 8); |
| + return true; |
| + |
| + case kASTC_10x5_Format: |
| + DecompressASTC(dst, dstRowBytes, src, width, height, 10, 5); |
| + return true; |
| + |
| + case kASTC_10x6_Format: |
| + DecompressASTC(dst, dstRowBytes, src, width, height, 10, 6); |
| + return true; |
| + |
| + case kASTC_10x8_Format: |
| + DecompressASTC(dst, dstRowBytes, src, width, height, 10, 8); |
| + return true; |
| + |
| + case kASTC_10x10_Format: |
| + DecompressASTC(dst, dstRowBytes, src, width, height, 10, 10); |
| + return true; |
| + |
| + case kASTC_12x10_Format: |
| + DecompressASTC(dst, dstRowBytes, src, width, height, 12, 10); |
| + return true; |
| + |
| case kASTC_12x12_Format: |
| - // TODO(krajcevski) .. right now just fall through and return false. |
| - return false; |
| + DecompressASTC(dst, dstRowBytes, src, width, height, 12, 12); |
| + return true; |
| default: |
| // Do nothing... |