| 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.h" | 8 #include "SkTextureCompressor.h" |
| 9 #include "SkTextureCompressor_ASTC.h" | 9 #include "SkTextureCompressor_ASTC.h" |
| 10 #include "SkTextureCompressor_LATC.h" | 10 #include "SkTextureCompressor_LATC.h" |
| 11 #include "SkTextureCompressor_R11EAC.h" | 11 #include "SkTextureCompressor_R11EAC.h" |
| 12 | 12 |
| 13 #include "SkBitmap.h" | 13 #include "SkBitmap.h" |
| 14 #include "SkBitmapProcShader.h" | 14 #include "SkBitmapProcShader.h" |
| 15 #include "SkData.h" | 15 #include "SkData.h" |
| 16 #include "SkEndian.h" | 16 #include "SkEndian.h" |
| 17 | 17 |
| 18 #include "SkTextureCompression_opts.h" | 18 #include "SkTextureCompression_opts.h" |
| 19 | 19 |
| 20 #ifndef SK_IGNORE_ETC1_SUPPORT | 20 #ifndef SK_IGNORE_ETC1_SUPPORT |
| 21 # include "etc1.h" | 21 # include "etc1.h" |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 // Convert ETC1 functions to our function signatures | 24 // Convert ETC1 functions to our function signatures |
| 25 static bool compress_etc1_565(uint8_t* dst, const uint8_t* src, | 25 static bool compress_etc1_565(uint8_t* dst, const uint8_t* src, |
| 26 int width, int height, int rowBytes) { | 26 int width, int height, size_t rowBytes) { |
| 27 #ifndef SK_IGNORE_ETC1_SUPPORT | 27 #ifndef SK_IGNORE_ETC1_SUPPORT |
| 28 return 0 == etc1_encode_image(src, width, height, 2, rowBytes, dst); | 28 return 0 == etc1_encode_image(src, width, height, 2, SkToInt(rowBytes), dst)
; |
| 29 #else | 29 #else |
| 30 return false; | 30 return false; |
| 31 #endif | 31 #endif |
| 32 } | 32 } |
| 33 | 33 |
| 34 //////////////////////////////////////////////////////////////////////////////// | 34 //////////////////////////////////////////////////////////////////////////////// |
| 35 | 35 |
| 36 namespace SkTextureCompressor { | 36 namespace SkTextureCompressor { |
| 37 | 37 |
| 38 void GetBlockDimensions(Format format, int* dimX, int* dimY, bool matchSpec) { | 38 void GetBlockDimensions(Format format, int* dimX, int* dimY, bool matchSpec) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 const int blocksX = width / dimX; | 113 const int blocksX = width / dimX; |
| 114 const int blocksY = height / dimY; | 114 const int blocksY = height / dimY; |
| 115 | 115 |
| 116 return blocksX * blocksY * encodedBlockSize; | 116 return blocksX * blocksY * encodedBlockSize; |
| 117 } | 117 } |
| 118 | 118 |
| 119 return -1; | 119 return -1; |
| 120 } | 120 } |
| 121 | 121 |
| 122 bool CompressBufferToFormat(uint8_t* dst, const uint8_t* src, SkColorType srcCol
orType, | 122 bool CompressBufferToFormat(uint8_t* dst, const uint8_t* src, SkColorType srcCol
orType, |
| 123 int width, int height, int rowBytes, Format format,
bool opt) { | 123 int width, int height, size_t rowBytes, Format forma
t, bool opt) { |
| 124 CompressionProc proc = NULL; | 124 CompressionProc proc = NULL; |
| 125 if (opt) { | 125 if (opt) { |
| 126 proc = SkTextureCompressorGetPlatformProc(srcColorType, format); | 126 proc = SkTextureCompressorGetPlatformProc(srcColorType, format); |
| 127 } | 127 } |
| 128 | 128 |
| 129 if (NULL == proc) { | 129 if (NULL == proc) { |
| 130 switch (srcColorType) { | 130 switch (srcColorType) { |
| 131 case kAlpha_8_SkColorType: | 131 case kAlpha_8_SkColorType: |
| 132 { | 132 { |
| 133 switch (format) { | 133 switch (format) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 | 253 |
| 254 default: | 254 default: |
| 255 // Do nothing... | 255 // Do nothing... |
| 256 break; | 256 break; |
| 257 } | 257 } |
| 258 | 258 |
| 259 return false; | 259 return false; |
| 260 } | 260 } |
| 261 | 261 |
| 262 } // namespace SkTextureCompressor | 262 } // namespace SkTextureCompressor |
| OLD | NEW |