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

Unified Diff: src/utils/SkTextureCompressor.cpp

Issue 444093002: - Add astcbitmap to gm slides (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Decode trits/quints into temp buffers 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 side-by-side diff with in-line comments
Download patch
Index: src/utils/SkTextureCompressor.cpp
diff --git a/src/utils/SkTextureCompressor.cpp b/src/utils/SkTextureCompressor.cpp
index 4034615b37f389a024547be0116574eb3e580f7a..b90d905d105fe6dad2b4601a84e0cf5d738cbc75 100644
--- a/src/utils/SkTextureCompressor.cpp
+++ b/src/utils/SkTextureCompressor.cpp
@@ -44,24 +44,31 @@ void GetBlockDimensions(Format format, int* dimX, int* dimY, bool matchSpec) {
}
// No specialized arguments, return the dimensions as they are in the spec.
- switch(format) {
- // These formats are 64 bits per 4x4 block.
- default:
- SkDEBUGFAIL("Unknown compression format!");
- // fall through
- case kLATC_Format:
- case kR11_EAC_Format:
- case kETC1_Format:
- *dimX = 4;
- *dimY = 4;
- break;
-
- // This format is 12x12 blocks to 128 bits.
- case kASTC_12x12_Format:
- *dimX = 12;
- *dimY = 12;
- break;
- }
+ static const struct FormatDimensions {
+ const int fBlockSizeX;
+ const int fBlockSizeY;
+ } kFormatDimensions[kFormatCnt] = {
+ { 4, 4 }, // kLATC_Format
+ { 4, 4 }, // kR11_EAC_Format
+ { 4, 4 }, // kETC1_Format
+ { 4, 4 }, // kASTC_4x4_Format
+ { 5, 4 }, // kASTC_5x4_Format
+ { 5, 5 }, // kASTC_5x5_Format
+ { 6, 5 }, // kASTC_6x5_Format
+ { 6, 6 }, // kASTC_6x6_Format
+ { 8, 5 }, // kASTC_8x5_Format
+ { 8, 6 }, // kASTC_8x6_Format
+ { 8, 8 }, // kASTC_8x8_Format
+ { 10, 5 }, // kASTC_10x5_Format
+ { 10, 6 }, // kASTC_10x6_Format
+ { 10, 8 }, // kASTC_10x8_Format
+ { 10, 10 }, // kASTC_10x10_Format
+ { 12, 10 }, // kASTC_12x10_Format
+ { 12, 12 }, // kASTC_12x12_Format
+ };
+
+ *dimX = kFormatDimensions[format].fBlockSizeX;
+ *dimY = kFormatDimensions[format].fBlockSizeY;
}
int GetCompressedDataSize(Format fmt, int width, int height) {
@@ -78,7 +85,20 @@ int GetCompressedDataSize(Format fmt, int width, int height) {
encodedBlockSize = 8;
break;
- // This format is 12x12 blocks to 128 bits.
+ // This format is 128 bits.
+ case kASTC_4x4_Format:
+ case kASTC_5x4_Format:
+ case kASTC_5x5_Format:
+ case kASTC_6x5_Format:
+ case kASTC_6x6_Format:
+ case kASTC_8x5_Format:
+ case kASTC_8x6_Format:
+ case kASTC_8x8_Format:
+ case kASTC_10x5_Format:
+ case kASTC_10x6_Format:
+ case kASTC_10x8_Format:
+ case kASTC_10x10_Format:
+ case kASTC_12x10_Format:
case kASTC_12x12_Format:
encodedBlockSize = 16;
break;
@@ -212,9 +232,23 @@ bool DecompressBufferFromFormat(uint8_t* dst, int dstRowBytes, const uint8_t* sr
case kETC1_Format:
return 0 == etc1_decode_image(src, dst, width, height, 3, dstRowBytes);
#endif
+
+ case kASTC_4x4_Format:
+ case kASTC_5x4_Format:
+ case kASTC_5x5_Format:
+ case kASTC_6x5_Format:
+ case kASTC_6x6_Format:
+ case kASTC_8x5_Format:
+ case kASTC_8x6_Format:
+ case kASTC_8x8_Format:
+ case kASTC_10x5_Format:
+ case kASTC_10x6_Format:
+ case kASTC_10x8_Format:
+ case kASTC_10x10_Format:
+ case kASTC_12x10_Format:
case kASTC_12x12_Format:
- // TODO(krajcevski) .. right now just fall through and return false.
- return false;
+ DecompressASTC(dst, dstRowBytes, src, width, height, dimX, dimY);
+ return true;
default:
// Do nothing...

Powered by Google App Engine
This is Rietveld 408576698