Use old define for gif (for now)
Need to update Flutter (to register some codecs explicitly
and/or use the new define name).
We can also delete some now-dead code that depends on
the very old gif decoder (that was not WUFFS).
Change-Id: I4c9b0c1926ea285a9d88229009097e7e8b61eede
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/811823
Reviewed-by: Ben Wagner <bungeman@google.com>
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index 4812a5a..5f72e5b 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -42,7 +42,7 @@
#include "include/codec/SkBmpDecoder.h"
#endif
-#if defined(SK_CODEC_DECODES_GIF)
+#if defined(SK_CODEC_DECODES_GIF) || defined(SK_HAS_WUFFS_LIBRARY)
#include "include/codec/SkGifDecoder.h"
#endif
@@ -97,7 +97,7 @@
#if defined(SK_CODEC_DECODES_WEBP)
decoders->push_back(SkWebpDecoder::Decoder());
#endif
-#if defined(SK_CODEC_DECODES_GIF)
+#if defined(SK_CODEC_DECODES_GIF) || defined(SK_HAS_WUFFS_LIBRARY)
decoders->push_back(SkGifDecoder::Decoder());
#endif
#if defined(SK_CODEC_DECODES_ICO)
diff --git a/tests/CodecPartialTest.cpp b/tests/CodecPartialTest.cpp
index 640d943..2738068 100644
--- a/tests/CodecPartialTest.cpp
+++ b/tests/CodecPartialTest.cpp
@@ -421,12 +421,7 @@
bm.allocPixels(info);
result = codec->getPixels(info, bm.getPixels(), bm.rowBytes());
- // See the comments in Codec_GifTruncated2.
-#ifdef SK_HAS_WUFFS_LIBRARY
REPORTER_ASSERT(r, result == SkCodec::kIncompleteInput);
-#else
- REPORTER_ASSERT(r, result == SkCodec::kInvalidInput);
-#endif
}
// Again, truncate to 23 bytes, this time for an incremental decode. We
@@ -440,8 +435,6 @@
bm.allocPixels(info);
result = codec->startIncrementalDecode(info, bm.getPixels(), bm.rowBytes());
- // See the comments in Codec_GifTruncated2.
-#ifdef SK_HAS_WUFFS_LIBRARY
REPORTER_ASSERT(r, result == SkCodec::kSuccess);
// Note that this is incrementalDecode, not startIncrementalDecode.
@@ -449,14 +442,6 @@
REPORTER_ASSERT(r, result == SkCodec::kIncompleteInput);
stream->addNewData(data->size());
-#else
- REPORTER_ASSERT(r, result == SkCodec::kIncompleteInput);
-
- // Note that this is startIncrementalDecode, not incrementalDecode.
- stream->addNewData(data->size());
- result = codec->startIncrementalDecode(info, bm.getPixels(), bm.rowBytes());
- REPORTER_ASSERT(r, result == SkCodec::kSuccess);
-#endif
result = codec->incrementalDecode();
REPORTER_ASSERT(r, result == SkCodec::kSuccess);
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index 068b5c8..a91e386 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -1746,56 +1746,9 @@
const char* file = "invalid_images/ossfuzz6274.gif";
auto image = ToolUtils::GetResourceAsImage(file);
-#ifdef SK_HAS_WUFFS_LIBRARY
- // We are transitioning from an old GIF implementation to a new (Wuffs) GIF
- // implementation.
- //
- // This test (without SK_HAS_WUFFS_LIBRARY) is overly specific to the old
- // implementation. In the new implementation, the MakeFromStream factory
- // method returns a nullptr SkImage*, instead of returning a non-null but
- // otherwise all-transparent SkImage*.
- //
- // Either way, the end-to-end result is the same - the source input is
- // rejected as an invalid GIF image - but the two implementations differ in
- // how that's represented.
- //
- // Once the transition is complete, we can remove the #ifdef and delete the
- // rest of the test function.
- //
- // See Codec_GifTruncated3 for the equivalent of the rest of the test
- // function, on different (but still truncated) source data.
if (image) {
ERRORF(r, "Invalid data gave non-nullptr image");
}
- return;
-#else
- if (!image) {
- ERRORF(r, "Missing %s", file);
- return;
- }
-
- REPORTER_ASSERT(r, image->width() == 32);
- REPORTER_ASSERT(r, image->height() == 32);
-
- SkBitmap bm;
- if (!bm.tryAllocPixels(SkImageInfo::MakeN32Premul(32, 32))) {
- ERRORF(r, "Failed to allocate pixels");
- return;
- }
-
- bm.eraseColor(SK_ColorTRANSPARENT);
-
- SkCanvas canvas(bm);
- canvas.drawImage(image, 0, 0);
-
- for (int i = 0; i < image->width(); ++i)
- for (int j = 0; j < image->height(); ++j) {
- SkColor actual = SkUnPreMultiply::PMColorToColor(*bm.getAddr32(i, j));
- if (actual != SK_ColorTRANSPARENT) {
- ERRORF(r, "did not initialize pixels! %i, %i is %x", i, j, actual);
- }
- }
-#endif
}
DEF_TEST(Codec_78329453, r) {