aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar krajcevski <krajcevski@google.com>2014-08-05 14:13:36 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-08-05 14:13:36 -0700
commit40a1e11ebebe81586f3fec96408fdfd4b51123d2 (patch)
treec2174293e43c71dd1d7de3d3568a4dc965f9e462 /src
parent07544757c9fcf0f359f1686a3779eb2e75dd5b36 (diff)
Add support for all compressed formats in KTX file format
R=robertphillips@google.com Author: krajcevski@google.com Review URL: https://codereview.chromium.org/440783004
Diffstat (limited to 'src')
-rw-r--r--src/gpu/SkGr.cpp3
-rw-r--r--src/images/SkImageDecoder_ktx.cpp9
-rw-r--r--src/utils/SkTextureCompressor.h2
3 files changed, 8 insertions, 6 deletions
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 5c0464da20..0a45100521 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -11,6 +11,7 @@
#include "SkData.h"
#include "SkMessageBus.h"
#include "SkPixelRef.h"
+#include "SkTextureCompressor.h"
#include "GrResourceCache.h"
#include "GrGpu.h"
#include "effects/GrDitherEffect.h"
@@ -165,7 +166,7 @@ static GrTexture *load_etc1_texture(GrContext* ctx,
SkKTXFile ktx(data);
// Is it actually an ETC1 texture?
- if (!ktx.isETC1()) {
+ if (!ktx.isCompressedFormat(SkTextureCompressor::kETC1_Format)) {
return NULL;
}
diff --git a/src/images/SkImageDecoder_ktx.cpp b/src/images/SkImageDecoder_ktx.cpp
index 058ab72646..c06450c631 100644
--- a/src/images/SkImageDecoder_ktx.cpp
+++ b/src/images/SkImageDecoder_ktx.cpp
@@ -105,7 +105,7 @@ bool SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
// Lock the pixels, since we're about to write to them...
SkAutoLockPixels alp(*bm);
- if (ktxFile.isETC1()) {
+ if (ktxFile.isCompressedFormat(SkTextureCompressor::kETC1_Format)) {
if (!sampler.begin(bm, SkScaledBitmapSampler::kRGB, *this)) {
return false;
}
@@ -113,11 +113,12 @@ bool SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
// ETC1 Data is encoded as RGB pixels, so we should extract it as such
int nPixels = width * height;
SkAutoMalloc outRGBData(nPixels * 3);
- etc1_byte *outRGBDataPtr = reinterpret_cast<etc1_byte *>(outRGBData.get());
+ uint8_t *outRGBDataPtr = reinterpret_cast<uint8_t *>(outRGBData.get());
// Decode ETC1
- const etc1_byte *buf = reinterpret_cast<const etc1_byte *>(ktxFile.pixelData());
- if (etc1_decode_image(buf, outRGBDataPtr, width, height, 3, width*3)) {
+ const uint8_t *buf = reinterpret_cast<const uint8_t *>(ktxFile.pixelData());
+ if (!SkTextureCompressor::DecompressBufferFromFormat(
+ outRGBDataPtr, width*3, buf, width, height, SkTextureCompressor::kETC1_Format)) {
return false;
}
diff --git a/src/utils/SkTextureCompressor.h b/src/utils/SkTextureCompressor.h
index 4254ae76fb..e44e7b353d 100644
--- a/src/utils/SkTextureCompressor.h
+++ b/src/utils/SkTextureCompressor.h
@@ -9,9 +9,9 @@
#define SkTextureCompressor_DEFINED
#include "SkImageInfo.h"
-#include "SkBlitter.h"
class SkBitmap;
+class SkBlitter;
class SkData;
namespace SkTextureCompressor {