| Index: src/gpu/SkGr.cpp
|
| diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
|
| index 716909133a733d28bb03efafe13d214384e47d98..e9698f92aa91fde8cff8ed958cb6a0c2d80dbd05 100644
|
| --- a/src/gpu/SkGr.cpp
|
| +++ b/src/gpu/SkGr.cpp
|
| @@ -22,6 +22,7 @@
|
| #include "SkConfig8888.h"
|
| #include "SkCanvas.h"
|
| #include "SkData.h"
|
| +#include "SkEncodedFormat.h"
|
| #include "SkErrorInternals.h"
|
| #include "SkGrPixelRef.h"
|
| #include "SkMessageBus.h"
|
| @@ -66,6 +67,37 @@ void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& ima
|
| builder[4] = imageBounds.fBottom;
|
| }
|
|
|
| +bool GrIsCompressedFormatPossiblySupported(GrContext* ctx, SkEncodedFormat format) {
|
| +#ifndef SK_IGNORE_ETC1_SUPPORT
|
| + if (!ctx->caps()->isConfigTexturable(kETC1_GrPixelConfig)) {
|
| + return false;
|
| + }
|
| + switch (format) {
|
| + case kPKM_SkEncodedFormat: // file format for ETC1
|
| + return true;
|
| + default:
|
| + return false;
|
| + }
|
| +#endif
|
| + return false;
|
| +}
|
| +
|
| +bool GrIsCompressedTextureDataPossiblySupported(GrContext* ctx, const void* data, size_t size) {
|
| +#ifndef SK_IGNORE_ETC1_SUPPORT
|
| + if (!ctx->caps()->isConfigTexturable(kETC1_GrPixelConfig)) {
|
| + return false;
|
| + }
|
| +
|
| + const uint8_t* bytes = reinterpret_cast<const uint8_t*>(data);
|
| + if (size > ETC_PKM_HEADER_SIZE && etc1_pkm_is_valid(bytes)) {
|
| + return true;
|
| + } else if (SkKTXFile::is_ktx(bytes, size)) {
|
| + return true;
|
| + }
|
| +#endif
|
| + return false;
|
| +}
|
| +
|
| GrPixelConfig GrIsCompressedTextureDataSupported(GrContext* ctx, SkData* data,
|
| int expectedW, int expectedH,
|
| const void** outStartOfDataToUpload) {
|
| @@ -87,7 +119,7 @@ GrPixelConfig GrIsCompressedTextureDataSupported(GrContext* ctx, SkData* data,
|
|
|
| *outStartOfDataToUpload = bytes + ETC_PKM_HEADER_SIZE;
|
| return kETC1_GrPixelConfig;
|
| - } else if (SkKTXFile::is_ktx(bytes)) {
|
| + } else if (SkKTXFile::is_ktx(bytes, data->size())) {
|
| SkKTXFile ktx(data);
|
|
|
| // Is it actually an ETC1 texture?
|
|
|