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

Unified Diff: src/utils/SkTextureCompressor.cpp

Issue 417933005: Add preliminary ASTC encoder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Code review changes 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') | src/utils/SkTextureCompressor_ASTC.h » ('j') | 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 453d98912d986737dd96a991ed441dc9ed2d0715..40c0d3e5e88714c80fca9a64661276a28c75f8b0 100644
--- a/src/utils/SkTextureCompressor.cpp
+++ b/src/utils/SkTextureCompressor.cpp
@@ -6,8 +6,9 @@
*/
#include "SkTextureCompressor.h"
-#include "SkTextureCompressor_R11EAC.h"
+#include "SkTextureCompressor_ASTC.h"
#include "SkTextureCompressor_LATC.h"
+#include "SkTextureCompressor_R11EAC.h"
#include "SkBitmap.h"
#include "SkData.h"
@@ -20,29 +21,36 @@
namespace SkTextureCompressor {
int GetCompressedDataSize(Format fmt, int width, int height) {
+ int blockDimension = 0;
+ int encodedBlockSize = 0;
+
switch (fmt) {
// These formats are 64 bits per 4x4 block.
case kR11_EAC_Format:
case kLATC_Format:
- {
- static const int kBlockDimension = 4;
- static const int kEncodedBlockSize = 8;
-
- if(((width % kBlockDimension) == 0) && ((height % kBlockDimension) == 0)) {
-
- const int blocksX = width / kBlockDimension;
- const int blocksY = height / kBlockDimension;
-
- return blocksX * blocksY * kEncodedBlockSize;
- }
+ blockDimension = 4;
+ encodedBlockSize = 8;
+ break;
- return -1;
- }
+ // This format is 12x12 blocks to 128 bits.
+ case kASTC_12x12_Format:
+ blockDimension = 12;
+ encodedBlockSize = 16;
+ break;
default:
SkFAIL("Unknown compressed format!");
return -1;
}
+
+ if(((width % blockDimension) == 0) && ((height % blockDimension) == 0)) {
+ const int blocksX = width / blockDimension;
+ const int blocksY = height / blockDimension;
+
+ return blocksX * blocksY * encodedBlockSize;
+ }
+
+ return -1;
}
bool CompressBufferToFormat(uint8_t* dst, const uint8_t* src, SkColorType srcColorType,
@@ -63,6 +71,9 @@ bool CompressBufferToFormat(uint8_t* dst, const uint8_t* src, SkColorType srcCol
case kR11_EAC_Format:
proc = CompressA8ToR11EAC;
break;
+ case kASTC_12x12_Format:
+ proc = CompressA8To12x12ASTC;
+ break;
default:
// Do nothing...
break;
« no previous file with comments | « src/utils/SkTextureCompressor.h ('k') | src/utils/SkTextureCompressor_ASTC.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698