Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/utils/SkTextureCompressor.cpp

Issue 447343002: Revert of - Add astcbitmap to gm slides (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/utils/SkTextureCompressor.h ('k') | src/utils/SkTextureCompressor_ASTC.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 26 matching lines...) Expand all
37 void GetBlockDimensions(Format format, int* dimX, int* dimY, bool matchSpec) { 37 void GetBlockDimensions(Format format, int* dimX, int* dimY, bool matchSpec) {
38 if (NULL == dimX || NULL == dimY) { 38 if (NULL == dimX || NULL == dimY) {
39 return; 39 return;
40 } 40 }
41 41
42 if (!matchSpec && SkTextureCompressorGetPlatformDims(format, dimX, dimY)) { 42 if (!matchSpec && SkTextureCompressorGetPlatformDims(format, dimX, dimY)) {
43 return; 43 return;
44 } 44 }
45 45
46 // No specialized arguments, return the dimensions as they are in the spec. 46 // No specialized arguments, return the dimensions as they are in the spec.
47 static const struct FormatDimensions { 47 switch(format) {
48 const int fBlockSizeX; 48 // These formats are 64 bits per 4x4 block.
49 const int fBlockSizeY; 49 default:
50 } kFormatDimensions[kFormatCnt] = { 50 SkDEBUGFAIL("Unknown compression format!");
51 { 4, 4 }, // kLATC_Format 51 // fall through
52 { 4, 4 }, // kR11_EAC_Format 52 case kLATC_Format:
53 { 4, 4 }, // kETC1_Format 53 case kR11_EAC_Format:
54 { 4, 4 }, // kASTC_4x4_Format 54 case kETC1_Format:
55 { 5, 4 }, // kASTC_5x4_Format 55 *dimX = 4;
56 { 5, 5 }, // kASTC_5x5_Format 56 *dimY = 4;
57 { 6, 5 }, // kASTC_6x5_Format 57 break;
58 { 6, 6 }, // kASTC_6x6_Format
59 { 8, 5 }, // kASTC_8x5_Format
60 { 8, 6 }, // kASTC_8x6_Format
61 { 8, 8 }, // kASTC_8x8_Format
62 { 10, 5 }, // kASTC_10x5_Format
63 { 10, 6 }, // kASTC_10x6_Format
64 { 10, 8 }, // kASTC_10x8_Format
65 { 10, 10 }, // kASTC_10x10_Format
66 { 12, 10 }, // kASTC_12x10_Format
67 { 12, 12 }, // kASTC_12x12_Format
68 };
69 58
70 *dimX = kFormatDimensions[format].fBlockSizeX; 59 // This format is 12x12 blocks to 128 bits.
71 *dimY = kFormatDimensions[format].fBlockSizeY; 60 case kASTC_12x12_Format:
61 *dimX = 12;
62 *dimY = 12;
63 break;
64 }
72 } 65 }
73 66
74 int GetCompressedDataSize(Format fmt, int width, int height) { 67 int GetCompressedDataSize(Format fmt, int width, int height) {
75 int dimX, dimY; 68 int dimX, dimY;
76 GetBlockDimensions(fmt, &dimX, &dimY, true); 69 GetBlockDimensions(fmt, &dimX, &dimY, true);
77 70
78 int encodedBlockSize = 0; 71 int encodedBlockSize = 0;
79 72
80 switch (fmt) { 73 switch (fmt) {
81 // These formats are 64 bits per 4x4 block. 74 // These formats are 64 bits per 4x4 block.
82 case kLATC_Format: 75 case kLATC_Format:
83 case kR11_EAC_Format: 76 case kR11_EAC_Format:
84 case kETC1_Format: 77 case kETC1_Format:
85 encodedBlockSize = 8; 78 encodedBlockSize = 8;
86 break; 79 break;
87 80
88 // This format is 128 bits. 81 // This format is 12x12 blocks to 128 bits.
89 case kASTC_4x4_Format:
90 case kASTC_5x4_Format:
91 case kASTC_5x5_Format:
92 case kASTC_6x5_Format:
93 case kASTC_6x6_Format:
94 case kASTC_8x5_Format:
95 case kASTC_8x6_Format:
96 case kASTC_8x8_Format:
97 case kASTC_10x5_Format:
98 case kASTC_10x6_Format:
99 case kASTC_10x8_Format:
100 case kASTC_10x10_Format:
101 case kASTC_12x10_Format:
102 case kASTC_12x12_Format: 82 case kASTC_12x12_Format:
103 encodedBlockSize = 16; 83 encodedBlockSize = 16;
104 break; 84 break;
105 85
106 default: 86 default:
107 SkFAIL("Unknown compressed format!"); 87 SkFAIL("Unknown compressed format!");
108 return -1; 88 return -1;
109 } 89 }
110 90
111 if(((width % dimX) == 0) && ((height % dimY) == 0)) { 91 if(((width % dimX) == 0) && ((height % dimY) == 0)) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 return true; 205 return true;
226 206
227 case kR11_EAC_Format: 207 case kR11_EAC_Format:
228 DecompressR11EAC(dst, dstRowBytes, src, width, height); 208 DecompressR11EAC(dst, dstRowBytes, src, width, height);
229 return true; 209 return true;
230 210
231 #ifndef SK_IGNORE_ETC1_SUPPORT 211 #ifndef SK_IGNORE_ETC1_SUPPORT
232 case kETC1_Format: 212 case kETC1_Format:
233 return 0 == etc1_decode_image(src, dst, width, height, 3, dstRowByte s); 213 return 0 == etc1_decode_image(src, dst, width, height, 3, dstRowByte s);
234 #endif 214 #endif
235
236 case kASTC_4x4_Format:
237 case kASTC_5x4_Format:
238 case kASTC_5x5_Format:
239 case kASTC_6x5_Format:
240 case kASTC_6x6_Format:
241 case kASTC_8x5_Format:
242 case kASTC_8x6_Format:
243 case kASTC_8x8_Format:
244 case kASTC_10x5_Format:
245 case kASTC_10x6_Format:
246 case kASTC_10x8_Format:
247 case kASTC_10x10_Format:
248 case kASTC_12x10_Format:
249 case kASTC_12x12_Format: 215 case kASTC_12x12_Format:
250 DecompressASTC(dst, dstRowBytes, src, width, height, dimX, dimY); 216 // TODO(krajcevski) .. right now just fall through and return false.
251 return true; 217 return false;
252 218
253 default: 219 default:
254 // Do nothing... 220 // Do nothing...
255 break; 221 break;
256 } 222 }
257 223
258 return false; 224 return false;
259 } 225 }
260 226
261 } // namespace SkTextureCompressor 227 } // namespace SkTextureCompressor
OLDNEW
« no previous file with comments | « src/utils/SkTextureCompressor.h ('k') | src/utils/SkTextureCompressor_ASTC.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698