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

Unified Diff: src/images/SkImageDecoder_ktx.cpp

Issue 1707053002: Delete KTX tests to fix Android build (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Delete SkImageDecoderGenerator as well Created 4 years, 10 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 | « bench/ETCBitmapBench.cpp ('k') | tests/KtxTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_ktx.cpp
diff --git a/src/images/SkImageDecoder_ktx.cpp b/src/images/SkImageDecoder_ktx.cpp
index 019fa97678f8fa23275395068f7466afdf2d3a56..539795ad9bb56b9ba4610ad6ae31d33fc7a8540b 100644
--- a/src/images/SkImageDecoder_ktx.cpp
+++ b/src/images/SkImageDecoder_ktx.cpp
@@ -329,101 +329,3 @@ SkImageEncoder* sk_libktx_efactory(SkImageEncoder::Type t) {
static SkImageDecoder_DecodeReg gReg(sk_libktx_dfactory);
static SkImageDecoder_FormatReg gFormatReg(get_format_ktx);
static SkImageEncoder_EncodeReg gEReg(sk_libktx_efactory);
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Old implementation of SkImageGenerator::NewFromEncoded which uses SkImageDecoder.
-// Here because it is only needed by DM and tests for Ktx.
-class BareMemoryAllocator : public SkBitmap::Allocator {
- const SkImageInfo fInfo;
- void* const fMemory;
- const size_t fRowBytes;
-
-public:
- BareMemoryAllocator(const SkImageInfo& info, void* memory, size_t rowBytes)
- : fInfo(info), fMemory(memory), fRowBytes(rowBytes)
- {}
-
-protected:
- bool allocPixelRef(SkBitmap* bm, SkColorTable* ctable) override {
- const SkImageInfo bmi = bm->info();
- if (bmi.width() != fInfo.width() || bmi.height() != fInfo.height() ||
- bmi.colorType() != fInfo.colorType())
- {
- return false;
- }
- return bm->installPixels(bmi, fMemory, fRowBytes, ctable, nullptr, nullptr);
- }
-};
-
-class SkImageDecoderGenerator : public SkImageGenerator {
- const SkImageInfo fInfo;
- SkAutoTDelete<SkImageDecoder> fDecoder;
- SkAutoTUnref<SkData> fData;
-
-public:
- SkImageDecoderGenerator(const SkImageInfo& info, SkImageDecoder* decoder, SkData* data)
- : INHERITED(info), fInfo(info), fDecoder(decoder), fData(SkRef(data))
- {}
-
-protected:
- SkData* onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM) override {
- return SkRef(fData.get());
- }
- bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
- SkPMColor ctableEntries[], int* ctableCount) override {
- SkMemoryStream stream(fData->data(), fData->size(), false);
- SkAutoTUnref<BareMemoryAllocator> allocator(
- new BareMemoryAllocator(info, pixels, rowBytes));
- fDecoder->setAllocator(allocator);
- fDecoder->setRequireUnpremultipliedColors(kUnpremul_SkAlphaType == info.alphaType());
-
- SkBitmap bm;
- const SkImageDecoder::Result result = fDecoder->decode(&stream, &bm, info.colorType(),
- SkImageDecoder::kDecodePixels_Mode);
- if (SkImageDecoder::kFailure == result) {
- return false;
- }
-
- SkASSERT(info.colorType() == bm.info().colorType());
-
- if (kIndex_8_SkColorType == info.colorType()) {
- SkASSERT(ctableEntries);
-
- SkColorTable* ctable = bm.getColorTable();
- if (nullptr == ctable) {
- return false;
- }
- const int count = ctable->count();
- memcpy(ctableEntries, ctable->readColors(), count * sizeof(SkPMColor));
- *ctableCount = count;
- }
- return true;
- }
-
- bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3],
- SkYUVColorSpace* colorSpace) override {
- SkMemoryStream stream(fData->data(), fData->size(), false);
- return fDecoder->decodeYUV8Planes(&stream, sizes, planes, rowBytes, colorSpace);
- }
-
-private:
- typedef SkImageGenerator INHERITED;
-};
-
-SkImageGenerator* decoder_image_generator(SkData* data) {
- SkMemoryStream stream(data->data(), data->size(), false);
- SkImageDecoder* decoder = SkImageDecoder::Factory(&stream);
- if (nullptr == decoder) {
- return nullptr;
- }
-
- SkBitmap bm;
- stream.rewind();
- if (!decoder->decode(&stream, &bm, kUnknown_SkColorType, SkImageDecoder::kDecodeBounds_Mode)) {
- delete decoder;
- return nullptr;
- }
-
- return new SkImageDecoderGenerator(bm.info(), decoder, data);
-}
-
« no previous file with comments | « bench/ETCBitmapBench.cpp ('k') | tests/KtxTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698