Remove dep from ktx to SkTextureCompressor.
authorHerb Derby <herb@google.com>
Thu, 9 Feb 2017 19:50:17 +0000 (14:50 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Thu, 9 Feb 2017 22:10:16 +0000 (22:10 +0000)
If this breaks anything in google3 revert it.

Change-Id: I35eb588e753a6fad78c1255556daae145533c801
Reviewed-on: https://skia-review.googlesource.com/8275
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Herb Derby <herb@google.com>

third_party/ktx/ktx.cpp
third_party/ktx/ktx.h

index a65c6f2..c96a308 100644 (file)
@@ -17,8 +17,8 @@
 
 #include "etc1.h"
 
-static inline uint32_t compressed_fmt_to_gl_define(SkTextureCompressor::Format fmt) {
-    static const uint32_t kGLDefineMap[SkTextureCompressor::kFormatCnt] = {
+static inline uint32_t compressed_fmt_to_gl_define(SkKTXFile::Format fmt) {
+    static const uint32_t kGLDefineMap[SkKTXFile::kFormatCnt] = {
         GR_GL_COMPRESSED_LUMINANCE_LATC1,      // kLATC_Format
         GR_GL_COMPRESSED_R11_EAC,              // kR11_EAC_Format
         GR_GL_COMPRESSED_ETC1_RGB8,            // kETC1_Format
@@ -38,24 +38,24 @@ static inline uint32_t compressed_fmt_to_gl_define(SkTextureCompressor::Format f
         GR_GL_COMPRESSED_RGBA_ASTC_12x12,      // kASTC_12x12_Format
     };
 
-    GR_STATIC_ASSERT(0 == SkTextureCompressor::kLATC_Format);
-    GR_STATIC_ASSERT(1 == SkTextureCompressor::kR11_EAC_Format);
-    GR_STATIC_ASSERT(2 == SkTextureCompressor::kETC1_Format);
-    GR_STATIC_ASSERT(3 == SkTextureCompressor::kASTC_4x4_Format);
-    GR_STATIC_ASSERT(4 == SkTextureCompressor::kASTC_5x4_Format);
-    GR_STATIC_ASSERT(5 == SkTextureCompressor::kASTC_5x5_Format);
-    GR_STATIC_ASSERT(6 == SkTextureCompressor::kASTC_6x5_Format);
-    GR_STATIC_ASSERT(7 == SkTextureCompressor::kASTC_6x6_Format);
-    GR_STATIC_ASSERT(8 == SkTextureCompressor::kASTC_8x5_Format);
-    GR_STATIC_ASSERT(9 == SkTextureCompressor::kASTC_8x6_Format);
-    GR_STATIC_ASSERT(10 == SkTextureCompressor::kASTC_8x8_Format);
-    GR_STATIC_ASSERT(11 == SkTextureCompressor::kASTC_10x5_Format);
-    GR_STATIC_ASSERT(12 == SkTextureCompressor::kASTC_10x6_Format);
-    GR_STATIC_ASSERT(13 == SkTextureCompressor::kASTC_10x8_Format);
-    GR_STATIC_ASSERT(14 == SkTextureCompressor::kASTC_10x10_Format);
-    GR_STATIC_ASSERT(15 == SkTextureCompressor::kASTC_12x10_Format);
-    GR_STATIC_ASSERT(16 == SkTextureCompressor::kASTC_12x12_Format);
-    GR_STATIC_ASSERT(SK_ARRAY_COUNT(kGLDefineMap) == SkTextureCompressor::kFormatCnt);
+    GR_STATIC_ASSERT(0 == SkKTXFile::kLATC_Format);
+    GR_STATIC_ASSERT(1 == SkKTXFile::kR11_EAC_Format);
+    GR_STATIC_ASSERT(2 == SkKTXFile::kETC1_Format);
+    GR_STATIC_ASSERT(3 == SkKTXFile::kASTC_4x4_Format);
+    GR_STATIC_ASSERT(4 == SkKTXFile::kASTC_5x4_Format);
+    GR_STATIC_ASSERT(5 == SkKTXFile::kASTC_5x5_Format);
+    GR_STATIC_ASSERT(6 == SkKTXFile::kASTC_6x5_Format);
+    GR_STATIC_ASSERT(7 == SkKTXFile::kASTC_6x6_Format);
+    GR_STATIC_ASSERT(8 == SkKTXFile::kASTC_8x5_Format);
+    GR_STATIC_ASSERT(9 == SkKTXFile::kASTC_8x6_Format);
+    GR_STATIC_ASSERT(10 == SkKTXFile::kASTC_8x8_Format);
+    GR_STATIC_ASSERT(11 == SkKTXFile::kASTC_10x5_Format);
+    GR_STATIC_ASSERT(12 == SkKTXFile::kASTC_10x6_Format);
+    GR_STATIC_ASSERT(13 == SkKTXFile::kASTC_10x8_Format);
+    GR_STATIC_ASSERT(14 == SkKTXFile::kASTC_10x10_Format);
+    GR_STATIC_ASSERT(15 == SkKTXFile::kASTC_12x10_Format);
+    GR_STATIC_ASSERT(16 == SkKTXFile::kASTC_12x12_Format);
+    GR_STATIC_ASSERT(SK_ARRAY_COUNT(kGLDefineMap) == SkKTXFile::kFormatCnt);
 
     return kGLDefineMap[fmt];
 }
@@ -168,14 +168,14 @@ SkString SkKTXFile::getValueForKey(const SkString& key) const {
     return SkString();
 }
 
-bool SkKTXFile::isCompressedFormat(SkTextureCompressor::Format fmt) const {
+bool SkKTXFile::isCompressedFormat(Format fmt) const {
     if (!this->valid()) {
         return false;
     }
 
     // This has many aliases
     bool isFmt = false;
-    if (fmt == SkTextureCompressor::kLATC_Format) {
+    if (fmt == kLATC_Format) {
         isFmt = GR_GL_COMPRESSED_RED_RGTC1 == fHeader.fGLInternalFormat ||
                 GR_GL_COMPRESSED_3DC_X == fHeader.fGLInternalFormat;
     }
index 3aaea15..22872ab 100644 (file)
@@ -10,7 +10,6 @@
 #define SkKTXFile_DEFINED
 
 #include "SkData.h"
-#include "SkTextureCompressor.h"
 #include "SkTypes.h"
 #include "SkTDArray.h"
 #include "SkString.h"
@@ -32,6 +31,39 @@ class SkWStream;
 
 class SkKTXFile {
 public:
+    // Various texture compression formats that we support.
+    enum Format {
+        // Alpha only formats.
+        kLATC_Format,       // 4x4 blocks, (de)compresses A8
+        kR11_EAC_Format,    // 4x4 blocks, (de)compresses A8
+
+        // RGB only formats
+        kETC1_Format,       // 4x4 blocks, compresses RGB 565, decompresses 8-bit RGB
+        //    NOTE: ETC1 supports 8-bit RGB compression, but we
+        //    currently don't have any RGB8 SkColorTypes. We could
+        //    support 8-bit RGBA but we would have to preprocess the
+        //    bitmap to insert alphas.
+
+        // Multi-purpose formats
+        kASTC_4x4_Format,   // 4x4 blocks, no compression, decompresses RGBA
+        kASTC_5x4_Format,   // 5x4 blocks, no compression, decompresses RGBA
+        kASTC_5x5_Format,   // 5x5 blocks, no compression, decompresses RGBA
+        kASTC_6x5_Format,   // 6x5 blocks, no compression, decompresses RGBA
+        kASTC_6x6_Format,   // 6x6 blocks, no compression, decompresses RGBA
+        kASTC_8x5_Format,   // 8x5 blocks, no compression, decompresses RGBA
+        kASTC_8x6_Format,   // 8x6 blocks, no compression, decompresses RGBA
+        kASTC_8x8_Format,   // 8x8 blocks, no compression, decompresses RGBA
+        kASTC_10x5_Format,  // 10x5 blocks, no compression, decompresses RGBA
+        kASTC_10x6_Format,  // 10x6 blocks, no compression, decompresses RGBA
+        kASTC_10x8_Format,  // 10x8 blocks, no compression, decompresses RGBA
+        kASTC_10x10_Format, // 10x10 blocks, no compression, decompresses RGBA
+        kASTC_12x10_Format, // 12x10 blocks, no compression, decompresses RGBA
+        kASTC_12x12_Format, // 12x12 blocks, compresses A8, decompresses RGBA
+
+        kLast_Format = kASTC_12x12_Format
+    };
+    static const int kFormatCnt = kLast_Format + 1;
+
     // The ownership of the data remains with the caller. This class is intended
     // to be used as a logical wrapper around the data in order to properly
     // access the pixels.
@@ -57,7 +89,7 @@ public:
 
     int numMipmaps() const { return static_cast<int>(fHeader.fNumberOfMipmapLevels); }
 
-    bool isCompressedFormat(SkTextureCompressor::Format fmt) const;
+    bool isCompressedFormat(Format fmt) const;
     bool isRGBA8() const;
     bool isRGB8() const;