| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 // Reverse each 3-bit index since indices are read in reverse order... | 249 // Reverse each 3-bit index since indices are read in reverse order... |
| 250 uint64_t t = (bottom ^ (bottom >> 2)) & 0x2492492492492492ULL; | 250 uint64_t t = (bottom ^ (bottom >> 2)) & 0x2492492492492492ULL; |
| 251 bottom = bottom ^ t ^ (t << 2); | 251 bottom = bottom ^ t ^ (t << 2); |
| 252 | 252 |
| 253 t = (top ^ (top >> 2)) & 0x0924924000000000ULL; | 253 t = (top ^ (top >> 2)) & 0x0924924000000000ULL; |
| 254 top = top ^ t ^ (t << 2); | 254 top = top ^ t ^ (t << 2); |
| 255 | 255 |
| 256 send_packing(dst, SkEndian_SwapLE64(top), SkEndian_SwapLE64(bottom)); | 256 send_packing(dst, SkEndian_SwapLE64(top), SkEndian_SwapLE64(bottom)); |
| 257 } | 257 } |
| 258 | 258 |
| 259 inline void compress_a8_astc_block_vertical(uint8_t* dst, const uint8_t* src) { | 259 inline void CompressA8ASTCBlockVertical(uint8_t* dst, const uint8_t* src) { |
| 260 compress_a8_astc_block<GetAlphaTranspose>(&dst, src, 12); | 260 compress_a8_astc_block<GetAlphaTranspose>(&dst, src, 12); |
| 261 } | 261 } |
| 262 | 262 |
| 263 //////////////////////////////////////////////////////////////////////////////// | 263 //////////////////////////////////////////////////////////////////////////////// |
| 264 | 264 |
| 265 namespace SkTextureCompressor { | 265 namespace SkTextureCompressor { |
| 266 | 266 |
| 267 bool CompressA8To12x12ASTC(uint8_t* dst, const uint8_t* src, int width, int heig
ht, int rowBytes) { | 267 bool CompressA8To12x12ASTC(uint8_t* dst, const uint8_t* src, int width, int heig
ht, int rowBytes) { |
| 268 if (width < 0 || ((width % 12) != 0) || height < 0 || ((height % 12) != 0))
{ | 268 if (width < 0 || ((width % 12) != 0) || height < 0 || ((height % 12) != 0))
{ |
| 269 return false; | 269 return false; |
| 270 } | 270 } |
| 271 | 271 |
| 272 uint8_t** dstPtr = &dst; | 272 uint8_t** dstPtr = &dst; |
| 273 for (int y = 0; y < height; y+=12) { | 273 for (int y = 0; y < height; y+=12) { |
| 274 for (int x = 0; x < width; x+=12) { | 274 for (int x = 0; x < width; x+=12) { |
| 275 compress_a8_astc_block<GetAlpha>(dstPtr, src + y*rowBytes + x, rowBy
tes); | 275 compress_a8_astc_block<GetAlpha>(dstPtr, src + y*rowBytes + x, rowBy
tes); |
| 276 } | 276 } |
| 277 } | 277 } |
| 278 | 278 |
| 279 return true; | 279 return true; |
| 280 } | 280 } |
| 281 | 281 |
| 282 SkBlitter* CreateASTCBlitter(int width, int height, void* outputBuffer) { | 282 SkBlitter* CreateASTCBlitter(int width, int height, void* outputBuffer) { |
| 283 return new | 283 return new |
| 284 SkTCompressedAlphaBlitter<12, 16, compress_a8_astc_block_vertical> | 284 SkTCompressedAlphaBlitter<12, 16, CompressA8ASTCBlockVertical> |
| 285 (width, height, outputBuffer); | 285 (width, height, outputBuffer); |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // SkTextureCompressor | 288 } // SkTextureCompressor |
| OLD | NEW |