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

Unified Diff: src/utils/SkTextureCompressor.cpp

Issue 422023006: Add query for block dimensions of a given format (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Bracketing ifdefs Created 6 years, 5 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
« no previous file with comments | « src/utils/SkTextureCompressor.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkTextureCompressor.cpp
diff --git a/src/utils/SkTextureCompressor.cpp b/src/utils/SkTextureCompressor.cpp
index 40c0d3e5e88714c80fca9a64661276a28c75f8b0..f5c134d75db77eb3ba84754f7c491bf4da0e1348 100644
--- a/src/utils/SkTextureCompressor.cpp
+++ b/src/utils/SkTextureCompressor.cpp
@@ -20,21 +20,48 @@
namespace SkTextureCompressor {
+void GetBlockDimensions(Format format, int* dimX, int* dimY) {
+ if (NULL == dimX || NULL == dimY) {
+ return;
+ }
+
+ if (SkTextureCompressorGetPlatformDims(format, dimX, dimY)) {
+ return;
+ }
+
+ switch(format) {
+ // These formats are 64 bits per 4x4 block.
+ default:
+ SkDEBUGFAIL("Unknown compression format!");
+ // fall through
+ case kR11_EAC_Format:
+ case kLATC_Format:
+ *dimX = 4;
+ *dimY = 4;
+ break;
+
+ // This format is 12x12 blocks to 128 bits.
+ case kASTC_12x12_Format:
+ *dimX = 12;
+ *dimY = 12;
+ break;
+ }
+}
+
int GetCompressedDataSize(Format fmt, int width, int height) {
- int blockDimension = 0;
+ int dimX, dimY;
+ GetBlockDimensions(fmt, &dimX, &dimY);
int encodedBlockSize = 0;
switch (fmt) {
// These formats are 64 bits per 4x4 block.
case kR11_EAC_Format:
case kLATC_Format:
- blockDimension = 4;
encodedBlockSize = 8;
break;
// This format is 12x12 blocks to 128 bits.
case kASTC_12x12_Format:
- blockDimension = 12;
encodedBlockSize = 16;
break;
@@ -43,9 +70,9 @@ int GetCompressedDataSize(Format fmt, int width, int height) {
return -1;
}
- if(((width % blockDimension) == 0) && ((height % blockDimension) == 0)) {
- const int blocksX = width / blockDimension;
- const int blocksY = height / blockDimension;
+ if(((width % dimX) == 0) && ((height % dimY) == 0)) {
+ const int blocksX = width / dimX;
+ const int blocksY = height / dimY;
return blocksX * blocksY * encodedBlockSize;
}
« no previous file with comments | « src/utils/SkTextureCompressor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698