Chromium Code Reviews| Index: src/utils/SkTextureCompressor.cpp |
| diff --git a/src/utils/SkTextureCompressor.cpp b/src/utils/SkTextureCompressor.cpp |
| index c4a6293ed26f6a4407a0f20332e088a8119b8319..a41a8e94d80d9a2dade8a9f36c40a9e0e8c4500e 100644 |
| --- a/src/utils/SkTextureCompressor.cpp |
| +++ b/src/utils/SkTextureCompressor.cpp |
| @@ -11,6 +11,8 @@ |
| #include "SkData.h" |
| #include "SkEndian.h" |
| +#include "SkTextureCompression_opts.h" |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // |
| // Utility Functions |
| @@ -586,15 +588,14 @@ static inline uint64_t interleave6(uint64_t topRows, uint64_t bottomRows) { |
| // x: b f 00 00 00 a e c g i m 00 00 00 d h j n 00 k o 00 l p |
| - x |= ((x << 52) & (0x3FULL << 52)); |
| - x = (x | ((x << 20) & (0x3FULL << 28))) >> 16; |
| + x = (x | ((x << 52) & (0x3FULL << 52)) | ((x << 20) & (0x3FULL << 28))) >> 16; |
| -#if defined (SK_CPU_BENDIAN) |
| // x: 00 00 00 00 00 00 00 00 b f l p a e c g i m k o d h j n |
| t = (x ^ (x >> 6)) & 0xFC0000ULL; |
| x = x ^ t ^ (t << 6); |
| +#if defined (SK_CPU_BENDIAN) |
| // x: 00 00 00 00 00 00 00 00 b f l p a e i m c g k o d h j n |
| t = (x ^ (x >> 36)) & 0x3FULL; |
| @@ -610,11 +611,6 @@ static inline uint64_t interleave6(uint64_t topRows, uint64_t bottomRows) { |
| #else |
| // If our CPU is little endian, then the above logic will |
| // produce the following indices: |
| - // x: 00 00 00 00 00 00 00 00 c g i m d h b f l p j n a e k o |
| - |
| - t = (x ^ (x >> 6)) & 0xFC0000ULL; |
|
mtklein
2014/07/11 15:24:27
Removing this was intentional?
krajcevski
2014/07/11 16:11:47
Yes, it was the same as line 595 above, which I mo
|
| - x = x ^ t ^ (t << 6); |
| - |
| // x: 00 00 00 00 00 00 00 00 c g i m d h l p b f j n a e k o |
| t = (x ^ (x >> 36)) & 0xFC0ULL; |
| @@ -770,19 +766,31 @@ static inline size_t get_compressed_data_size(Format fmt, int width, int height) |
| } |
| } |
| -typedef bool (*CompressBitmapProc)(uint8_t* dst, const uint8_t* src, |
| - int width, int height, int rowBytes); |
| - |
| -bool CompressBufferToFormat(uint8_t* dst, const uint8_t* src, SkColorType srcColorType, |
| - int width, int height, int rowBytes, Format format) { |
| +static class CompressionProcTable |
| +{ |
| +public: |
| + CompressionProcTable() { |
|
mtklein
2014/07/11 15:24:27
We try to avoid static initializers when possible.
krajcevski
2014/07/11 16:11:47
Done.
|
| + memset(kProcMap, 0, sizeof(kProcMap)); |
| + |
| + kProcMap[kLATC_Format][kAlpha_8_SkColorType] = compress_a8_to_latc; |
| + kProcMap[kR11_EAC_Format][kAlpha_8_SkColorType] = compress_a8_to_r11eac; |
| + CompressionProc r11opt = SkTextureCompressorGetPlatformProc(kR11_EAC_Format); |
| + if (NULL != r11opt) { |
| + kProcMap[kR11_EAC_Format][kAlpha_8_SkColorType] = r11opt; |
| + } |
| + } |
| - CompressBitmapProc kProcMap[kFormatCnt][kLastEnum_SkColorType + 1]; |
| - memset(kProcMap, 0, sizeof(kProcMap)); |
| + CompressionProc getProc(SkColorType colorType, Format fmt) const { |
| + return kProcMap[fmt][colorType]; |
| + } |
| - kProcMap[kLATC_Format][kAlpha_8_SkColorType] = compress_a8_to_latc; |
| - kProcMap[kR11_EAC_Format][kAlpha_8_SkColorType] = compress_a8_to_r11eac; |
| +private: |
| + CompressionProc kProcMap[kFormatCnt][kLastEnum_SkColorType + 1]; |
| +} kCompressionProcTable; |
| - CompressBitmapProc proc = kProcMap[format][srcColorType]; |
| +bool CompressBufferToFormat(uint8_t* dst, const uint8_t* src, SkColorType srcColorType, |
| + int width, int height, int rowBytes, Format format) { |
| + CompressionProc proc = kCompressionProcTable.getProc(srcColorType, format); |
| if (NULL != proc) { |
| return proc(dst, src, width, height, rowBytes); |
| } |