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

Unified Diff: src/utils/SkTextureCompressor.cpp

Issue 432143002: Add ETC1 format to SkTextureCompressor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add default clause to texture compressor. 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
« no previous file with comments | « src/utils/SkTextureCompressor.h ('k') | tests/TextureCompressionTest.cpp » ('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 801328642ff301cd4cad88232373c67316273378..4034615b37f389a024547be0116574eb3e580f7a 100644
--- a/src/utils/SkTextureCompressor.cpp
+++ b/src/utils/SkTextureCompressor.cpp
@@ -16,6 +16,20 @@
#include "SkTextureCompression_opts.h"
+#ifndef SK_IGNORE_ETC1_SUPPORT
+# include "etc1.h"
+#endif
+
+// Convert ETC1 functions to our function signatures
+static bool compress_etc1_565(uint8_t* dst, const uint8_t* src,
+ int width, int height, int rowBytes) {
+#ifndef SK_IGNORE_ETC1_SUPPORT
+ return 0 == etc1_encode_image(src, width, height, 2, rowBytes, dst);
+#else
+ return false;
+#endif
+}
+
////////////////////////////////////////////////////////////////////////////////
namespace SkTextureCompressor {
@@ -35,8 +49,9 @@ void GetBlockDimensions(Format format, int* dimX, int* dimY, bool matchSpec) {
default:
SkDEBUGFAIL("Unknown compression format!");
// fall through
- case kR11_EAC_Format:
case kLATC_Format:
+ case kR11_EAC_Format:
+ case kETC1_Format:
*dimX = 4;
*dimY = 4;
break;
@@ -57,8 +72,9 @@ int GetCompressedDataSize(Format fmt, int width, int height) {
switch (fmt) {
// These formats are 64 bits per 4x4 block.
- case kR11_EAC_Format:
case kLATC_Format:
+ case kR11_EAC_Format:
+ case kETC1_Format:
encodedBlockSize = 8;
break;
@@ -110,6 +126,19 @@ bool CompressBufferToFormat(uint8_t* dst, const uint8_t* src, SkColorType srcCol
}
break;
+ case kRGB_565_SkColorType:
+ {
+ switch (format) {
+ case kETC1_Format:
+ proc = compress_etc1_565;
+ break;
+ default:
+ // Do nothing...
+ break;
+ }
+ }
+ break;
+
default:
// Do nothing...
break;
@@ -179,9 +208,17 @@ bool DecompressBufferFromFormat(uint8_t* dst, int dstRowBytes, const uint8_t* sr
DecompressR11EAC(dst, dstRowBytes, src, width, height);
return true;
+#ifndef SK_IGNORE_ETC1_SUPPORT
+ case kETC1_Format:
+ return 0 == etc1_decode_image(src, dst, width, height, 3, dstRowBytes);
+#endif
case kASTC_12x12_Format:
// TODO(krajcevski) .. right now just fall through and return false.
return false;
+
+ default:
+ // Do nothing...
+ break;
}
return false;
« no previous file with comments | « src/utils/SkTextureCompressor.h ('k') | tests/TextureCompressionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698