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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "SkEndian.h" | 10 #include "SkEndian.h" |
11 #include "SkImageInfo.h" | 11 #include "SkImageInfo.h" |
| 12 #include "SkTemplates.h" |
12 #include "SkTextureCompressor.h" | 13 #include "SkTextureCompressor.h" |
13 #include "Test.h" | 14 #include "Test.h" |
14 | 15 |
15 // TODO: Create separate tests for RGB and RGBA data once | 16 // TODO: Create separate tests for RGB and RGBA data once |
16 // ASTC and ETC1 decompression is implemented. | 17 // ASTC and ETC1 decompression is implemented. |
17 | 18 |
18 static bool decompresses_a8(SkTextureCompressor::Format fmt) { | 19 static bool decompresses_a8(SkTextureCompressor::Format fmt) { |
19 switch (fmt) { | 20 switch (fmt) { |
20 case SkTextureCompressor::kLATC_Format: | 21 case SkTextureCompressor::kLATC_Format: |
21 case SkTextureCompressor::kR11_EAC_Format: | 22 case SkTextureCompressor::kR11_EAC_Format: |
(...skipping 107 matching lines...) Loading... |
129 if ((x ^ y) & 1) { | 130 if ((x ^ y) & 1) { |
130 pixels[x] = 0xFF; | 131 pixels[x] = 0xFF; |
131 } else { | 132 } else { |
132 pixels[x] = 0; | 133 pixels[x] = 0; |
133 } | 134 } |
134 } | 135 } |
135 pixels += pixmap.rowBytes(); | 136 pixels += pixmap.rowBytes(); |
136 } | 137 } |
137 } | 138 } |
138 | 139 |
139 SkAutoMalloc decompMemory(kWidth*kHeight); | 140 SkAutoTMalloc<uint8_t> decompMemory(kWidth*kHeight); |
140 uint8_t* decompBuffer = reinterpret_cast<uint8_t*>(decompMemory.get()); | 141 uint8_t* decompBuffer = decompMemory.get(); |
141 REPORTER_ASSERT(reporter, decompBuffer); | 142 REPORTER_ASSERT(reporter, decompBuffer); |
142 if (nullptr == decompBuffer) { | 143 if (nullptr == decompBuffer) { |
143 return; | 144 return; |
144 } | 145 } |
145 | 146 |
146 for (int i = 0; i < SkTextureCompressor::kFormatCnt; ++i) { | 147 for (int i = 0; i < SkTextureCompressor::kFormatCnt; ++i) { |
147 const SkTextureCompressor::Format fmt = static_cast<SkTextureCompressor:
:Format>(i); | 148 const SkTextureCompressor::Format fmt = static_cast<SkTextureCompressor:
:Format>(i); |
148 | 149 |
149 // Ignore formats for RGBA data, since the decompressed buffer | 150 // Ignore formats for RGBA data, since the decompressed buffer |
150 // won't match the size and contents of the original. | 151 // won't match the size and contents of the original. |
(...skipping 115 matching lines...) Loading... |
266 (kIndex << 28) | (kIndex << 31) | (kIndex << 34) | (kIndex << 37
) | | 267 (kIndex << 28) | (kIndex << 31) | (kIndex << 34) | (kIndex << 37
) | |
267 (kIndex << 40) | (kIndex << 43) | (kIndex << 46) | (kIndex << 49
) | | 268 (kIndex << 40) | (kIndex << 43) | (kIndex << 46) | (kIndex << 49
) | |
268 (kIndex << 52) | (kIndex << 55) | (kIndex << 58) | (kIndex << 61
)); | 269 (kIndex << 52) | (kIndex << 55) | (kIndex << 58) | (kIndex << 61
)); |
269 | 270 |
270 const uint64_t* blockPtr = reinterpret_cast<const uint64_t*>(latcData->d
ata()); | 271 const uint64_t* blockPtr = reinterpret_cast<const uint64_t*>(latcData->d
ata()); |
271 for (size_t i = 0; i < (kSizeToBe/8); ++i) { | 272 for (size_t i = 0; i < (kSizeToBe/8); ++i) { |
272 REPORTER_ASSERT(reporter, blockPtr[i] == kConstColorEncoding); | 273 REPORTER_ASSERT(reporter, blockPtr[i] == kConstColorEncoding); |
273 } | 274 } |
274 } | 275 } |
275 } | 276 } |
OLD | NEW |