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 "SkData.h" | 14 #include "SkData.h" |
15 #include "SkEndian.h" | 15 #include "SkEndian.h" |
16 | 16 |
17 #include "SkTextureCompression_opts.h" | 17 #include "SkTextureCompression_opts.h" |
18 | 18 |
19 //////////////////////////////////////////////////////////////////////////////// | 19 //////////////////////////////////////////////////////////////////////////////// |
20 | 20 |
21 namespace SkTextureCompressor { | 21 namespace SkTextureCompressor { |
22 | 22 |
robertphillips
2014/07/31 15:01:01
Is there a better name then hardware?
krajcevski
2014/07/31 15:12:18
Done.
| |
23 void GetBlockDimensions(Format format, int* dimX, int* dimY) { | 23 void GetBlockDimensions(Format format, int* dimX, int* dimY, bool hardware) { |
24 if (NULL == dimX || NULL == dimY) { | 24 if (NULL == dimX || NULL == dimY) { |
25 return; | 25 return; |
26 } | 26 } |
27 | 27 |
28 if (SkTextureCompressorGetPlatformDims(format, dimX, dimY)) { | 28 if (!hardware && SkTextureCompressorGetPlatformDims(format, dimX, dimY)) { |
29 return; | 29 return; |
30 } | 30 } |
31 | 31 |
32 switch(format) { | 32 switch(format) { |
33 // These formats are 64 bits per 4x4 block. | 33 // These formats are 64 bits per 4x4 block. |
34 default: | 34 default: |
35 SkDEBUGFAIL("Unknown compression format!"); | 35 SkDEBUGFAIL("Unknown compression format!"); |
36 // fall through | 36 // fall through |
37 case kR11_EAC_Format: | 37 case kR11_EAC_Format: |
38 case kLATC_Format: | 38 case kLATC_Format: |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 case kASTC_12x12_Format: | 152 case kASTC_12x12_Format: |
153 return CreateASTCBlitter(width, height, compressedBuffer); | 153 return CreateASTCBlitter(width, height, compressedBuffer); |
154 | 154 |
155 default: | 155 default: |
156 return NULL; | 156 return NULL; |
157 } | 157 } |
158 | 158 |
159 return NULL; | 159 return NULL; |
160 } | 160 } |
161 | 161 |
162 bool DecompressBufferFromFormat(uint8_t* dst, int dstRowBytes, const uint8_t* sr c, | |
163 int width, int height, Format format) { | |
164 int dimX, dimY; | |
165 GetBlockDimensions(format, &dimX, &dimY, true); | |
166 | |
167 if (width < 0 || ((width % dimX) != 0) || height < 0 || ((height % dimY) != 0)) { | |
168 return false; | |
169 } | |
170 | |
171 switch(format) { | |
172 case kLATC_Format: | |
173 DecompressLATC(dst, dstRowBytes, src, width, height); | |
174 return true; | |
175 | |
176 case kR11_EAC_Format: | |
177 DecompressR11EAC(dst, dstRowBytes, src, width, height); | |
178 return true; | |
179 | |
180 case kASTC_12x12_Format: | |
181 // TODO(krajcevski) .. right now just fall through and return false. | |
182 return false; | |
183 } | |
184 | |
185 return false; | |
186 } | |
187 | |
162 } // namespace SkTextureCompressor | 188 } // namespace SkTextureCompressor |
OLD | NEW |