| 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 #include "SkTextureCompressor_ASTC.h" | 8 #include "SkTextureCompressor_ASTC.h" |
| 9 #include "SkTextureCompressor_Blitter.h" | 9 #include "SkTextureCompressor_Blitter.h" |
| 10 | 10 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 // documented at this site: | 278 // documented at this site: |
| 279 // http://matthewarcus.wordpress.com/2012/11/18/reversing-a-64-bit-word/ | 279 // http://matthewarcus.wordpress.com/2012/11/18/reversing-a-64-bit-word/ |
| 280 | 280 |
| 281 template <typename T, T m, int k> | 281 template <typename T, T m, int k> |
| 282 static inline T swap_bits(T p) { | 282 static inline T swap_bits(T p) { |
| 283 T q = ((p>>k)^p) & m; | 283 T q = ((p>>k)^p) & m; |
| 284 return p^q^(q<<k); | 284 return p^q^(q<<k); |
| 285 } | 285 } |
| 286 | 286 |
| 287 static inline uint64_t reverse64(uint64_t n) { | 287 static inline uint64_t reverse64(uint64_t n) { |
| 288 static const uint64_t m0 = 0x5555555555555555LLU; | 288 static const uint64_t m0 = 0x5555555555555555ULL; |
| 289 static const uint64_t m1 = 0x0300c0303030c303LLU; | 289 static const uint64_t m1 = 0x0300c0303030c303ULL; |
| 290 static const uint64_t m2 = 0x00c0300c03f0003fLLU; | 290 static const uint64_t m2 = 0x00c0300c03f0003fULL; |
| 291 static const uint64_t m3 = 0x00000ffc00003fffLLU; | 291 static const uint64_t m3 = 0x00000ffc00003fffULL; |
| 292 n = ((n>>1)&m0) | (n&m0)<<1; | 292 n = ((n>>1)&m0) | (n&m0)<<1; |
| 293 n = swap_bits<uint64_t, m1, 4>(n); | 293 n = swap_bits<uint64_t, m1, 4>(n); |
| 294 n = swap_bits<uint64_t, m2, 8>(n); | 294 n = swap_bits<uint64_t, m2, 8>(n); |
| 295 n = swap_bits<uint64_t, m3, 20>(n); | 295 n = swap_bits<uint64_t, m3, 20>(n); |
| 296 n = (n >> 34) | (n << 30); | 296 n = (n >> 34) | (n << 30); |
| 297 return n; | 297 return n; |
| 298 } | 298 } |
| 299 | 299 |
| 300 // An ASTC block is 128 bits. We represent it as two 64-bit integers in order | 300 // An ASTC block is 128 bits. We represent it as two 64-bit integers in order |
| 301 // to efficiently operate on the block using bitwise operations. | 301 // to efficiently operate on the block using bitwise operations. |
| (...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2092 read_astc_block(&data, src); | 2092 read_astc_block(&data, src); |
| 2093 decompress_astc_block(reinterpret_cast<uint8_t*>(colorPtr + x), dstR
owBytes, data); | 2093 decompress_astc_block(reinterpret_cast<uint8_t*>(colorPtr + x), dstR
owBytes, data); |
| 2094 | 2094 |
| 2095 // ASTC encoded blocks are 16 bytes (128 bits) large. | 2095 // ASTC encoded blocks are 16 bytes (128 bits) large. |
| 2096 src += 16; | 2096 src += 16; |
| 2097 } | 2097 } |
| 2098 } | 2098 } |
| 2099 } | 2099 } |
| 2100 | 2100 |
| 2101 } // SkTextureCompressor | 2101 } // SkTextureCompressor |
| OLD | NEW |