Revert "Remove all KTX support"
This reverts commit ada12ab0557a1f540e775288e2ce44f64fcd8c7e.
Reason for revert: Google3 needs it:
https://test.corp.google.com/ui#id=OCL:142184832:BASE:142184975:1481839118985:32fde8ef
Original change's description:
> Remove all KTX support
>
> It is untested and unused.
>
> Change-Id: I010ff4ad942738f362d42a99af4edbbb1cb0cd71
> Reviewed-on: https://skia-review.googlesource.com/6142
> Commit-Queue: Leon Scroggins <scroggo@google.com>
> Reviewed-by: Mike Klein <mtklein@chromium.org>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
>
TBR=mtklein@chromium.org,mtklein@google.com,robertphillips@google.com,scroggo@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: I1ea2f9487eb2212efbfcc514122792b70c9e8737
Reviewed-on: https://skia-review.googlesource.com/6181
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index d1cecde..4147855 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -40,6 +40,7 @@
#include "effects/GrYUVEffect.h"
#ifndef SK_IGNORE_ETC1_SUPPORT
+# include "ktx.h"
# include "etc1.h"
#endif
@@ -87,6 +88,22 @@
*outStartOfDataToUpload = bytes + ETC_PKM_HEADER_SIZE;
return kETC1_GrPixelConfig;
+ } else if (SkKTXFile::is_ktx(bytes, data->size())) {
+ SkKTXFile ktx(data);
+
+ // Is it actually an ETC1 texture?
+ if (!ktx.isCompressedFormat(SkTextureCompressor::kETC1_Format)) {
+ return kUnknown_GrPixelConfig;
+ }
+
+ // Does the data match the dimensions of the bitmap? If not,
+ // then we don't know how to scale the image to match it...
+ if (ktx.width() != expectedW || ktx.height() != expectedH) {
+ return kUnknown_GrPixelConfig;
+ }
+
+ *outStartOfDataToUpload = ktx.pixelData();
+ return kETC1_GrPixelConfig;
}
#endif
return kUnknown_GrPixelConfig;